Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
AfterProductLoad Class Reference

Public Member Functions

 __construct (\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry)
 
 afterLoad (\Magento\Catalog\Model\Product $product)
 

Detailed Description

Deprecated:
100.2.0 Stock Item as a part of ExtensionAttributes is deprecated
See also
StockItemInterface when you want to change the stock data
StockStatusInterface when you want to read the stock data for representation layer (storefront)
StockItemRepositoryInterface::save as extension point for customization of saving process

Definition at line 15 of file AfterProductLoad.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\CatalogInventory\Api\StockRegistryInterface  $stockRegistry)
Parameters
\Magento\CatalogInventory\Api\StockRegistryInterface$stockRegistry

Definition at line 25 of file AfterProductLoad.php.

27  {
28  $this->stockRegistry = $stockRegistry;
29  }

Member Function Documentation

◆ afterLoad()

afterLoad ( \Magento\Catalog\Model\Product  $product)

Add stock item information to the product's extension attributes

Parameters
\Magento\Catalog\Model\Product$product
Returns
\Magento\Catalog\Model\Product

Definition at line 37 of file AfterProductLoad.php.

38  {
39  $productExtension = $product->getExtensionAttributes();
40  $productExtension->setStockItem($this->stockRegistry->getStockItem($product->getId()));
41  $product->setExtensionAttributes($productExtension);
42  return $product;
43  }

The documentation for this class was generated from the following file: