Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Retrieve first active category of product in Magento
// $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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment