Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve problem with origin data #22

Closed
naydav opened this issue May 19, 2017 · 0 comments
Closed

Resolve problem with origin data #22

naydav opened this issue May 19, 2017 · 0 comments
Assignees

Comments

@naydav
Copy link

naydav commented May 19, 2017

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:

  1. [Recommended] Create a mechanism for tracking the origin entity data, based on EntityStateInterface. For this, a separate HLD is required.
  2. Use origin data from StockItem like as $stockItem->getOriginData('status')
  3. Create a simple model like this:
class ProductOriginStockStatusChecker
{
    public function getValue()
    {
        // resolving from origin data or direct call to db or 
    } 
}
  1. Using of private property in Product model for storing stock status data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant