how to show product id included in url on product listing page?
-
15-04-2021 - |
Lösung
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.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange