-
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
We have the following situation in _\Magento\Catalog\Model\Product.php#L2298
/**
* Check whether stock status changed
*
* @return bool
*/
private function isStockStatusChanged()
{
$stockItem = null;
$extendedAttributes = $this->getExtensionAttributes();
if ($extendedAttributes !== null) {
$stockItem = $extendedAttributes->getStockItem();
}
$stockData = $this->getStockData();
return (
(is_array($stockData))
&& array_key_exists('is_in_stock', $stockData)
&& (null !== $stockItem)
&& ($stockItem->getIsInStock() != $stockData['is_in_stock'])
);
}We need to DELETE or REFACT this code.
So, we need to check the origin of the Stock Status value. We can solve in several ways:
- [Recommended] Create a mechanism for tracking the origin entity data, based on EntityStateInterface. For this, a separate HLD is required.
- Use origin data from StockItem like as $stockItem->getOriginData('status')
- Create a simple model like this:
class ProductOriginStockStatusChecker
{
public function getValue()
{
// resolving from origin data or direct call to db or
}
}- Using of private property in Product model for storing stock status data.
Metadata
Metadata
Assignees
Labels
No labels