-
Notifications
You must be signed in to change notification settings - Fork 255
Closed
Description
Full context in documentation
[HLD] Inconsistent saving of Stock Data
Description
1. Replace 'getExtensionAttributes' method
/**
* {@inheritdoc}
*
* @return \Magento\Catalog\Api\Data\ProductExtensionInterface
*/
public function getExtensionAttributes()
{
$extensionAttributes = $this->_getExtensionAttributes();
if (!$extensionAttributes) {
/** @var \Magento\Catalog\Api\Data\ProductExtensionInterface $extensionAttributes */
$extensionAttributes = $this->extensionAttributesFactory->create(
\Magento\Catalog\Api\Data\ProductInterface::class
);
$this->setExtensionAttributes($extensionAttributes);
}
return $extensionAttributes;
}After replacing, we nave a problem: the extensionAttributes is recreated every time the method is called.
2. Fix 'toArray' and 'fromArray'
The entities:
- \Magento\Catalog\Model\Product::toArray
- \Magento\Catalog\Model\Product::fromArray
must be changed to get the stock inventory data from the current StockItem.
3. Remove reindexing from 'afterSave'
Remove the following from the \Magento\Catalog\Model\Product::afterSave:
if ($this->getStockData()) {
$this->setForceReindexEavRequired(true);
}Metadata
Metadata
Assignees
Labels
No labels