-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
do the stock check on default level because the stock on website leve… #11485
Conversation
…l isn't updated and should be ignored Product's are linked to categories without notice of any website. The visual merchandiser shows to lowest price of in stock and active simples that are associated with the configurable. The stock check ignores the website scope so if a simple is in stock on the website level but out of stock on default level it should been ignored to determine the lowest price. This commit fixes that issue.
@naydav could you please take a look on this. |
)->where('stock.stock_status = ?', Stock::STOCK_IN_STOCK); | ||
) | ||
->where('stock.stock_status = ?', Stock::STOCK_IN_STOCK) | ||
->where('stock.website_id = ?', 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a lot of potential problems if we would accept proposed changes, but currently, Magento 2 is a Single Stock system and if your installation is not customized one, there should not be another data in cataloginventory_stock_item
and cataloginventory_stock_status
tables except data for Default Website (0). Thus there are no possibilities to have in_stock data on one website for particular SKU, and out of stock data for the same SKU on another website. That's functionality would be provided by Multi-Source Inventory (MSI) project.
All we do now is storing and retrieving data for Default Website only.
That's why most of the code looks like
/**
* Subtract product qtys from stock.
* Return array of items that require full save
*
* @param string[] $items
* @param int $websiteId
* @return StockItemInterface[]
* @throws \Magento\Framework\Exception\LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function registerProductsSale($items, $websiteId = null)
{
//if (!$websiteId) {
$websiteId = $this->stockConfiguration->getDefaultScopeId();
//}
So, I suppose that there is some customization on Magento Installation where current fix need to be applied.
But that fix could be also achieved pretty easily using Magento extensibility, as the class mentioned in this PR
class StockStatusBaseSelectProcessor implements BaseSelectProcessorInterface
being the implementation of Extension point declared in Magento (BaseSelectProcessorInterface).
Thus even in current code base, there is a possibility to achieve proposed behavior.
But additional filter for DEFAULT WEBSITE (0) we could consider as Defensive Programming practice.
…on website leve… magento#11485 - fixed unit tests
…l isn't updated and should be ignored
Product's are linked to categories without notice of any website. The visual merchandiser shows to lowest price of in stock and active simples that are associated with the configurable. The stock check ignores the website scope so if a simple is in stock on the website level but out of stock on default level it should been ignored to determine the lowest price. This commit fixes that issue.
Fixed Issues (if relevant)
Manual testing scenarios
Before the fix:
After the fix:
Contribution checklist