Add category path to breadcrumbs on product view pageHow to show catalog/product name , title above the breadcrumbs?Magento2 Get Category Id like breadcrumbs of Current ProductGetting different category id for the productsIs it possible for breadcrumbs to always display on a product page? Not just when navigated to through category layersFull breadcrumb in product listing pageDynamic Breadcrumbs on Product View with Full Page Cache EnabledHow to get Search result Product collection outside result.phtmlDisplay the Search Query Along With the BreadcrumbsDisplay breadcrumbs on a custom phtml pageHow to add breadcrumbs in my account pagesBreadcrumbs not working on Product Page Magento 2.2.4Magento2 Improper Breadcrumb On Product Detail PageMagento 2 breadcrumbs issue on product view page?

What can cause a never-frozen indoor copper drain pipe to crack?

How does Howard Stark know this?

Exception propagation: When to catch exceptions?

Can you book a one-way ticket to the UK on a visa?

How to deal with inappropriate comments during interviews for academic positions?

Can 'sudo apt-get remove [write]' destroy my Ubuntu?

Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?

How to make a language evolve quickly?

When do you stop "pushing" a book?

A musical commute to work

How to slow yourself down (for playing nice with others)

How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?

Guns in space with bullets that return?

How do car rear-view mirrors work?

Is Simic Ascendancy triggered by Awakening of Vitu-Ghazi?

International Code of Ethics for order of co-authors in research papers

Is it a bad idea to replace pull-up resistors with hard pull-ups?

Was there a contingency plan in place if Little Boy failed to detonate?

On studying Computer Science vs. Software Engineering to become a proficient coder

Why is it so slow when assigning a concatenated string to a variable in python?

What is the significance of 4200 BCE in context of farming replacing foraging in Europe?

What are the ramifications of setting ARITHABORT ON for all connections in SQL Server?

"Right on the tip of my tongue" meaning?

Is calcium chloride an acidic or basic salt?



Add category path to breadcrumbs on product view page


How to show catalog/product name , title above the breadcrumbs?Magento2 Get Category Id like breadcrumbs of Current ProductGetting different category id for the productsIs it possible for breadcrumbs to always display on a product page? Not just when navigated to through category layersFull breadcrumb in product listing pageDynamic Breadcrumbs on Product View with Full Page Cache EnabledHow to get Search result Product collection outside result.phtmlDisplay the Search Query Along With the BreadcrumbsDisplay breadcrumbs on a custom phtml pageHow to add breadcrumbs in my account pagesBreadcrumbs not working on Product Page Magento 2.2.4Magento2 Improper Breadcrumb On Product Detail PageMagento 2 breadcrumbs issue on product view page?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















By Default Manual Navigation Products breadcrumb looks like,



Wanted product detail page:



enter image description here




When I reached to product page using by search the breadcrumb looks like,



Current product detail page:



enter image description here



How can I get Complete Breadcrumb of the desired products even reached
by search?










share|improve this question






























    3















    By Default Manual Navigation Products breadcrumb looks like,



    Wanted product detail page:



    enter image description here




    When I reached to product page using by search the breadcrumb looks like,



    Current product detail page:



    enter image description here



    How can I get Complete Breadcrumb of the desired products even reached
    by search?










    share|improve this question


























      3












      3








      3


      3






      By Default Manual Navigation Products breadcrumb looks like,



      Wanted product detail page:



      enter image description here




      When I reached to product page using by search the breadcrumb looks like,



      Current product detail page:



      enter image description here



      How can I get Complete Breadcrumb of the desired products even reached
      by search?










      share|improve this question
















      By Default Manual Navigation Products breadcrumb looks like,



      Wanted product detail page:



      enter image description here




      When I reached to product page using by search the breadcrumb looks like,



      Current product detail page:



      enter image description here



      How can I get Complete Breadcrumb of the desired products even reached
      by search?







      magento-1.9 catalogsearch navigation product-page breadcrumbs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 26 '17 at 0:21









      sv3n

      10.1k62557




      10.1k62557










      asked Jun 9 '17 at 11:27







      user51361



























          4 Answers
          4






          active

          oldest

          votes


















          1





          +50









          You can try this one ... create an extension with this code:




          app/etc/modules/My_Module.xml




          <?xml version="1.0"?>
          <config>
          <modules>
          <My_Module>
          <active>true</active>
          <codePool>local</codePool>
          </My_Module>
          </modules>
          </config>



          app/code/local/My/Module/etc/config.xml




          <?xml version="1.0" encoding="UTF-8"?>
          <config>
          <modules>
          <My_Module>
          <version>0.0.1</version>
          </My_Module>
          </modules>
          <global>
          <models>
          <my_module>
          <class>My_Module_Model</class>
          </my_module>
          </models>
          </global>
          <frontend>
          <events>
          <catalog_controller_product_view>
          <observers>
          <add_category_to_breadcrumbs>
          <class>my_module/observer</class>
          <method>addCategoryToBreadcrumbs</method>
          </add_category_to_breadcrumbs>
          </observers>
          </catalog_controller_product_view>
          </events>
          </frontend>
          </config>



          app/code/local/My/Module/Model/Observer.php




          class My_Module_Model_Observer extends Mage_Core_Model_Observer

          public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)

          if (Mage::registry('current_category'))
          return;


          $product = $observer->getProduct();

          $product->setDoNotUseCategoryId(false);
          $categoryIds = $product->getCategoryIds();

          if (count($categoryIds))
          $categories = Mage::getModel('catalog/category')->getCollection()
          ->addAttributeToFilter('entity_id', $categoryIds)
          ->addAttributeToFilter('is_active', 1);

          $categories->getSelect()->order('level DESC')->limit(1);

          Mage::register('current_category', $categories->getFirstItem());








          share|improve this answer

























          • not working, getting the same error

            – user51361
            Jun 12 '17 at 12:30












          • Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

            – sv3n
            Jun 12 '17 at 13:48











          • I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

            – user51361
            Jun 13 '17 at 5:24











          • Its working good,,

            – user51361
            Jun 13 '17 at 7:31






          • 1





            Working fine. great work.

            – Chandra Bhushan
            Apr 22 at 6:26


















          0














          The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs



          enter image description here



          In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html






          share|improve this answer






























            0














            You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...



             if(empty($path)) 
            if ($this->getProduct())

            $collection = Mage::getModel('catalog/category')->getCollection()
            ->setStoreId(Mage::app()->getStore()->getId())
            ->addAttributeToSelect('name')
            ->addAttributeToSelect('is_active')
            ->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));

            $categories = array();
            $cate = false;
            foreach ($collection as $category)
            if($category->getId())
            $cate = $category;
            $pathInStore = $category->getPathInStore();
            $pathIds = array_reverse(explode(',', $pathInStore));


            if($cate)
            $categories = $cate->getParentCategories();
            if($categories)
            foreach($pathIds as $categoryId)
            $path['category'.$categoryId] = array(
            'label' => $categories[$categoryId]->getName(),
            'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
            );

            else
            $path['category'] = array('label' => $cate->getName());









            share|improve this answer






























              0














              Just a comment to the awesome answer of @sv3n.
              Let's assume we have this category structure




              root > category 1 > category 2 > category 3 > category 4


              A product of the category 4 can be listed in Category 1, 2, 3 or 4
              If the user clicks the product in the category 2 listing the breadcrumb will be




              root > category 1 > category 2 > product


              So if always the complete product breadcrumb path must be shown a change is needed




              if (Mage::registry('current_category'))
              return;



              for




              if (Mage::registry('current_category'))
              Mage::unregister('current_category');






              share|improve this answer








              New contributor



              rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.



















                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "479"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: false,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f178268%2fadd-category-path-to-breadcrumbs-on-product-view-page%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown
























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1





                +50









                You can try this one ... create an extension with this code:




                app/etc/modules/My_Module.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <My_Module>
                <active>true</active>
                <codePool>local</codePool>
                </My_Module>
                </modules>
                </config>



                app/code/local/My/Module/etc/config.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <config>
                <modules>
                <My_Module>
                <version>0.0.1</version>
                </My_Module>
                </modules>
                <global>
                <models>
                <my_module>
                <class>My_Module_Model</class>
                </my_module>
                </models>
                </global>
                <frontend>
                <events>
                <catalog_controller_product_view>
                <observers>
                <add_category_to_breadcrumbs>
                <class>my_module/observer</class>
                <method>addCategoryToBreadcrumbs</method>
                </add_category_to_breadcrumbs>
                </observers>
                </catalog_controller_product_view>
                </events>
                </frontend>
                </config>



                app/code/local/My/Module/Model/Observer.php




                class My_Module_Model_Observer extends Mage_Core_Model_Observer

                public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)

                if (Mage::registry('current_category'))
                return;


                $product = $observer->getProduct();

                $product->setDoNotUseCategoryId(false);
                $categoryIds = $product->getCategoryIds();

                if (count($categoryIds))
                $categories = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToFilter('entity_id', $categoryIds)
                ->addAttributeToFilter('is_active', 1);

                $categories->getSelect()->order('level DESC')->limit(1);

                Mage::register('current_category', $categories->getFirstItem());








                share|improve this answer

























                • not working, getting the same error

                  – user51361
                  Jun 12 '17 at 12:30












                • Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

                  – sv3n
                  Jun 12 '17 at 13:48











                • I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

                  – user51361
                  Jun 13 '17 at 5:24











                • Its working good,,

                  – user51361
                  Jun 13 '17 at 7:31






                • 1





                  Working fine. great work.

                  – Chandra Bhushan
                  Apr 22 at 6:26















                1





                +50









                You can try this one ... create an extension with this code:




                app/etc/modules/My_Module.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <My_Module>
                <active>true</active>
                <codePool>local</codePool>
                </My_Module>
                </modules>
                </config>



                app/code/local/My/Module/etc/config.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <config>
                <modules>
                <My_Module>
                <version>0.0.1</version>
                </My_Module>
                </modules>
                <global>
                <models>
                <my_module>
                <class>My_Module_Model</class>
                </my_module>
                </models>
                </global>
                <frontend>
                <events>
                <catalog_controller_product_view>
                <observers>
                <add_category_to_breadcrumbs>
                <class>my_module/observer</class>
                <method>addCategoryToBreadcrumbs</method>
                </add_category_to_breadcrumbs>
                </observers>
                </catalog_controller_product_view>
                </events>
                </frontend>
                </config>



                app/code/local/My/Module/Model/Observer.php




                class My_Module_Model_Observer extends Mage_Core_Model_Observer

                public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)

                if (Mage::registry('current_category'))
                return;


                $product = $observer->getProduct();

                $product->setDoNotUseCategoryId(false);
                $categoryIds = $product->getCategoryIds();

                if (count($categoryIds))
                $categories = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToFilter('entity_id', $categoryIds)
                ->addAttributeToFilter('is_active', 1);

                $categories->getSelect()->order('level DESC')->limit(1);

                Mage::register('current_category', $categories->getFirstItem());








                share|improve this answer

























                • not working, getting the same error

                  – user51361
                  Jun 12 '17 at 12:30












                • Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

                  – sv3n
                  Jun 12 '17 at 13:48











                • I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

                  – user51361
                  Jun 13 '17 at 5:24











                • Its working good,,

                  – user51361
                  Jun 13 '17 at 7:31






                • 1





                  Working fine. great work.

                  – Chandra Bhushan
                  Apr 22 at 6:26













                1





                +50







                1





                +50



                1




                +50





                You can try this one ... create an extension with this code:




                app/etc/modules/My_Module.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <My_Module>
                <active>true</active>
                <codePool>local</codePool>
                </My_Module>
                </modules>
                </config>



                app/code/local/My/Module/etc/config.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <config>
                <modules>
                <My_Module>
                <version>0.0.1</version>
                </My_Module>
                </modules>
                <global>
                <models>
                <my_module>
                <class>My_Module_Model</class>
                </my_module>
                </models>
                </global>
                <frontend>
                <events>
                <catalog_controller_product_view>
                <observers>
                <add_category_to_breadcrumbs>
                <class>my_module/observer</class>
                <method>addCategoryToBreadcrumbs</method>
                </add_category_to_breadcrumbs>
                </observers>
                </catalog_controller_product_view>
                </events>
                </frontend>
                </config>



                app/code/local/My/Module/Model/Observer.php




                class My_Module_Model_Observer extends Mage_Core_Model_Observer

                public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)

                if (Mage::registry('current_category'))
                return;


                $product = $observer->getProduct();

                $product->setDoNotUseCategoryId(false);
                $categoryIds = $product->getCategoryIds();

                if (count($categoryIds))
                $categories = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToFilter('entity_id', $categoryIds)
                ->addAttributeToFilter('is_active', 1);

                $categories->getSelect()->order('level DESC')->limit(1);

                Mage::register('current_category', $categories->getFirstItem());








                share|improve this answer















                You can try this one ... create an extension with this code:




                app/etc/modules/My_Module.xml




                <?xml version="1.0"?>
                <config>
                <modules>
                <My_Module>
                <active>true</active>
                <codePool>local</codePool>
                </My_Module>
                </modules>
                </config>



                app/code/local/My/Module/etc/config.xml




                <?xml version="1.0" encoding="UTF-8"?>
                <config>
                <modules>
                <My_Module>
                <version>0.0.1</version>
                </My_Module>
                </modules>
                <global>
                <models>
                <my_module>
                <class>My_Module_Model</class>
                </my_module>
                </models>
                </global>
                <frontend>
                <events>
                <catalog_controller_product_view>
                <observers>
                <add_category_to_breadcrumbs>
                <class>my_module/observer</class>
                <method>addCategoryToBreadcrumbs</method>
                </add_category_to_breadcrumbs>
                </observers>
                </catalog_controller_product_view>
                </events>
                </frontend>
                </config>



                app/code/local/My/Module/Model/Observer.php




                class My_Module_Model_Observer extends Mage_Core_Model_Observer

                public function addCategoryToBreadcrumbs(Varien_Event_Observer $observer)

                if (Mage::registry('current_category'))
                return;


                $product = $observer->getProduct();

                $product->setDoNotUseCategoryId(false);
                $categoryIds = $product->getCategoryIds();

                if (count($categoryIds))
                $categories = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToFilter('entity_id', $categoryIds)
                ->addAttributeToFilter('is_active', 1);

                $categories->getSelect()->order('level DESC')->limit(1);

                Mage::register('current_category', $categories->getFirstItem());









                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jun 12 '17 at 13:46

























                answered Jun 12 '17 at 11:49









                sv3nsv3n

                10.1k62557




                10.1k62557












                • not working, getting the same error

                  – user51361
                  Jun 12 '17 at 12:30












                • Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

                  – sv3n
                  Jun 12 '17 at 13:48











                • I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

                  – user51361
                  Jun 13 '17 at 5:24











                • Its working good,,

                  – user51361
                  Jun 13 '17 at 7:31






                • 1





                  Working fine. great work.

                  – Chandra Bhushan
                  Apr 22 at 6:26

















                • not working, getting the same error

                  – user51361
                  Jun 12 '17 at 12:30












                • Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

                  – sv3n
                  Jun 12 '17 at 13:48











                • I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

                  – user51361
                  Jun 13 '17 at 5:24











                • Its working good,,

                  – user51361
                  Jun 13 '17 at 7:31






                • 1





                  Working fine. great work.

                  – Chandra Bhushan
                  Apr 22 at 6:26
















                not working, getting the same error

                – user51361
                Jun 12 '17 at 12:30






                not working, getting the same error

                – user51361
                Jun 12 '17 at 12:30














                Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

                – sv3n
                Jun 12 '17 at 13:48





                Please flush the cache and check if extension is loaded (add Mage::log('loaded', null, 'test.log', true) to addCategoryToBreadcrumbs before if (Mage::registry('current_category'))

                – sv3n
                Jun 12 '17 at 13:48













                I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

                – user51361
                Jun 13 '17 at 5:24





                I did exactly what you said, again not working, could you pls join chat chat.stackexchange.com/rooms/60356/…

                – user51361
                Jun 13 '17 at 5:24













                Its working good,,

                – user51361
                Jun 13 '17 at 7:31





                Its working good,,

                – user51361
                Jun 13 '17 at 7:31




                1




                1





                Working fine. great work.

                – Chandra Bhushan
                Apr 22 at 6:26





                Working fine. great work.

                – Chandra Bhushan
                Apr 22 at 6:26













                0














                The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs



                enter image description here



                In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html






                share|improve this answer



























                  0














                  The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs



                  enter image description here



                  In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html






                  share|improve this answer

























                    0












                    0








                    0







                    The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs



                    enter image description here



                    In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html






                    share|improve this answer













                    The easiest way is to include category URL Keys into your product URLs. The is a special setting in Magento to do this in System > Configuration > Catalog > Search Engine Optimization > Use Categories Path for Product URLs



                    enter image description here



                    In case this way is not ok for you, you can use a ready solution like this one: https://www.magestyapps.com/magento-extensions/advanced-breadcrumbs.html







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 13 '17 at 15:26









                    MagestyAppsMagestyApps

                    34613




                    34613





















                        0














                        You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...



                         if(empty($path)) 
                        if ($this->getProduct())

                        $collection = Mage::getModel('catalog/category')->getCollection()
                        ->setStoreId(Mage::app()->getStore()->getId())
                        ->addAttributeToSelect('name')
                        ->addAttributeToSelect('is_active')
                        ->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));

                        $categories = array();
                        $cate = false;
                        foreach ($collection as $category)
                        if($category->getId())
                        $cate = $category;
                        $pathInStore = $category->getPathInStore();
                        $pathIds = array_reverse(explode(',', $pathInStore));


                        if($cate)
                        $categories = $cate->getParentCategories();
                        if($categories)
                        foreach($pathIds as $categoryId)
                        $path['category'.$categoryId] = array(
                        'label' => $categories[$categoryId]->getName(),
                        'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
                        );

                        else
                        $path['category'] = array('label' => $cate->getName());









                        share|improve this answer



























                          0














                          You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...



                           if(empty($path)) 
                          if ($this->getProduct())

                          $collection = Mage::getModel('catalog/category')->getCollection()
                          ->setStoreId(Mage::app()->getStore()->getId())
                          ->addAttributeToSelect('name')
                          ->addAttributeToSelect('is_active')
                          ->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));

                          $categories = array();
                          $cate = false;
                          foreach ($collection as $category)
                          if($category->getId())
                          $cate = $category;
                          $pathInStore = $category->getPathInStore();
                          $pathIds = array_reverse(explode(',', $pathInStore));


                          if($cate)
                          $categories = $cate->getParentCategories();
                          if($categories)
                          foreach($pathIds as $categoryId)
                          $path['category'.$categoryId] = array(
                          'label' => $categories[$categoryId]->getName(),
                          'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
                          );

                          else
                          $path['category'] = array('label' => $cate->getName());









                          share|improve this answer

























                            0












                            0








                            0







                            You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...



                             if(empty($path)) 
                            if ($this->getProduct())

                            $collection = Mage::getModel('catalog/category')->getCollection()
                            ->setStoreId(Mage::app()->getStore()->getId())
                            ->addAttributeToSelect('name')
                            ->addAttributeToSelect('is_active')
                            ->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));

                            $categories = array();
                            $cate = false;
                            foreach ($collection as $category)
                            if($category->getId())
                            $cate = $category;
                            $pathInStore = $category->getPathInStore();
                            $pathIds = array_reverse(explode(',', $pathInStore));


                            if($cate)
                            $categories = $cate->getParentCategories();
                            if($categories)
                            foreach($pathIds as $categoryId)
                            $path['category'.$categoryId] = array(
                            'label' => $categories[$categoryId]->getName(),
                            'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
                            );

                            else
                            $path['category'] = array('label' => $cate->getName());









                            share|improve this answer













                            You can add this to magento/app/code/core/Mage/Catalog/Helper/Data.php after if ($category = $this->getCategory()) ...



                             if(empty($path)) 
                            if ($this->getProduct())

                            $collection = Mage::getModel('catalog/category')->getCollection()
                            ->setStoreId(Mage::app()->getStore()->getId())
                            ->addAttributeToSelect('name')
                            ->addAttributeToSelect('is_active')
                            ->addFieldToFilter('entity_id', array('in' => $this->getProduct()->getCategoryIds()));

                            $categories = array();
                            $cate = false;
                            foreach ($collection as $category)
                            if($category->getId())
                            $cate = $category;
                            $pathInStore = $category->getPathInStore();
                            $pathIds = array_reverse(explode(',', $pathInStore));


                            if($cate)
                            $categories = $cate->getParentCategories();
                            if($categories)
                            foreach($pathIds as $categoryId)
                            $path['category'.$categoryId] = array(
                            'label' => $categories[$categoryId]->getName(),
                            'link' => $this->_isCategoryLink($categoryId) ? $categories[$categoryId]->getURL() : ''
                            );

                            else
                            $path['category'] = array('label' => $cate->getName());










                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 30 '18 at 14:04









                            LipaLipa

                            11




                            11





















                                0














                                Just a comment to the awesome answer of @sv3n.
                                Let's assume we have this category structure




                                root > category 1 > category 2 > category 3 > category 4


                                A product of the category 4 can be listed in Category 1, 2, 3 or 4
                                If the user clicks the product in the category 2 listing the breadcrumb will be




                                root > category 1 > category 2 > product


                                So if always the complete product breadcrumb path must be shown a change is needed




                                if (Mage::registry('current_category'))
                                return;



                                for




                                if (Mage::registry('current_category'))
                                Mage::unregister('current_category');






                                share|improve this answer








                                New contributor



                                rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.























                                  0














                                  Just a comment to the awesome answer of @sv3n.
                                  Let's assume we have this category structure




                                  root > category 1 > category 2 > category 3 > category 4


                                  A product of the category 4 can be listed in Category 1, 2, 3 or 4
                                  If the user clicks the product in the category 2 listing the breadcrumb will be




                                  root > category 1 > category 2 > product


                                  So if always the complete product breadcrumb path must be shown a change is needed




                                  if (Mage::registry('current_category'))
                                  return;



                                  for




                                  if (Mage::registry('current_category'))
                                  Mage::unregister('current_category');






                                  share|improve this answer








                                  New contributor



                                  rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.





















                                    0












                                    0








                                    0







                                    Just a comment to the awesome answer of @sv3n.
                                    Let's assume we have this category structure




                                    root > category 1 > category 2 > category 3 > category 4


                                    A product of the category 4 can be listed in Category 1, 2, 3 or 4
                                    If the user clicks the product in the category 2 listing the breadcrumb will be




                                    root > category 1 > category 2 > product


                                    So if always the complete product breadcrumb path must be shown a change is needed




                                    if (Mage::registry('current_category'))
                                    return;



                                    for




                                    if (Mage::registry('current_category'))
                                    Mage::unregister('current_category');






                                    share|improve this answer








                                    New contributor



                                    rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    Just a comment to the awesome answer of @sv3n.
                                    Let's assume we have this category structure




                                    root > category 1 > category 2 > category 3 > category 4


                                    A product of the category 4 can be listed in Category 1, 2, 3 or 4
                                    If the user clicks the product in the category 2 listing the breadcrumb will be




                                    root > category 1 > category 2 > product


                                    So if always the complete product breadcrumb path must be shown a change is needed




                                    if (Mage::registry('current_category'))
                                    return;



                                    for




                                    if (Mage::registry('current_category'))
                                    Mage::unregister('current_category');







                                    share|improve this answer








                                    New contributor



                                    rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.








                                    share|improve this answer



                                    share|improve this answer






                                    New contributor



                                    rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.








                                    answered May 7 at 16:29









                                    rekobekorekobeko

                                    1




                                    1




                                    New contributor



                                    rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.




                                    New contributor




                                    rekobeko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.





























                                        draft saved

                                        draft discarded
















































                                        Thanks for contributing an answer to Magento Stack Exchange!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid


                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.

                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f178268%2fadd-category-path-to-breadcrumbs-on-product-view-page%23new-answer', 'question_page');

                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                                        Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                                        Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?