如何在magento中加载多个类别id?
嗨,我想在magento中加载多个类别id,我在这里使用了,但它只获取子类别的第一个类别,而不是类别的其余部分如何在magento中加载多个类别id?,magento,magento-1.9,Magento,Magento 1.9,嗨,我想在magento中加载多个类别id,我在这里使用了,但它只获取子类别的第一个类别,而不是类别的其余部分 $category = $model->load(79,80,91); 您必须使用收集而不是加载 $collection = Mage::getModel('catalog/category')->getCollection() ->setStoreId(Mage::app()->getStore()->getId
$category = $model->load(79,80,91);
您必须使用收集而不是加载
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addIdFilter(array(79,80,91))
->addAttributeToFilter('is_active', 1)//get only active categories if you want
->addAttributeToSort('position', 'desc'); //sort by position
然后你可以使用循环投掷
foreach($collection as $category) {
echo $category->getName()
}
希望这对您有用。您必须使用收集而不是加载
$collection = Mage::getModel('catalog/category')->getCollection()
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToSelect('name')
->addIdFilter(array(79,80,91))
->addAttributeToFilter('is_active', 1)//get only active categories if you want
->addAttributeToSort('position', 'desc'); //sort by position
然后你可以使用循环投掷
foreach($collection as $category) {
echo $category->getName()
}
希望这对你有用。你可以用这个
$categories = array(10,13);
$_category = Mage::getModel('catalog/category');
$cats = $_category->getCollection()->addAttributeToFilter('entity_id', array('in'=>$categories));
foreach($cats as $cat) {
Zend_Debug::dump($cat);
//or
// do Somthing
}
你可以用这个
$categories = array(10,13);
$_category = Mage::getModel('catalog/category');
$cats = $_category->getCollection()->addAttributeToFilter('entity_id', array('in'=>$categories));
foreach($cats as $cat) {
Zend_Debug::dump($cat);
//or
// do Somthing
}
您可以使用以下选项:
$categories = array(1,2,3);
$category = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('entity_id', array('in'=>$categories));
foreach($category as $categorys) {
//or do Somthing
}
您可以使用以下选项:
$categories = array(1,2,3);
$category = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('entity_id', array('in'=>$categories));
foreach($category as $categorys) {
//or do Somthing
}