14

Actually in my case Salable Quantity is showing zero in product grid Magento 2.3.

Due to this issue, products are not showing in frontend. If anyone has any idea then please tell me.

For this re-indexing is also done but still Salable Quantity is showing zero(0).

Add and update Quantity programmatic but Salable Quantity is showing zero .

  • try to allow out of stock backorder and check if the products will be displayed. This is not a fix but at least to check wether the exact problem is the salable qty. – fmsthird Jan 8 '19 at 3:42
  • have you fixed it? – fmsthird Jan 9 '19 at 4:17
  • yes actually there was a permission problem in our server – Hitesh Balpande Jan 9 '19 at 4:52
  • Hi, Have you found out the issue? – Octopus Feb 6 '19 at 9:33
  • 1
    @Octopus,yes reindex worked always but there was permission in server then it is resolved – Hitesh Balpande Feb 6 '19 at 9:46
20

In DataBase, There was two type,

1) Tables

2) Views

The issue is possibly caused when Import/Export DataBase Views was not created in Magento 2.3. So create Views and inventory_stock_1 table in DataBase.

See Attached Image:

enter image description here

  • 1
    Thank you so much. After spending 2 hours I got the solutions from your answer. Thanks again. – Kamlesh Solanki Jun 29 '19 at 15:33
  • 2
    +1 For Great Answer – Sanjay Gohil Jul 19 '19 at 10:31
  • @Savan its already created at my end. but still facing same issue – insoftservice Aug 15 '19 at 6:50
  • @insoftservice I am facing the same issue, did you get any idea? – Hardik Visa Oct 8 '19 at 10:07
  • @HardikVisa do you have this view at your end. If yes just try to execute it manually at my end it was given permission issue which got resolved by granting full permission. – insoftservice Oct 8 '19 at 12:12
9

I skipped this line of query, due to Previllages error and my add to cart was not working on live server, in local server this line was not skipped and add to cart was working fine.

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`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`))) ;

Because the View was not created in the live server enter image description here

3

I had to remove the DEFINER=root@localhost from @Thakur answer so here is what I used:

CREATE ALGORITHM=UNDEFINED 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`))) ;

Failure to remove it caused a privilege error.

1

Please try the below steps:

Admin -> Stores -> Inventory -> Stock -> Edit Default Stock -> Sales Channels -> select Main Website

It worked fine.

OR find the below link

https://webkul.com/blog/get-salable-quantity-in-magento-2-3/

0

I was facing the same issue, after creating the view by executing the below query my problem has been resolved.

CREATE ALGORITHM=UNDEFINED DEFINER=`{database_user_name}`@`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`))
   ) ;
0

Another method to fix this would be to remove the patch from the patch_list and re-run the setup:upgrade to re-invoke the command.

The code responsible for creating the SQL SECURITY INVOKER can be found in Magento\InventoryCatalog\Setup\Patch\Schema\CreateLegacyStockStatusView.

You can remove the data patch from the patch list by searching running

select * from patch_list where patch_name = 'Magento\InventoryCatalog\Setup\Patch\Schema\CreateLegacyStockStatusView

Delete the record.

Re-run setup:upgrade setup:di:compile setup:static-content:deploy

Re-save the products with ZERO Salable Quantity either one by one or mass action via admin.

0

I'm gonna share my experience related to this issue, i hope it could help someone who would have been in the same situation.

We were working on an staged instance, all was ready to go to production. So we duplicated everything on the prod env and launched some SQL truncates in order to delete every dummy orders, reviews, etc.. you get the idea.

After some final tests, we realized that our products "stock qty" where far different from product "salable qty". The SQL View seemed to work fine, so we investigated deeper. Turns out we missed a SQL table in our truncate instructions :

TRUNCATE TABLE `inventory_reservation`;

This bad girl was containing each "not shipped but reserved products" from past orders.

Of course don't forget to reindex stuff :

bin/magento indexer:reindex;
-3

I just changed to STORE -> CATELOG -> INVENTORY -> PRODUCTS STOCK OPTIONS -> BACKORDERS -> Allow Qty Below 0

and the issue solved

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