Magento 2 Get Full Category Path for productHow to get product url with category key on home pageRedirect product url with category pathFull width template for end level categoryMagento full product path not workingMagento 2 - Get a level descending category collection for path to product for breadcrumbsBuilding multi stores with multi domains but get 500Magento 2 : get full file path of full size image currently assigned to productMagento 2 Product Custom Option ImagesMagento 2 get cached url full path of custom attributeMagento 2 How to hide price from front end with custom module?SEO category path

Is there a way to get a compiler for the original B programming language?

Why don't other Westeros houses use wildfire?

Pass By Reference VS Pass by Value

What are the potential pitfalls when using metals as a currency?

How to type a section sign (§) into the Minecraft client

Please, smoke with good manners

The Defining Moment

How to verbalise code in Mathematica?

What do the phrase "Reeyan's seacrest" and the word "fraggle" mean in a sketch?

Why do games have consumables?

How can I practically buy stocks?

What is the difference between `command a[bc]d` and `command `ab,cd`

What language was spoken in East Asia before Proto-Turkic?

How to get a plain text file version of a CP/M .BAS (M-BASIC) program?

How did Captain America manage to do this?

How do I use proper grammar in the negation of "have not" for the following sentence translation?

Is there any limitation with Arduino Nano serial communication distance?

What makes accurate emulation of old systems a difficult task?

Fizzy, soft, pop and still drinks

Shrinkwrap tetris shapes without scaling or diagonal shapes

How to have a sharp product image?

Mac Pro install disk keeps ejecting itself

Contradiction proof for inequality of P and NP?

How to make a pipeline wait for end-of-file or stop after an error?



Magento 2 Get Full Category Path for product


How to get product url with category key on home pageRedirect product url with category pathFull width template for end level categoryMagento full product path not workingMagento 2 - Get a level descending category collection for path to product for breadcrumbsBuilding multi stores with multi domains but get 500Magento 2 : get full file path of full size image currently assigned to productMagento 2 Product Custom Option ImagesMagento 2 get cached url full path of custom attributeMagento 2 How to hide price from front end with custom module?SEO category path






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








5















How to get full category path in Magento 2?



For example




Home > Women > Dresses > Maxi Dresses




I am developing script for Google Shopping Feed and there is a node product_type which is require product category in above format



enter image description here



This node should be in below format:



<g:product_type><![CDATA[Home > Women > Dresses > Maxi Dresses]]></g:product_type>


I have searched on forum but didn't found any solution for Magento 2.



If anyone any idea then please share me.










share|improve this question
























  • mageplaza.com/devdocs/… This will help you.

    – Aaditya
    Apr 24 at 4:44











  • Check this if it can help you to get an idea: magento.stackexchange.com/questions/158709/…

    – Ajju
    Apr 24 at 4:46











  • Do you want category names path in request url of product ?

    – Aaditya
    Apr 24 at 16:24











  • @Aaditya,please check updated answer.

    – akgola
    Apr 25 at 4:36











  • Hello @akgola I got your concern product_type is optional in Google Shopping Feed

    – Aaditya
    Apr 25 at 4:43

















5















How to get full category path in Magento 2?



For example




Home > Women > Dresses > Maxi Dresses




I am developing script for Google Shopping Feed and there is a node product_type which is require product category in above format



enter image description here



This node should be in below format:



<g:product_type><![CDATA[Home > Women > Dresses > Maxi Dresses]]></g:product_type>


I have searched on forum but didn't found any solution for Magento 2.



If anyone any idea then please share me.










share|improve this question
























  • mageplaza.com/devdocs/… This will help you.

    – Aaditya
    Apr 24 at 4:44











  • Check this if it can help you to get an idea: magento.stackexchange.com/questions/158709/…

    – Ajju
    Apr 24 at 4:46











  • Do you want category names path in request url of product ?

    – Aaditya
    Apr 24 at 16:24











  • @Aaditya,please check updated answer.

    – akgola
    Apr 25 at 4:36











  • Hello @akgola I got your concern product_type is optional in Google Shopping Feed

    – Aaditya
    Apr 25 at 4:43













5












5








5








How to get full category path in Magento 2?



For example




Home > Women > Dresses > Maxi Dresses




I am developing script for Google Shopping Feed and there is a node product_type which is require product category in above format



enter image description here



This node should be in below format:



<g:product_type><![CDATA[Home > Women > Dresses > Maxi Dresses]]></g:product_type>


I have searched on forum but didn't found any solution for Magento 2.



If anyone any idea then please share me.










share|improve this question
















How to get full category path in Magento 2?



For example




Home > Women > Dresses > Maxi Dresses




I am developing script for Google Shopping Feed and there is a node product_type which is require product category in above format



enter image description here



This node should be in below format:



<g:product_type><![CDATA[Home > Women > Dresses > Maxi Dresses]]></g:product_type>


I have searched on forum but didn't found any solution for Magento 2.



If anyone any idea then please share me.







magento2 category






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 25 at 4:33







akgola

















asked Apr 24 at 4:25









akgolaakgola

1,487520




1,487520












  • mageplaza.com/devdocs/… This will help you.

    – Aaditya
    Apr 24 at 4:44











  • Check this if it can help you to get an idea: magento.stackexchange.com/questions/158709/…

    – Ajju
    Apr 24 at 4:46











  • Do you want category names path in request url of product ?

    – Aaditya
    Apr 24 at 16:24











  • @Aaditya,please check updated answer.

    – akgola
    Apr 25 at 4:36











  • Hello @akgola I got your concern product_type is optional in Google Shopping Feed

    – Aaditya
    Apr 25 at 4:43

















  • mageplaza.com/devdocs/… This will help you.

    – Aaditya
    Apr 24 at 4:44











  • Check this if it can help you to get an idea: magento.stackexchange.com/questions/158709/…

    – Ajju
    Apr 24 at 4:46











  • Do you want category names path in request url of product ?

    – Aaditya
    Apr 24 at 16:24











  • @Aaditya,please check updated answer.

    – akgola
    Apr 25 at 4:36











  • Hello @akgola I got your concern product_type is optional in Google Shopping Feed

    – Aaditya
    Apr 25 at 4:43
















mageplaza.com/devdocs/… This will help you.

– Aaditya
Apr 24 at 4:44





mageplaza.com/devdocs/… This will help you.

– Aaditya
Apr 24 at 4:44













Check this if it can help you to get an idea: magento.stackexchange.com/questions/158709/…

– Ajju
Apr 24 at 4:46





Check this if it can help you to get an idea: magento.stackexchange.com/questions/158709/…

– Ajju
Apr 24 at 4:46













Do you want category names path in request url of product ?

– Aaditya
Apr 24 at 16:24





Do you want category names path in request url of product ?

– Aaditya
Apr 24 at 16:24













@Aaditya,please check updated answer.

– akgola
Apr 25 at 4:36





@Aaditya,please check updated answer.

– akgola
Apr 25 at 4:36













Hello @akgola I got your concern product_type is optional in Google Shopping Feed

– Aaditya
Apr 25 at 4:43





Hello @akgola I got your concern product_type is optional in Google Shopping Feed

– Aaditya
Apr 25 at 4:43










2 Answers
2






active

oldest

votes


















1














Try this



public function __construct(
MagentoFrameworkRegistry $registry,
MagentoCatalogApiCategoryRepositoryInterface $categoryRepository,
MagentoStoreModelStoreManagerInterface $storeManager

)
$this->storeManager = $storeManager;
$this->registry = $registry;
$this->categoryRepository = $categoryRepository;


public function yourfunctionname()
$categoryIds = $product->getCategoryIds();
if (!$categoryIds)
return null;

$category = $this->categoryRepository->get($categoryIds[0], $this->storeManager->getStore()->getId());
$this->registry->register('current_category',$category);
$redirectionUrl = $product->getProductUrl();



the __construct contain the dependencies injection you needed to load model and yourfunctionname have the code to get url using the current product page category to get category url






share|improve this answer










New contributor




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




















  • ,this is returning only url of product ,not full path.

    – akgola
    Apr 24 at 6:57











  • @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

    – rinzler
    Apr 24 at 7:52












  • this will generate url like www.example.com/category/product.html

    – rinzler
    Apr 24 at 7:54











  • ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

    – akgola
    Apr 24 at 10:11











  • i added new solution @akgola .please check it

    – rinzler
    Apr 24 at 13:01



















0














sample



here a image where i put path below add to cart button just adding below code in addtocart.phtml in



app/code/vendor_name/extension_Name/view/frontend/templates/product/view/addtocart.phtml


<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>


add this to any phtml file you will get the path you wanted



hope this helps you






share|improve this answer










New contributor




rinzler 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%2f272161%2fmagento-2-get-full-category-path-for-product%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Try this



    public function __construct(
    MagentoFrameworkRegistry $registry,
    MagentoCatalogApiCategoryRepositoryInterface $categoryRepository,
    MagentoStoreModelStoreManagerInterface $storeManager

    )
    $this->storeManager = $storeManager;
    $this->registry = $registry;
    $this->categoryRepository = $categoryRepository;


    public function yourfunctionname()
    $categoryIds = $product->getCategoryIds();
    if (!$categoryIds)
    return null;

    $category = $this->categoryRepository->get($categoryIds[0], $this->storeManager->getStore()->getId());
    $this->registry->register('current_category',$category);
    $redirectionUrl = $product->getProductUrl();



    the __construct contain the dependencies injection you needed to load model and yourfunctionname have the code to get url using the current product page category to get category url






    share|improve this answer










    New contributor




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




















    • ,this is returning only url of product ,not full path.

      – akgola
      Apr 24 at 6:57











    • @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

      – rinzler
      Apr 24 at 7:52












    • this will generate url like www.example.com/category/product.html

      – rinzler
      Apr 24 at 7:54











    • ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

      – akgola
      Apr 24 at 10:11











    • i added new solution @akgola .please check it

      – rinzler
      Apr 24 at 13:01
















    1














    Try this



    public function __construct(
    MagentoFrameworkRegistry $registry,
    MagentoCatalogApiCategoryRepositoryInterface $categoryRepository,
    MagentoStoreModelStoreManagerInterface $storeManager

    )
    $this->storeManager = $storeManager;
    $this->registry = $registry;
    $this->categoryRepository = $categoryRepository;


    public function yourfunctionname()
    $categoryIds = $product->getCategoryIds();
    if (!$categoryIds)
    return null;

    $category = $this->categoryRepository->get($categoryIds[0], $this->storeManager->getStore()->getId());
    $this->registry->register('current_category',$category);
    $redirectionUrl = $product->getProductUrl();



    the __construct contain the dependencies injection you needed to load model and yourfunctionname have the code to get url using the current product page category to get category url






    share|improve this answer










    New contributor




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




















    • ,this is returning only url of product ,not full path.

      – akgola
      Apr 24 at 6:57











    • @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

      – rinzler
      Apr 24 at 7:52












    • this will generate url like www.example.com/category/product.html

      – rinzler
      Apr 24 at 7:54











    • ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

      – akgola
      Apr 24 at 10:11











    • i added new solution @akgola .please check it

      – rinzler
      Apr 24 at 13:01














    1












    1








    1







    Try this



    public function __construct(
    MagentoFrameworkRegistry $registry,
    MagentoCatalogApiCategoryRepositoryInterface $categoryRepository,
    MagentoStoreModelStoreManagerInterface $storeManager

    )
    $this->storeManager = $storeManager;
    $this->registry = $registry;
    $this->categoryRepository = $categoryRepository;


    public function yourfunctionname()
    $categoryIds = $product->getCategoryIds();
    if (!$categoryIds)
    return null;

    $category = $this->categoryRepository->get($categoryIds[0], $this->storeManager->getStore()->getId());
    $this->registry->register('current_category',$category);
    $redirectionUrl = $product->getProductUrl();



    the __construct contain the dependencies injection you needed to load model and yourfunctionname have the code to get url using the current product page category to get category url






    share|improve this answer










    New contributor




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










    Try this



    public function __construct(
    MagentoFrameworkRegistry $registry,
    MagentoCatalogApiCategoryRepositoryInterface $categoryRepository,
    MagentoStoreModelStoreManagerInterface $storeManager

    )
    $this->storeManager = $storeManager;
    $this->registry = $registry;
    $this->categoryRepository = $categoryRepository;


    public function yourfunctionname()
    $categoryIds = $product->getCategoryIds();
    if (!$categoryIds)
    return null;

    $category = $this->categoryRepository->get($categoryIds[0], $this->storeManager->getStore()->getId());
    $this->registry->register('current_category',$category);
    $redirectionUrl = $product->getProductUrl();



    the __construct contain the dependencies injection you needed to load model and yourfunctionname have the code to get url using the current product page category to get category url







    share|improve this answer










    New contributor




    rinzler 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








    edited Apr 24 at 5:46





















    New contributor




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









    answered Apr 24 at 5:36









    rinzlerrinzler

    216




    216




    New contributor




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





    New contributor





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






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












    • ,this is returning only url of product ,not full path.

      – akgola
      Apr 24 at 6:57











    • @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

      – rinzler
      Apr 24 at 7:52












    • this will generate url like www.example.com/category/product.html

      – rinzler
      Apr 24 at 7:54











    • ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

      – akgola
      Apr 24 at 10:11











    • i added new solution @akgola .please check it

      – rinzler
      Apr 24 at 13:01


















    • ,this is returning only url of product ,not full path.

      – akgola
      Apr 24 at 6:57











    • @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

      – rinzler
      Apr 24 at 7:52












    • this will generate url like www.example.com/category/product.html

      – rinzler
      Apr 24 at 7:54











    • ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

      – akgola
      Apr 24 at 10:11











    • i added new solution @akgola .please check it

      – rinzler
      Apr 24 at 13:01

















    ,this is returning only url of product ,not full path.

    – akgola
    Apr 24 at 6:57





    ,this is returning only url of product ,not full path.

    – akgola
    Apr 24 at 6:57













    @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

    – rinzler
    Apr 24 at 7:52






    @akgola what you mean by path .You can't get the path of the product page as html is generated from the magento's structure dynamically

    – rinzler
    Apr 24 at 7:52














    this will generate url like www.example.com/category/product.html

    – rinzler
    Apr 24 at 7:54





    this will generate url like www.example.com/category/product.html

    – rinzler
    Apr 24 at 7:54













    ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

    – akgola
    Apr 24 at 10:11





    ,I mean in format Home > Women > Dresses > Maxi Dresses not url format.

    – akgola
    Apr 24 at 10:11













    i added new solution @akgola .please check it

    – rinzler
    Apr 24 at 13:01






    i added new solution @akgola .please check it

    – rinzler
    Apr 24 at 13:01














    0














    sample



    here a image where i put path below add to cart button just adding below code in addtocart.phtml in



    app/code/vendor_name/extension_Name/view/frontend/templates/product/view/addtocart.phtml


    <?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>


    add this to any phtml file you will get the path you wanted



    hope this helps you






    share|improve this answer










    New contributor




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
























      0














      sample



      here a image where i put path below add to cart button just adding below code in addtocart.phtml in



      app/code/vendor_name/extension_Name/view/frontend/templates/product/view/addtocart.phtml


      <?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>


      add this to any phtml file you will get the path you wanted



      hope this helps you






      share|improve this answer










      New contributor




      rinzler 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







        sample



        here a image where i put path below add to cart button just adding below code in addtocart.phtml in



        app/code/vendor_name/extension_Name/view/frontend/templates/product/view/addtocart.phtml


        <?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>


        add this to any phtml file you will get the path you wanted



        hope this helps you






        share|improve this answer










        New contributor




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










        sample



        here a image where i put path below add to cart button just adding below code in addtocart.phtml in



        app/code/vendor_name/extension_Name/view/frontend/templates/product/view/addtocart.phtml


        <?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>


        add this to any phtml file you will get the path you wanted



        hope this helps you







        share|improve this answer










        New contributor




        rinzler 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








        edited 2 days ago





















        New contributor




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









        answered Apr 24 at 13:00









        rinzlerrinzler

        216




        216




        New contributor




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





        New contributor





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






        rinzler 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%2f272161%2fmagento-2-get-full-category-path-for-product%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

            Sum ergo cogito? 1 nng

            419 nièngy_Soadمي 19bal1.5o_g

            Queiggey Chernihivv 9NnOo i Zw X QqKk LpB