Ask a Question

Categories
< All Topics
  • Main
  • Magento 2
  • Disable or Enable MSI (Saleable Quantity) | Magento 2
Print

Disable or Enable MSI (Saleable Quantity) | Magento 2

In some cases, you may need to remove “Saleable Quantity” or after removing it you may change your mind and want to revert the change.

Removing Saleable Quantity

This can be achieved in a few ways;

  • Option 1: If you can access the following file on the server app/etc/config.php change 1 with 0 for every module that contains ‘Magento_Inventory’ in its name. I have listed only 4 modules but there are plenty of them
   'Magento_Inventory' => 0,
   'Magento_InventoryAdminUi' => 0,
   'Magento_InventoryAdvancedCheckout' => 0,
   ...

You can see the full list of modules on Magento’s official site: https://devdocs.magento.com/extensions/inventory-management/ 1

  • Option 2: Run the following SSH line which will find all modules with the names containing “Magento_Inventory” to disable
php bin/magento module:status | grep Magento_Inventory | grep -v List | grep -v None | grep -v -e '^$' | xargs php bin/magento module:disable

Finally, run the below lines to complete the process

php bin/magento s:upgrade
php bin/magento s:s:deploy -f
php bin/magento c:flush
php bin/magento i:reindex

Revert Changes

If the table of views -> inventory_stock_1 does not exist in Magento 2 database

Run the below SQL query in your database to create the table:

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

After creating the view table, now we need to link it to inventory:

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

After all, If Saleable Quantity is empty on the Magento backend then run the below query in your database:

INSERT INTO `inventory_source_stock_link` (`link_id`, `stock_id`, `source_code`, `priority`) VALUES ('1', '1', 'default', '1');

Finally, reset the indexer and reindex;

php bin/magento indexer:reset && php bin/magento indexer:reindex

In some cases, you may need to create “Default Source” and “Default Stock” manually on the Magento backend.

Stores > Inventory > Sources

Stores > Inventory > Stocks

That’s it!

 

Reference:
  1. Magento 2[]
Previous Command returned non-zero exit code: (Switch from developer to production)
Next Magento 2.4 minimum system requirements
0 Comment

No Comment.

Table of Contents
Home
Search
WhatsApp