Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@seansan
Created February 2, 2017 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seansan/1397a892fa496d5b5f98c2d85e4fa82e to your computer and use it in GitHub Desktop.
Save seansan/1397a892fa496d5b5f98c2d85e4fa82e to your computer and use it in GitHub Desktop.
$store_id = Mage::app()->getStore()->getId();
$rootId = Mage::app()->getStore($store_id)->getRootCategoryId();
$catCollection = $_product->getCategoryCollection()->addAttributeToSelect('name')->addUrlRewriteToResult()
->addIsActiveFilter()->addFieldToFilter('path', array('like'=> "1/$rootId/%"))->setOrder('id','ASC');
$cache = Mage::app()->getCache(); // [TODO] Cache the collection result not sure if this works
$cache->setLifetime(28800);
$catCollection->initCache($cache,'customcategoryfilter_', array('collections'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment