Created
May 20, 2014 17:25
-
-
Save herveguetin/217fcc05a03d2aef9dd5 to your computer and use it in GitHub Desktop.
Retrieve first active category of product in Magento
This file contains 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
<?php | |
// $product must be an instance of Mage_Catalog_Model_Product | |
$productCategoryIds = $product->getCategoryIds(); | |
$productCategory = Mage::getModel('catalog/category')->getCollection() | |
->addAttributeToFilter('is_active', true) | |
->addAttributeToFilter('entity_id', array('in' => $productCategoryIds)) | |
->setPageSize(1) | |
->getFirstItem(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment