Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddInventoryDataObserver.php
Go to the documentation of this file.
1 <?php
8 
11 
13 {
17  protected $stockHelper;
18 
22  public function __construct(\Magento\CatalogInventory\Helper\Stock $stockHelper)
23  {
24  $this->stockHelper = $stockHelper;
25  }
26 
33  public function execute(EventObserver $observer)
34  {
35  $product = $observer->getEvent()->getProduct();
36  if ($product instanceof \Magento\Catalog\Model\Product) {
37  $this->stockHelper->assignStatusToProduct($product);
38  }
39  }
40 }
__construct(\Magento\CatalogInventory\Helper\Stock $stockHelper)