0

I'm using Magento EE 2.2.5

I need to get the product url of a product with its category path.

Presently, I'm using the code

$product_url = $product->getUrlInStore();

And also tried with

$product_url = $product->getProductUrl();

I'm getting like: www.domain.com/product_url_key

But I need to get it like: www.domain.com/category_level_1/category_level_2/product_url_key

So is there any default function to get that?

  • maybe this will help you – Hitesh Oct 25 '18 at 5:24
  • seems it's core error track here, but just try with above link maybe it will solve your issue – Hitesh Oct 25 '18 at 5:28
  • So is it like we have to build the url manually, we dont have any default function for that? – Harshith S Oct 25 '18 at 5:28
  • No, you don't need to write any function just follow this answer – Hitesh Oct 25 '18 at 5:30
  • In which page , you want to get? – Rohan Hapani Oct 25 '18 at 6:23
0

You can change in configuration for same and after making changes in configuration, please do the re-indexing.

Changes: go to Store -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> "Use Categories Path for Product URLs" set to "Yes"

  • I have added this and i want this complete product url in email template item listing href – Harshith S Oct 25 '18 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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