How can I dynamically change the url of a product?
Now I got this url
www.domain.com/product-name.html
I need to add SKU, to my url like this:
www.domain.com/product-name-SKU.html
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHow can I dynamically change the url of a product?
Now I got this url
www.domain.com/product-name.html
I need to add SKU, to my url like this:
www.domain.com/product-name-SKU.html
In Magento 2 you can extend
Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator
class file. Append product SKU into
prepareProductUrlKey(), prepareProductDefaultUrlKey(),getUrlPath() function
.