Вопрос

I have an array with 3 categories names:

$arr = ['onecat','twocat','threecat'];

How can I get the IDs from this categories? For example in other array.

Это было полезно?

Решение

Make a category Collection in 1.x Version then filter That Collection in condtion;

    $collection=Mage::getResourceModel('catalog/category_collection')
->addAttributeToFilter('name',['in' =>$arr]);

Then those category ids by getAllids()

$collection->getAllIds();

Or:

 $collection=Mage::getResourceModel('catalog/category_collection')
->addAttributeToFilter('name',['in' =>$arr])->addAttributeToSelect('*');
foreach ($collection as $category) {
echo $category->getId();

}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top