Magento 2.3 Product Quantity: Why Salable Quantity May Show Zero in the Product Grid

Posted on: 28 Oct 2019 by Admin

This is the ultimate guide to salable quantity magento 2.3 is showing zero in the product grid

In the most advanced Magento version 2.3, you might have seen a new quantity parameter ‘Salable Quantity‘.
Now we will discuss how to make a product’s salable quantity in Magento 2.3

Magento 2.3.x has introduced MSI (Multi-Source inventory) which will help merchants to achieve multiple warehouse inventory management without any 3rd party modules. You can find the details of MSI in Magento’s official dev docs.
To handle Multi Source Inventory Magento is using one predefined Source (Default Source) and one Stock (Default Stock) to which the inventory needs to be added in order to properly calculate the salable qty. For managing the default salable qty Magento using a database view called inventory_stock_1 which will get created on installing Magento.
If you imported the database from your local or a different server, the view won’t be there with your SQL dump and hence Magento won’t be able to calculate the salable qty.
As a result, the entire products will get disappeared from the shop frontend after a reindex or cache flush.
To solve this issue, you will need to manually create the view in your new database by executing the below SQL.

 

CREATE ALGORITHM=UNDEFINED DEFINER=`{database_user}`@`localhost` SQL SECURITY INVOKER VIEW `inventory_stock_1` AS 
SELECT distinct `legacy_stock_status`.`product_id` AS `product_id`,
`legacy_stock_status`.`website_id` AS `website_id`,
`legacy_stock_status`.`stock_id` AS `stock_id`,
`legacy_stock_status`.`qty` AS `quantity`,
`legacy_stock_status`.`stock_status` AS `is_salable`,
`product`.`sku` AS `sku` 
FROM
(
`cataloginventory_stock_status` `legacy_stock_status` 
join `catalog_product_entity` `product` 
on ((`legacy_stock_status`.`product_id` = `product`.`entity_id`))
) ;

 

Replace {database_user} with your actual database user with enough privileges.

Once you executed the query in your database, you may need to flush Magento Cache to update the salable qty in the products grid as shown below.