Salable quantity issue: After deleting a product, its entry is still present in the inventory_reservation table.
- Dominant language
- PHP
- Stars
- 357
- Forks
- 262
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions (*)
Tested on this versions:
1. Magento 2.4.3-p1
2. Magento 2.4.5-p1
### Description (*)
When we placed order for any product than order_placed entry is being generated in inventory_reservation table. After that if we delete that product and create order shipment of that order than shipment is successfully generated. But we do not have the product now so the entry of order_placed in inventory_reservation table have to be delete automatic or by using inventory_cleanup_reservation cron but it is now deleting. So now if we create same sku product again and save it than we can see that salable quantity is lesser than the actual quantity we set into the product because same sku name is already stored as order_placed in inventory_reservation table, So it is counting minus in salable quantity in new product. This is causing a salable quantity issue.
### Steps to reproduce (*)
1. Create two simple products
2. Order it both of these products
4. Delete one product from the backend
5. Create shipment for that order
6. Open the database and check inventory_reservation table

### Expected result (*)
1. When we delete one product from the backend than the entry order_placed of that product will also have to be delete from the inventory_reservation table

2. When the order_placed entry was removed from the inventory_reservation table and then if we create a new product with same sku than salable quantity have to set as the default quantity.

3. As we can see here the salable quantity is same as per the quantity I have set here.

### Actual result (*)
1. After deleting one product, the order_placed entry in inventory_reservation table is still showing.
2. If we create new product with same sku which we have deleted before than it is taking less salable quantity because the entry of order_placed of deleted product is still in inventory_reservation table
Contributor guide
Research direction
Start by reproducing the product-order-deletion-shipment flow described in the issue, then inspect the inventory_reservation table and the inventory_cleanup_reservation cron behavior. Trace the product deletion and shipment paths to determine whether the order_placed entry is handled. Done means the reservation no longer reduces salable quantity when a deleted SKU is recreated, with the reported flow verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100