I would like to add a Product Prefix (Static Path) to product URLs.
Something like www.test.com/product-prefix/product1.html
So all products url of the website follows the same structure – www.test.com/product-prefix/product2.html
Where product-prefix is a static product-prefix.
I want to add it as statically , no url rewrite concept.
I have checked core ProductUrlPathGenerator.php but not getting exact solution. Can anybody help and suggest the better way ?
Magento Version – 2.2
Best Answer
After debugging of couple of hours i have resolved this issue by following below method.
I have override two files in my custom module, One is Product Url Model and Another one is Router Controller\Router
Below is the di.xml
Code for Url.php
Code for Controller Router.php