I have a Product in my Magento shop. It is in Category C.
My architecure is Category A > Category B > Category C.
With my code below, this displays Category B when on the Product page. How would I adapt the code below to display Category A instead?
if(Mage::registry('current_product')) {
$_category = Mage::registry('current_category');
$parentCategoryId = $_category->getParentId();
$parentCategory = Mage::getModel('catalog/category')->load($parentCategoryId);
$url = strtolower(str_replace(" ","-",$parentCategory->name));
echo '<a href="/'.$url.'">'.$parentCategory->name.'</a>';
}
I had thought of maybe using the number of '/' in the URL to change my code.
Many thanks for any pointers with this.