I am using magnto2.1.3. i want to show my product id in url on product listing page.below is what i need.
how to achieve this?kindly help me please?
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 communityI am using magnto2.1.3. i want to show my product id in url on product listing page.below is what i need.
how to achieve this?kindly help me please?
Magento add URL-rewrite for product here: Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver
In your extension you should add "before" plugin for execute method. See magento tutorial
In your plugin method you should add:
$product->setUrlKey($product->getUrlKey() . '_' . $product->getId());
(Of course, also you can add some checks for exists product ID in URL key for avoid
[url_key]_[id]_[id]_[id]
P.S. This method will not modify URL-key attribute (because product was saved before), but will modify URL rewrite.
P.S.2. You can use around plugin and after creating URL rewrite set original URL-key for product for avoid some conflicts.