-
Notifications
You must be signed in to change notification settings - Fork 247
CLI Reference
DEVELOP User Guide - This guide provides MSI Develop Branch/Active Development merchant information on Magento Multi Source Inventory (MSI) features and project.
MSI Inventory Management provides CLI commands to manage inventory data and configuration settings.
These commands include:
- Checking and resolving reservation inconsistencies affecting salable quantity
- Adding geocodes for the Distance Priority algorithm
Reservations place a salable quantity hold for product SKUs per stock. When you ship, add products, cancel, or refund an order, compensation reservations enter to place or clear these holds.
MSI provides two CLI commands to check and resolve reservation inconsistencies:
inventory:reservation:list-inconsistencies
inventory:reservation:create-compensations
Inventory Management generates reservations for key events:
- Order placement (initial reservation)
- Order shipment (compensation reservation)
- Refund order or issue a credit memo (compensation reservation)
- Order cancellation (compensation reservation)
Reservation inconsistencies may occur when Inventory Management loses the initial reservation and enters too many reservation compensations (overcompensating and leading to inconsistent amounts), or correctly places the initial reservation but loses compensational reservations.
The following configurations and events can cause reservation inconsistencies:
- Upgrade Magento to 2.3.x with orders not in a completed state (Complete, Canceled, or Closed). Inventory Management will create compensational reservations for these orders, but it will not enter or have the initial reservation that deducts from the salable quantity. We recommend using these commands after upgrading to Magento v2.3.x from 2.1.x or 2.2.x. If you have pending orders, the commands correctly update your salable quantity and reservations for sales and order fulfillment.
- You do not manage stock then later change this configuration. You may start using 2.3.x with Manage Stock set to "No" in the Magento configuration. Magento does not place reservations at order placement and shipment events. If you later enable the Manage Stock configuration and some orders were created at that time, the Salable Qty would be corrupted with compensation reservation when you handle and fulfill that order.
- You re-assign the Stock for a Website while orders submit to that website. The initial reservation enters for the initial stock and all compensational reservation enter to the new stock.
-
The sum total of all reservations may not resolve to
0
. All reservations in the scope of an Order in a completed state (Complete, Canceled, Closed) should resolve to0
, clearing all salable quantity holds.
The list-inconsistencies
command detects and lists all reservation inconsistencies. Use the options to check completed or incomplete orders, or all.
bin/magento inventory:reservation:list-inconsistencies
Command options:
-
-c
,--complete-orders
- Returns inconsistencies for only completed orders. Incorrect reservations may still be on hold for completed orders. -
-i
,--incomplete-orders
- Returns inconsistencies for only incomplete orders (partially shipped, unshipped). Incorrect reservations may hold too much or not enough salable quantity for the orders. -
-r
,--raw
- Returns inconsistences for all orders in raw output.
If no issues are found, this message returns: No order inconsistencies were found.
Returned values are in <ORDER_INCREMENT_ID>:<SKU>:<QUANTITY>:<STOCK-ID>
format:
- Order ID indicates the scope of the inconsistency.
- SKU indicates the product with the inconsistency.
- Quantity sets the amount to enter for the reservation compensation.
- Stock ID defines to scope for stock, which uses the reservations to calculate salable quantity.
Example responses:
Inconsistencies found on following entries:
Order 172:
- Product bike-123 should be compensated by +2.000000 for stock 1
172:bike-123:+2.000000:1
The create-compensations
command creates compensation reservations using the returned list of inconsistencies. Depending on the issue, new reservations are created to either place or release a hold on salable quantity. When these are generated, the metadata in the database indicates these are "event_type":"manual_compensation"
.
You can run both commands by piping list-inconsistencies
and create-compensations
to check and immediately create compensations. If not, you will need to provide the compensations using the format <ORDER_INCREMENT_ID>:<SKU>:<QUANTITY>:<STOCK-ID>
such as 172:bike-123:+2.000000:1
.
bin/magento inventory:reservation:create-compensations
Command options:
-
-c
,--complete-orders
- Creates reservations for only completed order inconsistencies. -
-i
,--incomplete-orders
- Creates reservations for only incomplete order inconsistencies. -
-r
,--raw
- Raw output. -
-d
,--dry-run
- Simulates the reservation creation without affecting reservations. Use this option to get a test run of potential reservation compensations.
Requested compendations must be provided using this format: <ORDER_INCREMENT_ID>:<SKU>:<QUANTITY>:<STOCK-ID>
.
If the format of the request is incorrect, the following message displays: A list of compensations needs to be defined as argument or STDIN.
As reservations are entered, messages display indicating the updates by SKU, order, and stock.
Check reservation inconsistencies for all orders and create compensations by piping these commands together:
bin/magento inventory:reservation:list-inconsistencies -r | bin/magento inventory:reservation:create-compensations
Example response:
Following reservations were created:
- Product bike-123 was compensated by +2.000000 for stock 1
- Product bikehat-456 was compensated by +1.000000 for stock 1
After updates complete, run the list command to verify:
bin/magento inventory:reservation:list-inconsistencies -r
If no other issues are found, this message displays:
No order inconsistencies were found.
Inventory Management provides the Distance Priority algorithm, which helps determine the best option for shipping a full or partial order. The algorithm uses GPS information or geocodes to calculate the distance between the source (a warehouse or other physical location) of each item in an order and the shipping address. Based on those results, the algorithm recommends which source should be used to ship out each item in the order.
The merchant selects the provider of the GPS or geocode data required to calculate distances:
-
Google MAP uses Google Maps Platform services to calculate the distance and time between the shipping destination address and source locations. This option requires a Google billing plan and may incur charges through Google.
-
Offline calculation calculates the distance using data downloaded from geonames.org and imported into Magento with a command. This option is free of charge.
Enter the following command with a space-separated list of ISO-3166 alpha2 country codes:
bin/magento inventory-geonames:import <country code> <country code> ...
For example:
bin/magento inventory-geonames:import us ca gb de
The system downloads and imports the geocodes data to your database, then displays the message Importing <country code>: OK
.
Multi-Source Inventory developed by Magento 2 Community
- Technical Vision. Catalog Inventory
- Installation Guide
- List of Inventory APIs and their legacy analogs
- MSI Roadmap
- Known Issues in Order Lifecycle
- MSI User Guide
- 2.3 LIVE User Guide
- MSI Release Notes and Installation
- Overview
- Get Started with MSI
- MSI features and processes
- Global and Product Settings
- Configure Source Selection Algorithm
- Create Sources
- Create Stock
- Assign Inventory and Product Notifications
- Configure MSI backorders
- MSI Import and Export Product Data
- Mass Action Tool
- Shipment and Order Management
- CLI reference
- Reports and MSI
- MSI FAQs
- DevDocs Documentation
- Manage Inventory Management Modules (install/upgrade info)
- Inventory Management
- Reservations
- Inventory CLI reference
- Inventory API reference
- Inventory In-Store Pickup API reference
- Order Processing with Inventory Management
- Managing sources
- Managing stocks
- Link and unlink stocks and sources
- Manage source items
- Perform bulk actions
- Manage Low-Quantity Notifications
- Check salable quantities
- Manage source selection algorithms
- User Stories
- Support of Store Pickup for MSI
- Product list assignment per Source
- Source assignment per Product
- Stocks to Sales Channel Mapping
- Adapt Product Import/Export to support multi Sourcing
- Introduce SourceCode attribute for Source and SourceItem entities
- Assign Source Selector for Processing of Returns Credit Memo
- User Scenarios:
- Technical Designs:
- Module Structure in MSI
- When should an interface go into the Model directory and when should it go in the Api directory?
- Source and Stock Item configuration Design and DB structure
- Stock and Source Configuration design
- Open Technical Questions
- Inconsistent saving of Stock Data
- Source API
- Source WebAPI
- Sources to Sales Channels mapping
- Service Contracts MSI
- Salable Quantity Calculation and Mechanism of Reservations
- StockItem indexation
- Web API and How To cover them with Functional Testing
- Source Selection Algorithms
- Validation of Domain Entities
- PHP 7 Syntax usage for Magento contribution
- The first step towards pre generated IDs. And how this will improve your Integration tests
- The Concept of Default Source and Domain Driven Design
- Extension Point of Product Import/Export
- Source Selection Algorithm
- SourceItem Entity Extension
- Design Document for changing SerializerInterface
- Stock Management for Order Cancelation
- Admin UI
- MFTF Extension Tests
- Weekly MSI Demos
- Tutorials