Product saleable qty not showing and update in magento 2.3
-
14-04-2021 - |
Solution
I have same issue with resolved, take inventory_source_item
table backup first.
Run sql query:
INSERT IGNORE INTO `inventory_source_item` (source_code, sku, quantity, status)
select 'default', sku, qty, stock_status from (`cataloginventory_stock_status` as `lg` join `catalog_product_entity` as `prd` on((`lg`.`product_id` = `prd`.`entity_id`)))
Apply command:
php bin/magento indexer:reindex
php bin/magento cache:flush
OTHER TIPS
In Magento v2.3
If you want to use MSI:
Check inventory_reservation
If you don't want to use MSI turn the All Magento Inventory Modules Disable :
https://devdocs.magento.com/guides/v2.3/inventory/index.html
IN DataBase There was two type
1> Tables and
2> Views
also The issue is possibly caused When Import/Export DataBase Views Was Not Created in magento 2.3 So check Views and inventory_stock_1 table In DataBase.
The issue is possibly caused by the missing DB tables
with connections/relations to the Product Table
.
The solution would be:
- Check whether
All DB Tables
(including data) fromthe old DB
are all copied to thenew DB Schema
. - Check if
inventory_stock_1
Table does exist and is filled with data relating to your Product Table.
In Magento 2.3 you need to configure inventory sources in addition to adding product quantity. Check following 2 things:
- Under Stores => Inventory => Sources you have at least one source available. If not then you found the problem. Add New Source with following (you can use different values here if you wanted):
Name: Default Source, Code: default, under Address Data, select your store country & provide a zip code / postcode
. Save & Continue - Under Stores => Inventory => Stocks, if you don't have any records then click on Add New Stock button, Add Name: Default Stock, Websites: select the website and click Assign Source. Now select the default source that we created earlier. Click Save
Reindex catalogue php bin/magento indexer:reindex
and clear the cache.
This should do the trick.
The most probable reason is that you did not assign your product to any Source. As soon as the product would be assigned Magento would calculate Salable product Quantity automatically.
Read more about Salable Quantity calculation and Inventory Management in Magento 2.3 here - https://docs.magento.com/m2/ce/user_guide/catalog/inventory-management.html
What worked for me was creating a new inventory source and assigning it to my products. Not entirely sure what the issue was but it was related to the default source created from the sample data.
In my case, problem was in assigning products to Source.
Check inventory_source_item
table in your DB. If you can't find your product(-s) by SKU - try to regenerate this table items manually.
Warning - it might work only for single stores view.
- Make backup of your
inventory_source_item
table. - Check what source_code is using in this table for products, if it has rows.
- Clear
inventory_source_item
table. - Use this sql query to generate sources for all your products.(change
source_code
value fromdefault
to yours, if needed)
INSERT IGNORE INTO 'inventory_source_item'('source_code', 'sku', 'quantity', 'status') SELECT 'default', catalog_product_entity.sku , cataloginventory_stock_item.qty, 1 FROM 'catalog_product_entity' INNER JOIN 'cataloginventory_stock_item' ON catalog_product_entity.entity_id = cataloginventory_stock_item.product_id
Make sure you use table prefix if needed.
Reindex products
php bin/magento indexer:reindex
And flush cache
php bin/magento cache:flush
Answer by manoj pal above worked for me. The inventory_source_item table was empty and required one-time population.
After setting up Inventory Stocks/Sources in the back end, I observed these problems with my installation that needed fixing:
You could not add a product to cart on front end. 'Product that you are trying to add is not available.'
In the back-end, in the product table, the 'Salable quantity' column was blank, i.e. nothing showing in the table cell.
In the back end, the 'Product Saleable Quantity' twistie on the product page was also blank. Nothing was visible.
When saving a product in the back-end, I observed this error in the var/log/debug.log:
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails CONSTRAINT
INVENTORY_SOURCE_ITEM_SOURCE_CODE_INVENTORY_SOURCE_SOURCE_CODE
FOREIGN KEY (source_code
) REFERENCESinventory_source
(source_code
)), query was: INSERT INTOinventory_source_item
(source_code
,sku
,quantity
,status
) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATEquantity
= VALUES(quantity
),status
= VALUES(status
) [] []
Following instructions above by @manoj-pal fixed this, and I was able to add products to cart.
However, saleable quantity and the twistie was still blank in the admin back end! WTF. I then noticed the join table inventory_source_stock_link table was blank. Googling this took me to this post:
https://stackoverflow.com/questions/57213282/salable-quantity-in-magento-2-3-dont-show
I saw how he inserted the missing row into table inventory_source_stock_link. Once I had populated this table, the back-end product pages started to display 'Salable quantity' in both the table cell and the twistie.
I must say MSI shows lots of promise and capabilities but this upgrade to Inventory Management has been quite a drama!