質問

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