MWA

Maurisource Web Agency

  • Montreal + Magento ®
    • Magento ® ecommerce package
  • Services
  • Portfolio
  • Testimonials
  • Store
  • Magento developer trends publication
  • Contact

September 1, 2020 by Manesh Sonah Leave a Comment (0)

Error salable quantity in Magento is showing null, 0. Even if products are enabled and marked as “In Stock”, the product won’t be able ordered. Since Magento 2.3 this new introduced parameter is not to be found in your database tables because it’s a view.

Why is this happening?

This issue is often seen after migrating a database to a different host. From Localhost to Staging server for example. Since the export script for a MySQL dump file generally excludes the View if done through PhpMyAdmin, this table is discarded from the creation script. So you need to run the following SQL query to have it created again on the migrated server:

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` )
)

Log back into Magento 2 > Products > Catalog, you should now see the Salable Qty values automatically generated corresponding to the Quantity attribute value.

NEXCESS doesn’t allow running query using CREATE ALGORITHM. So the workaround is using CREATE VIEW

CREATE 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` )
)

Magento 2 magento 2, magento 2.3 inventory

Related Posts

  • Magento 2 heroMagento 2 – What’s our thoughts
  • CANADA POST RATES IN MAGENTO 2How to get Canada Post rates in Magento 2 ?
  • Maurisource + ShipStation partnership
  • Magento 2 – How to use dynamic shipping rates in cart or checkout?

About Manesh Sonah

When I'm not looking for solutions in the eCommerce industry: I enjoy traveling, photography, water-sports and gaming.

Do you have a project in mind?

Interaction is the beginning of something great!

Get Started

Copyright © 2021 MWA Maurisource Web Agency