When i list my products on front page (from Default Category (Father of all other categories anchor is set YES)), when click in any product, the product page (product view) doesn't show the category of this product.

Category of product doesn't show in Breadcumb and URL My product is acessible via direct link, like this: mystore.com/product-name, when i see on list of category page, the url is mystore.com/category/product-name, i want force always show the category of this product.

Note: Magento

What i need do?


  • whats your magento version 1 or 2 Feb 17, 2017 at 11:41
  • @MurtuzaZabuawala Sorry, magento
    – Kauan
    Feb 17, 2017 at 11:42

2 Answers 2


In file app/code/core/Mage/Catalog/Helper/Data.php you will find getBreadcrumbPath() function in which they look for the Mage::registry('current_category')

public function getBreadcrumbPath()
        if (!$this->_categoryPath) {

            $path = array();
            if ($category = $this->getCategory()) {
                $pathInStore = $category->getPathInStore();
                $pathIds = array_reverse(explode(',', $pathInStore));

                $categories = $category->getParentCategories();

                // add category path breadcrumb
                foreach ($pathIds as $categoryId) {
                    if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                        $path['category'.$categoryId] = array(
                            'label' => $categories[$categoryId]->getName(),
                            'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getUrl() : ''

            if ($this->getProduct()) {
                $path['product'] = array('label'=>$this->getProduct()->getName());

            $this->_categoryPath = $path;
        return $this->_categoryPath;

in if condition

public function getCategory()
    return Mage::registry('current_category');

As you are going from the home page that time Mage::registry('current_category') is not set thats why category path is not getting display.

if your url is mystore.com/category/product-name then it will display breadcrumb

As you mentioned I want force always show the category of this product.

Solution :

You can set current_category before product page loads but Product can be from multiple categories.


create template file create the product list and set anchor by full product url.


Edit in core file app/code/core/Mage/Catalog/Helper/Data.php (not good practice and its abstract file)


Login adminPanel


system->configuration->catalog->catalog->Search Engine Optimizations

and set Use Categories Path for Product URLs to yes

Then clear cache and do reindex and check

  • It is already configured that way. The product displayed on the homepage when I click the URL on it is mystore.com/product-name, and yes i cleaned all caches..
    – Kauan
    Feb 17, 2017 at 11:49
  • @user1533106 provide code that you are using for product collection Feb 17, 2017 at 11:51
  • {{block type='catalog/product_list' category_id='2' grid_column_count='2' hide_toolbar='1' template='catalog/product/list.phtml'}} category_id=2 is "Default Category"
    – Kauan
    Feb 17, 2017 at 11:53
  • I want block direct acess like this: mystore.com/product-name, and force this: mystore.com/category/product-name
    – Kauan
    Feb 17, 2017 at 11:54
  • i guess i found the problem, on menu Catalog - Manage URL Rewrites, this have rules to rewrite like: category/product-name, and just product-name, need configure category anchor or anything like this? i want display all products on home page from default category...
    – Kauan
    Feb 17, 2017 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.