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?

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

1 Answer 1

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"

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

Your Answer

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

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