问题
I am trying to get only which category name that assigned a product and which category's have not any sub-category.
E.g :
Category
-> Sub-category 1
-> Sub-category 2
-> Sub-category 3
-> Sub-sub-category 1
-> sub-Sub-category 2
-> product 1
-> product 2
The above example , I want to get only sub-sub-category 2.
回答1:
you can try this
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter()
->addAttributeToFilter('level',3)
来源:https://stackoverflow.com/questions/20926118/get-last-level-category-name-of-a-product-in-magento