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?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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?
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();
$criteria->setProductsFilter($productId);
/** @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