Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductUrlKeyAutogeneratorObserver.php
Go to the documentation of this file.
1 <?php
7 
12 
14 {
19 
24  {
25  $this->productUrlPathGenerator = $productUrlPathGenerator;
26  }
27 
32  public function execute(\Magento\Framework\Event\Observer $observer)
33  {
35  $product = $observer->getEvent()->getProduct();
36  $urlKey = $this->productUrlPathGenerator->getUrlKey($product);
37  if (null !== $urlKey) {
38  $product->setUrlKey($urlKey);
39  }
40  }
41 }