Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteProductGoogleExperimentScriptObserver.php
Go to the documentation of this file.
1 <?php
9 
11 
13 {
17  protected $_modelCode;
18 
22  public function __construct(\Magento\GoogleOptimizer\Model\Code $modelCode)
23  {
24  $this->_modelCode = $modelCode;
25  }
26 
33  public function execute(\Magento\Framework\Event\Observer $observer)
34  {
36  $product = $observer->getEvent()->getProduct();
37  $this->_modelCode->loadByEntityIdAndType(
38  $product->getId(),
40  $product->getStoreId()
41  );
42 
43  if ($this->_modelCode->getId()) {
44  $this->_modelCode->delete();
45  }
46  return $this;
47  }
48 }