Skip to content

Catalog Inventory using 0 as website ID #7090

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

Closed
lhsatch opened this issue Oct 19, 2016 · 3 comments
Closed

Catalog Inventory using 0 as website ID #7090

lhsatch opened this issue Oct 19, 2016 · 3 comments
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@lhsatch
Copy link

lhsatch commented Oct 19, 2016

Preconditions

  1. Magento version - 2.1.0

Steps to reproduce

  1. I was attempting to get the stock status of a product using \Magento\Store\Model\StoreManagerInterface getProductsStockStatuses(). This function requires you to pass productIds and the website id.
  2. The returned array for all items was coming back empty.

Expected result

  1. The returned array should contain the stock status (instock 1 out of stock 0) of the product.

Actual result

  1. An empty array is being returned. I have looked in the cataloginventory_stock_status table and can see that the website id is set to 0. See image.
    stockstatuswebsite
    If I look into the catalog_product_website table the website id used is 1.

catalog_product_website

Should the website_id be set to 1 for the first website in the cataloginventory_stock_status?

@odubovyk
Copy link

Thank you for the report. Internal ticket MAGETWO-60146

@odubovyk odubovyk added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Oct 26, 2016
@odubovyk odubovyk removed their assignment Oct 26, 2016
@maghamed
Copy link
Contributor

Hi @lhsatch

Looks like you use
\Magento\CatalogInventory\Model\ResourceModel\Stock\Status::getProductsStockStatuses($productIds, $websiteId, $stockId = Stock::DEFAULT_STOCK_ID)

method passing $websiteId = 1 (your current website) and get an empty result, because ResurceModel Stock Status uses it as a filter for cataloginventory_stock_status table.

Correct way to achieve desirable behavior is to use API interface
\Magento\CatalogInventory\Api\StockStatusRepositoryInterface::getList(StockStatusCriteriaInterface $searchCriteria);
and pass needed product ids as search criteria filter there.

For now Magento supports single stock without linkage to websites

@miakusha
Copy link
Contributor

It's duplicate #5222. Issue was fixed in 2.1.3

magento-engcom-team pushed a commit that referenced this issue Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

5 participants