I have got an issue of "Stock Item with id "x" does not exist" because of this some product have didn't display price and options in product detail page.

Have any solution?

1 Answer 1


Basically I am not getting your questions. But primarily, it looks like you need stock details.

So, for that, you can follow the below approach

/** @var \Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory $stockStatusCriteriaFactory **/
        $criteria = $stockStatusCriteriaFactory->create();
        /** @var \Magento\CatalogInventory\Api\Data\StockStatusRepositoryInterface $stockStatusRepository **/
        $result = $stockStatusRepository->getList($criteria);
        $stockStatus = current($result->getItems());
        $stockStatus->getProductId();                 // product id
        $stockStatus->getQty();   // quantity of specified product
        $stockStatus->getStockStatus();     // Could be 
// Magento\CatalogInventory\Model\Stock\Status::STATUS_OUT_OF_STOCK = 0;
// or
// Magento\CatalogInventory\Model\Stock\Status::STATUS_IN_STOCK = 1;

Credits: https://github.com/magento/magento2/issues/7057#issuecomment-256052729

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.