Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AfterProductLoad.php
Go to the documentation of this file.
1 <?php
8 
16 {
20  private $stockRegistry;
21 
25  public function __construct(
26  \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
27  ) {
28  $this->stockRegistry = $stockRegistry;
29  }
30 
37  public function afterLoad(\Magento\Catalog\Model\Product $product)
38  {
39  $productExtension = $product->getExtensionAttributes();
40  $productExtension->setStockItem($this->stockRegistry->getStockItem($product->getId()));
41  $product->setExtensionAttributes($productExtension);
42  return $product;
43  }
44 }
afterLoad(\Magento\Catalog\Model\Product $product)
__construct(\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry)