【发布时间】:2020-09-06 17:16:44
【问题描述】:
我在 magento 中有一个 phtml 文件。我正在使用此代码。但它会加载所有子类别。有什么办法可以排除某些子类别
$layer = Mage::getSingleton('catalog/layer');
$category = $layer->getCurrentCategory();
/* @var $category Mage_Catalog_Model_Category */
$collection = Mage::getModel('catalog/category')->getCollection();
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
$collection->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
->addAttributeToSelect('is_anchor')
->addAttributeToSelect('image')
->addAttributeToFilter('is_active', 1)
->addIdFilter($category->getChildren())
->setOrder('position', 'ASC')
->joinUrlRewrite()
->load();
$_categories=$collection;
$_subcategories = $_category->getChildrenCategories()
foreach ($_subcategories as $_subcategory)
{
//need to exclude some subcategory based on its id.
}
【问题讨论】:
标签: php magento categories