diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 6cfa90a7c4c0c..c94c52c7d31a2 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -29,6 +29,7 @@ * @method \Magento\Catalog\Model\ResourceModel\Product\Collection getCollection() * @method string getUrlKey() * @method Product setUrlKey(string $urlKey) + * @method Product setUrlPath(string $urlKey) * @method Product setRequestPath(string $requestPath) * @method Product setWebsiteIds(array $ids) * diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlPathAutogeneratorObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlPathAutogeneratorObserver.php new file mode 100644 index 0000000000000..c8bccc5f05f21 --- /dev/null +++ b/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlPathAutogeneratorObserver.php @@ -0,0 +1,36 @@ +productUrlPathGenerator = $productUrlPathGenerator; + } + + /** + * @param \Magento\Framework\Event\Observer $observer + * @return void + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + /** @var Product $product */ + $product = $observer->getEvent()->getProduct(); + $product->setUrlPath($this->productUrlPathGenerator->getUrlPath($product)); + } +} diff --git a/app/code/Magento/CatalogUrlRewrite/etc/events.xml b/app/code/Magento/CatalogUrlRewrite/etc/events.xml index 60c8d1045d836..b9af7031a6a36 100644 --- a/app/code/Magento/CatalogUrlRewrite/etc/events.xml +++ b/app/code/Magento/CatalogUrlRewrite/etc/events.xml @@ -23,6 +23,7 @@ +