Inventory Reservation Cleaner for Magento 2
- Compatibility
- 2.4.9, 2.4.8, 2.4.7, 2.4.6, 2.4.5, 2.4.4, 2.4.3, 2.4.2, 2.4.1, 2.4.0
Description / Inventory Reservation Cleaner for Magento 2
MAGENTO 2 · ERP · MSI · SELECTED STOCKS
Clean MSI reservations in line with your ERP process.
Kowal Reservation Cleaner
In a specialized ERP-first implementation, run controlled reservation cleanup for the entire table or selected stocks. Choose the schedule, logging, reindexing, and process lock.
Cron or CLI · Log Only and Dry Run · Full or selective cleanup
HOW IT WORKS IN PRACTICE
01 · Define the synchronization model
Confirm when ERP provides the correct stock levels.
02 · Check the scope
Select stocks and review the Log Only or Dry Run result.
03 · Run the process
The schedule or CLI performs cleanup and optional reindexing.
What does your store gain?
Explore the module features, use cases, and settings.
Who this module is for
The module is a good fit if:
- stock levels are regularly imported from ERP
- Magento is not the primary inventory system
- MSI reservations disrupt
salable quantity - you need fast, predictable, and automatic reservation cleanup
- the store runs on multiple stocks and cleanup should cover only selected ones
The module is not intended for stores that manage stock levels exclusively in Magento and rely on full real-time MSI logic.
The problem it solves
In standard Magento 2 with MSI, subsequent orders, cancellations, and shipments save data in inventory_reservation. In environments with ERP integration, these records often stop being operationally needed, but they still affect product availability and stock diagnostics.
Most common effects:
- understated
salable quantity - discrepancies between Magento and ERP
- a growing number of records in
inventory_reservation - more difficult inventory issue diagnostics
- additional load for availability-related calculations
Key features
- automatic execution from Magento CRON
- manual execution via CLI
full_reset,log_only, andclean_after_erp_syncmodes- lock to prevent parallel process execution
- optional reindexing after cleanup
- optional cache clean after completion
- technical logging to a file
- option to limit cleanup to selected stocks
How the module works
The module registers a CRON task that runs frequently, but actual execution happens only when the current time matches the configuration. This means the system schedule does not need to be dynamically rebuilt after every settings change.
Process flow:
- Check whether the module is enabled.
- Check whether the environment is allowed.
- Check the schedule.
- Apply the process lock.
- Count reservation records.
- Perform cleanup or logging only.
- Optional reindexing.
- Optional cache clean.
- Release the lock and write the log.
Full Reset
The simplest and fastest option for ERP-first stores.
When cleanup applies to all stocks, the module uses:
TRUNCATE TABLE inventory_reservation
This solution is the most efficient with a large number of records.
Log Only
Diagnostic mode. The module does not delete data and only counts records and writes the result to the log.
Clean After ERP Sync
A mode designed to run immediately after importing stock levels from ERP. Functionally, it cleans reservations in the same way as full_reset, but it organizes the implementation model and schedule.
Cleanup only for selected stocks
The module also supports a scenario where cleanup is performed only for specified stocks.
How it works:
- if the stock list is empty, the entire reservation table is cleaned
- if specific stocks are specified, the module deletes only records for those
stock_idvalues
In this case, a selective query is used:
DELETE FROM inventory_reservation WHERE stock_id IN (...)
This approach is slower than TRUNCATE, but it allows you to keep reservations for the remaining stocks and provides more control in more complex implementations.
Business benefits
- better stock level consistency between Magento and ERP
- fewer errors related to
salable quantity - simpler inventory diagnostics
- lower risk of unnecessary data accumulating in MSI
- implementation without disabling Magento MSI
- a predictable and fast process that can be automated
Configuration
Admin panel:
Stores -> Configuration -> Kowal -> Reservation Cleaner
Key settings:
- enable or disable the module
- select the operating mode
- execution hour and minute
- select stocks for cleanup
- enable reindexing
- reindexing type
- cache clean after the process
- logging
- lock validity time
- limit operation to selected environments
Running from CLI
Basic command:
bin/magento kowal:reservation:clean
Example usage:
bin/magento kowal:reservation:clean --mode=full_resetbin/magento kowal:reservation:clean --mode=log_onlybin/magento kowal:reservation:clean --reindex=inventory_onlybin/magento kowal:reservation:clean --dry-run=1bin/magento kowal:reservation:clean --stocks=1,2
This lets you run the module manually, for testing, or directly after the ERP import is completed.
Logging and security
The technical log is written to:
var/log/kowal_reservation_cleaner.log
The module includes:
- process lock
- exception handling
- environment control
- time slot control
- ability to work in
log_onlymode
Recommended implementation model
The most practical option for ERP-first stores:
full_resetmode- active logging
- schedule started shortly after the ERP import
inventory_onlyreindexing or reindexing handled separately in the integration process- empty stock field for full cleanup, or specified stocks where a selective option is required
Limitations
This module:
- does not fix MSI logic
- does not reconstruct reservation history
- does not replace a properly designed ERP integration
- is not a universal solution for all Magento stores
It is a specialized tool for implementations where ERP manages the actual inventory state.
Package and module name
- Magento module:
Kowal_ReservationCleaner - Composer package:
kowal/reservation-cleaner
CTA
Need implementation or module adjustment for ERP integration, multiple stocks, or a custom schedule? Contact us via kowal.store and describe your inventory synchronization model.
Cleanup deletes reservation history
Full Reset and Clean After ERP Sync delete reservation records within the selected scope. With an empty stock list, the process empties the entire inventory_reservation table; with specified stocks, it deletes only their records.
Implementation requires a model in which ERP provides the correct stock levels after the order process is taken into account. Deleting reservations alone does not confirm availability accuracy and does not restore MSI history.
Post-ERP mode and the actual trigger
The name clean_after_erp_sync describes the use case; it is not an automatic integration with the ERP import completion event. You organize execution after synchronization through CLI or a properly selected schedule.
Cron checks the configured time slot and environment. Environment handling uses APP_ENV or MAGENTO_ENV and the Magento mode. The lock limits parallel executions.
Pre-operation check
Log Only and --dry-run=1 are used to count records without deleting them. Verify stock_id, ERP import completion, and the expected salable quantity before enabling cleanup.
Reindexing and cache clean are optional steps. Choose inventory_only, full reindexing, or a separate indexing process to match the actual inventory integration.
Installation via Composer
Package kowal/reservation-cleaner, module Kowal_ReservationCleaner. After configuring access to the Kowal repository, install the package, enable the module, update Magento, and clear the cache. In production, include compilation and static content deployment according to your store process.
From configuration to result
1. Define the synchronization model
Confirm when ERP provides the correct stock levels.
2. Check the scope
Select stocks and review the Log Only or Dry Run result.
3. Run the process
The schedule or CLI performs cleanup and optional reindexing.
Controlled stage after ERP import
ERP has completed the stock level import. The integration starts the CLI process for the defined stock scope, and the result is written to the log.
The clean_after_erp_sync mode does not detect import completion on its own. The order of stages is ensured by the schedule or ERP integration.
Match reservations to your inventory model
Want to tailor the module to your store? Ask about Kowal Reservation Cleaner implementation and discuss configuration or the extensions you need.
More Information
| Theme compatibility | Luma / Blank, KOWAL |
|---|
Questions and Answers
Does the module disable MSI in Magento 2?
Can reservations be cleared only for selected stocks?
How can the module be run?
Is the module suitable for every Magento store?
Change Log
Module Installation Instructions
Installation via Composer
You will receive access credentials for the Composer repository, the customer email address and license token, by email after purchase. They are also available in the customer panel after logging in at kowal.store. Replace TWOJ_EMAIL_KLIENTA with your account email address and TWOJ_TOKEN with the token you received. Run the commands in the Magento root directory.
composer config repositories.kowal composer https://repo.kowal.storecomposer config http-basic.repo.kowal.store 'TWOJ_EMAIL_KLIENTA' 'TWOJ_TOKEN'composer require kowal/reservation-cleanerCompleting the installation
After installing the package, update Magento and clear the cache:
php bin/magento setup:upgradephp bin/magento cache:flushIn a production environment, also run DI compilation and deploy static files according to your store deployment process.