Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductProcessUrlRewriteRemovingObserver.php
Go to the documentation of this file.
1 <?php
7 
12 
14 {
18  protected $urlPersist;
19 
23  public function __construct(
25  ) {
26  $this->urlPersist = $urlPersist;
27  }
28 
35  public function execute(\Magento\Framework\Event\Observer $observer)
36  {
38  $product = $observer->getEvent()->getProduct();
39 
40  if ($product->getId()) {
41  $this->urlPersist->deleteByData(
42  [
43  UrlRewrite::ENTITY_ID => $product->getId(),
45  ]
46  );
47  }
48  }
49 }