Its a uncommon issue that i face while getting the product category in product detail page.
My code is working fine in staging and not working in live.
I used below code to get the current category.
if (Mage::registry('current_category'))
{
// Category Name
$current_category = Mage::registry('current_category')->getName();
// Category ID
$category_id = Mage::registry('current_category')->getId();
// Catergory Url
$url = Mage::getModel("catalog/category")->load($category_id)->getUrl();
}
This code is working fine in staging not in live.
I tried this approach also(Method 2)
$categoryIds = $_product->getCategoryIds();
foreach($categoryIds as $categoryId) {
$category = Mage::getModel('catalog/category')->load($categoryId);
$categorynm = $category->getName();
$url = $category->getUrl();
}
Using this method also i am unable to get the category url in live. Please help me to find this issue.its totally uncommon scenario works in staging and not working in live.
I tried several method from stack exchange questions but i am unable to fix this issue.