If you use the function getParentCategories()
then it called the function
load() which is taken more load time.
See:
$pathIds = array_reverse(explode(',', $category->getPathInStore()));
$categories = Mage::getResourceModel('catalog/category_collection')
->setStore(Mage::app()->getStore())
->addAttributeToSelect('name')
->addAttributeToSelect('url_key')
->addFieldToFilter('entity_id', array('in' => $pathIds))
->addFieldToFilter('is_active', 1)
->load()
->getItems();
Then it will better to call Custom Category collection
and doesnot use collection load function
.
$category = Mage::getModel('catalog/category')->load($id);
$catnames=array();
$pathIds = array_reverse(explode(',', $category->getPathInStore()));
$Categories = Mage::getResourceModel('catalog/category_collection')
->setStore(Mage::app()->getStore())
->addAttributeToSelect('name')
->addFieldToFilter('entity_id', array('in' => $pathIds))
->addFieldToFilter('is_active', 1);
foreach ($Categories as $Eachparent) {
$catnames[] = $Eachparent>getName();
}