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;
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
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
|
show 2 more comments
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
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
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
|
show 2 more comments
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
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
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
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
magento2 category
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
|
show 2 more comments
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
|
show 2 more comments
2 Answers
2
active
oldest
votes
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
New contributor
,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
add a comment |
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
New contributor
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
New contributor
,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
add a comment |
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
New contributor
,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
add a comment |
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
New contributor
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
New contributor
edited Apr 24 at 5:46
New contributor
answered Apr 24 at 5:36
rinzlerrinzler
216
216
New contributor
New contributor
,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
add a comment |
,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
add a comment |
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
New contributor
edited 2 days ago
New contributor
answered Apr 24 at 13:00
rinzlerrinzler
216
216
New contributor
New contributor
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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