0

I would like to app prefix like my-product to the view product, for example using magento 2 sample product we can view one of the product using this link :

http://localhost:8000/desiree-fitness-tee.html

I would like to add my-product before desiree so it becomes :

http://localhost:8000/my-product/desiree-fitness-tee.html

I can do the hack way to achieve this, like change the request_path column in the table url_rewrite. But I'm pretty sure this is not the right way to do it.

So what I want to do is finding the module that generate all this url for products and categories, so I can add a prefix to that url before magento 2 render or showing the page.

Where can I find the module that handle this ?

0

The Module that displaying or getting the url you can find it on :

  • vendor/magento/module-catalog/Model/Product.php
  • vendor/magento/module-catalog/Model/Category.php

Both of them has the method called getRequestPath(). You can change the behavior using Plugin in magento 2. Note use after for changing the return value of this method.

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.