DataFirefly Auto Clearance: automatic clearance of dead stock
Installation, discount tiers, rules per category, price protection, cron task, dashboard and troubleshooting.
Installation
Install the module from Modules > Module Manager > Upload a module by sending the ZIP file, or drop the dfclearance folder into the /modules/ directory of your shop and click Install.
On installation, the module:
- creates an Outlet category under Home, which you can rename or replace with an existing category;
- adds the Catalog > Auto Clearance tab, which lists the products in the outlet;
- creates its tables (outlet products, exclusions, log, outlet sales);
- stays disabled: no price or category changes until you enable the automatic run.
When upgrading from version 1.0.0, simply upload the new ZIP: the upgrade script adds the sales table, the new settings and the new hooks without touching your existing settings.
Getting started
The configuration page shows a four-step checklist until the module is fully running:
- Set your tiers in the Tiers and prices tab. The defaults are 10% at 90 days, 20% at 150 days and 35% at 240 days.
- Run a simulation with the Simulate button at the top of the page. The report lists the products that would enter the outlet, the discounts that would change and the products that would leave. Nothing is written.
- Enable the automatic run, first option of the Tiers and prices tab.
- Schedule the cron task with the URL from the Cron task tab.
After a simulation, the Apply now button runs the process for real if the module is enabled.
Tiers and prices
Default tiers
Each tier links a number of days without sale to a percentage discount. The first tier is the entry threshold into the outlet. Each tier must give a higher discount than the previous one. A timeline under the table shows the progression and flags inconsistent tiers before saving.
Days without sale are counted from the last valid order containing the product, all combinations included. A product that never sold counts from its creation date.
Tier progression
- Days without sale: the counter restarts after each sale, including a sale in the outlet.
- Time spent in the outlet: tiers keep going even if the product sells.
In both cases, the discount of a product in the outlet never goes down.
Tiers per category
The Add a category rule button creates a set of tiers for one category. The rule applies to the category and all its subcategories, and replaces the default tiers for the matching products. When a product matches several rules, the first one in the list wins. For a product moved to the outlet, the module uses the categories it had before entering.
Category handling
- Add (recommended): the product is added to the outlet and stays in its categories.
- Add as default category: the outlet also becomes the default category, shown in the breadcrumb.
- Move: the product only appears in the outlet. Its categories are saved and restored when it leaves.
The Add as default category and Move modes change the product URL when the category is part of your product URL format. PrestaShop redirects the old URL, but check this point before using them on a well-ranked catalog.
Price protection
- Maximum discount (60% by default): cap applied to every tier.
- Margin guard: the outlet price never goes below the purchase price excluding tax plus the minimum margin (5% by default). Products without a purchase price are not limited. If no discount is possible, the product does not enter the outlet.
- Price ending: Exact, x.99, x.90 or x.00. The module rounds the outlet price including tax for the default country to the closest ending. If no ending stays within 5 points of the tier discount, it keeps the exact percentage.
The Preview with a product at box calculates the price at each tier live for the price of your choice, rounding and maximum discount included.
Eligibility
Entry conditions
- Minimum stock to enter: set 2 or more to keep the last unit at full price.
- Ignore products already on sale: a product with an active discount for all customers does not enter the outlet, to avoid stacking.
- Excluded categories and brands: the matching products never enter. A filter field helps you find a category in a long list.
Virtual products, disabled products and products priced at zero are always ignored.
Exit conditions
- Leave the outlet when out of stock: the product gets its categories and regular price back once sold out.
- Leave the outlet when restocked: the product leaves when its stock goes above the quantity it had when it entered.
- A disabled or excluded product also leaves at the next run.
Re-entry delay
A product that leaves the outlet, whether removed manually, restocked, or excluded then allowed again, cannot come back before this delay (30 days by default, 0 disables it). With 30 days, the struck-through price always matches the lowest price of the last 30 days, as required by the EU Omnibus directive. The delay does not apply after a change of outlet category.
New products per run
Limits the number of products entering the outlet at each run (200 by default). The rest is processed at the next runs. Each run also has a time budget to stay within hosting limits.
Pause
Enter a start date and an end date to suspend clearance during official sales or a Black Friday campaign. During the pause, no product enters the outlet and no discount goes up. Exits still apply and current outlet prices stay as they are. The module header shows the pause in progress.
Cron task
The Cron task tab gives the URL to call once a day, preferably at night, with a copy button. Available parameters:
&simulate=1: dry run, nothing is changed;&all_shops=1: processes every shop of a multistore installation.
Example crontab or cPanel line:
0 3 * * * curl -s "https://your-shop.com/module/dfclearance/cron?token=YOUR_TOKEN" > /dev/null
The date of the last call is displayed. If the automatic run is enabled and the cron has not been called for more than 48 hours, a warning appears at the top of the page. The New token button invalidates the current URL.
When the shop is in maintenance mode, add the IP address of your server to the maintenance IP list, otherwise the call is blocked.
Dashboard
The Dashboard tab shows:
- the number of products and units in the outlet;
- the stock to clear at purchase value and its value at outlet price;
- outlet revenue excluding tax over the last 30 days, with the number of orders and units, and since install;
- the stock cleared at purchase value;
- the average discount of products in the outlet;
- a day-by-day chart of outlet revenue, the movements of the last 30 days, the distribution of products per discount and the five best outlet sales.
Sales are recorded when the order is placed, for the products in the outlet at that time. Only valid orders are counted, and amounts are converted to the default currency. Figures start when the module is installed: there is no retroactive history.
Upcoming products and exclusions
The Upcoming tab lists the products that will reach their entry threshold within the next 7, 14, 30 or 60 days, with the discount they will get, their stock and its purchase value. Products marked “next run” are already past their threshold. The Exclude button removes them from clearance for good.
The Excluded products tab accepts product IDs or references separated by commas. Excluding a product already in the outlet makes it leave immediately. The Remove the exclusion button makes it eligible again, after the re-entry delay.
Badge and e-mails
Badge
The badge is shown on product miniatures and product pages, next to the native discount badge. You can choose its color and its text in each language, with a live preview.
E-mail report
Once enabled, a report is sent after each real run that moves products in or out of the outlet, or changes a discount. It lists the products concerned with their discount and the reason. Leave the recipients field empty to use the shop e-mail address, or enter several addresses separated by commas. The test button sends the result of a simulation.
Outlet product list
Catalog > Auto Clearance lists the products in the outlet with their discount, regular price including tax, outlet price including tax, stock, entry date and next step (for example “35% in 38 days”). From this list, you can:
- remove a product from the outlet, which cannot come back before the re-entry delay ends;
- start a manual run;
- export the list to CSV.
How the discount is applied
The discount is a native PrestaShop specific price, for all customers, currencies and countries. The theme therefore shows the usual struck-through price and discount badge. Without a price ending, the discount is a percentage. With an ending, it is an amount including tax calculated for the default country, and themes then show the saving as an amount rather than a percentage.
The module updates the price index of the faceted search module when that module allows it, so that the price filter stays accurate. If the base price of a product changes while it is in the outlet, the specific price is recalculated at the next run.
Uninstall and reset
The Release all products button, in the Cron task tab, removes every product from the outlet, restores its categories and deletes its outlet price. The re-entry delay applies afterwards. Uninstalling the module does the same before deleting its tables. The outlet category is not deleted.
Troubleshooting
No product enters the outlet
Run a simulation. The Products skipped section lists the products the margin guard prevents from being discounted. The other filters do not produce a line in the report: check the minimum stock, the option that ignores products already on sale, the excluded categories and brands, the re-entry delay and a possible pause. Finally, check that the first tier is not longer than the age of your products.
A product removed manually does not come back
This is the re-entry delay. Shorten it, or set it to 0 if you do not sell in the European Union.
The outlet price does not end in .99
On a cheap product, no ending stays within 5 points of the tier discount: the module then keeps the exact percentage. In countries other than the default country, a different VAT rate also shifts the ending.
The cron does not run
Open the cron URL in a browser: it must return a JSON result. A 503 error usually means maintenance mode, a 403 error an invalid token.
Compatibility
- PrestaShop 8.0 to 9.x, the same ZIP covers both branches.
- Multistore and multilingual.
- No Composer dependency.
- Discount applied per product, all combinations included.
- Interface available in French, English, Spanish, German, Italian, Dutch, Polish and Portuguese.