Last active
January 2, 2016 13:09
-
-
Save willboudle/8307653 to your computer and use it in GitHub Desktop.
Magento get category from product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //$_product = Mage::getModel('catalog/product')->load($productID); | |
| ----------------------------------- | |
| $catCollection = $_product->getCategoryCollection(); | |
| foreach($catCollection as $cat){ | |
| print_r($cat->getData()); | |
| //echo $cat->getName(); | |
| //echo $cat->getUrl(); | |
| } | |
| ----------------------------------- | |
| $catIds = $_product->getCategoryIds(); | |
| $catCollection = Mage::getResourceModel('catalog/category_collection') | |
| //->addAttributeToSelect('name') | |
| //->addAttributeToSelect('url') | |
| ->addAttributeToSelect('*') | |
| ->addAttributeToFilter('entity_id', $catIds) | |
| ->addIsActiveFilter(); | |
| foreach($catCollection as $cat){ | |
| print_r($cat->getData()); | |
| //echo $cat->getName(); | |
| //echo $cat->getUrl(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment