List inconsistencies command

The list-inconsistencies command detects and lists all reservation inconsistencies. Use the command options to check only completed or incomplete orders, or all.

bin/magento inventory:reservation:list-inconsistencies

Command options:

  • -c, --complete-orders - Returns inconsistencies for completed orders. Incorrect reservations may still be on hold for completed orders.
  • -i, --incomplete-orders - Returns inconsistencies for incomplete orders (partially shipped, unshipped). Incorrect reservations may hold too much or not enough salable quantity for the orders.
  • -b, --bunch-size - Defines how many orders to load at once.
  • -r, --raw - Raw output.

Responses using -r return 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.

Examples:

bin/magento inventory:reservation:list-inconsistencies

Inconsistencies found on following entries:
Order 172:
- Product bike-123 should be compensated by +2.000000 for stock 1
bin/magento inventory:reservation:list-inconsistencies -r

172:bike-123:+2.000000:1

If no issues are found, this message returns: No order inconsistencies were found.

Create compensations command

The create-compensations command creates compensation reservations. Depending on the issue, new reservations are created to either place or release a hold on salable quantity.

To create reservations, provide 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 option:

  • -r, --raw - Returns raw output.

If the format of the request is incorrect, the following message displays:

Error while parsing argument "your_incorrect_format_argument". Given argument does not match pattern "/(?P<increment_id>.*):(?P<sku>.*):(?P<quantity>.*):(?P<stock_id>.*)/".

As the command creates reservations, it displays messages indicating the updates by SKU, order, and stock.

bin/magento inventory:reservation:create-compensations 172:bike-123:+2.000000:1

Following reservations were created:
- Product bike-123 was compensated by +2.000000 for stock 1

If the SKU for a compensation entry includes spaces, enclose the SKU in quotation marks.

bin/magento inventory:reservation:create-compensations 172:"bike 123":+2.000000:1

Detect inconsistencies and create compensations

You can detect inconsistences and immediately create compensations by using a pipe to run both the list-inconsistencies and create-compensations. Use the -r command option to generate and submit the raw data to create-compensations.

bin/magento inventory:reservation:list-inconsistencies -r | bin/magento inventory:reservation:create-compensations

Example response:

bin/magento inventory:reservation:list-inconsistencies -r | bin/magento inventory:reservation:create-compensations
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
No order inconsistencies were found.

You can also pipe the commands to detect inconsistencies and create compensations for only incomplete (-i) or complete (-c) orders.

bin/magento inventory:reservation:list-inconsistencies -r -i | bin/magento inventory:reservation:create-compensations
bin/magento inventory:reservation:list-inconsistencies -r -c | bin/magento inventory:reservation:create-compensations

Import geocodes

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 Commerce with a command. This option is free of charge.

To import geocodes for offline calculation:

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.