magento / magento/inventory

Front End to Debug Stock Issues

Open
#3,321 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Progress: ready for grooming
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

Description (*)

Some kind of front end to the Inventory_reservation table, that shows issues. e.g. reservations where the sum of the qty is positive & reservations that don't have an order in the sales_order table.

Expected behavior (*)

Page in the Magento admin to show all the current rows in the inventory_reservation, the ability to click on each one to be taken to the related order.

The ability to remove incorrect rows from the inventory_reservation table.

Another part of the page to flag up issues, if things don't add up correctly.

Benefits

Easy way to fix Inventory_reservation problems without having to use SQL.

Additional information

We had some issues with the import from Magento 1 to Magento 2, orders that were created in Magento 1 then shipped in Magento 2, the inventory_reservation didn't work as expected. We had to delete the rows from inventory_reservation to sort.

We have also had a problem with a PayPal order, something went wrong, the payment failed but we ended up with records in the inventory_reservation table that didn't have a related order is sales_order table.

Please ignore the bad SQL, but this is what we have been using to find the issues in the table:
Find reservations where reservations are positive:
SELECT sku, sum(quantity) FROM inventory_reservation GROUP by sku having sum(quantity)>0

Find reservations where reservations don’t have a matching order:

SELECT res_orderid
FROM sales_order
RIGHT JOIN
(SELECT DISTINCT(SUBSTRING(metadata, POSITION("object_increment_id" IN metadata)+22, LENGTH(metadata)-POSITION("object_increment_id" IN metadata)-23)) AS res_orderid FROM inventory_reservation) b
ON b.res_orderid = sales_order.increment_id
WHERE sales_order.increment_id IS NULL

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the inventory_reservation and sales_order tables and the two SQL examples in the issue to define the reservation checks. The work is done when a Magento admin page lists reservations, links entries to related orders, identifies the described inconsistencies, and supports removing incorrect rows without SQL.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.