Automatically set the default product combination (attribute) to the lowest-priced variant.
TecDefaultCombination is a lightweight PrestaShop module that helps you ensure the storefront shows the cheapest product combination as the default selection. It can be run manually from the Back Office or scheduled using a secure front controller (cron-friendly) for bulk updates.
- Scans product combinations and computes the effective final price for each variant.
- Sets the combination with the lowest final price as the product default (updates product_shop.cache_default_attribute and product_attribute default_on flags).
- Designed to be executed via a secure front controller (cron-friendly).
- No extra DB tables added.
- Safe for large catalogs: supports batch processing (when invoked by cron).
- Persisted secure key stored in Configuration (editable from Back Office) to protect cron endpoint.
- Optional debug logging with automatic trimming (keeps last 100 lines).
- PrestaShop 1.7+ (tested on PS 8/9; always verify on a staging environment before production use).
- PHP version compatible with your PrestaShop installation.
- Upload the
tecdefaultcombinationfolder into your PrestaShopmodules/directory. - Install the module from the Back Office > Modules > Module Manager or use the CLI/console installer if you prefer.
- Configure the module from the module page in the Back Office.
You can trigger the process manually from the module Back Office or schedule it using a cron job calling the module front controller.
Example cron base URL (replace domain and secure_key accordingly):
https://yourshop.example/module/tecdefaultcombination/cron?secure_key=YOUR_FULL_SECURE_KEYSupported query parameters:
dry_run=1— compute and count changes without applying them (useful for testing).batch_size=N— process at mostNproducts in this run (0 means all products).start=K— pagination offset when usingbatch_size(useful to run multiple batches).
Examples:
# Dry run (no changes applied)
curl -s "https://yourshop.example/module/tecdefaultcombination/cron?secure_key=YOUR_FULL_SECURE_KEY&dry_run=1"
# Execute with batch of 50 products
curl -s "https://yourshop.example/module/tecdefaultcombination/cron?secure_key=YOUR_FULL_SECURE_KEY&batch_size=50&start=0"Notes:
- The module validates the full secure key saved in the module settings (not a short prefix) by default. The secure key is persisted in Configuration (option:
TECDEFAULTCOMBINATION_SECURE_KEY) and can be changed in the module Back Office. - Keep the secure key secret and always call the cron endpoint over HTTPS.
Open the module settings in the PrestaShop Back Office to:
- View/edit the
Module secure key(persistent token stored asTECDEFAULTCOMBINATION_SECURE_KEY). - Enable or disable
Debug(switch). When enabled, cron runs will write messages tomodules/tecdefaultcombination/logs/cron.log. - After changing settings, save and use the displayed Cron URL.
- Log file:
modules/tecdefaultcombination/logs/cron.log - When Debug is enabled the module appends cron start/finish/error lines to the file.
- To prevent uncontrolled growth, the module trims the log file keeping only the last 100 lines after each write.
- To avoid committing logs to Git, add
modules/tecdefaultcombination/logs/to your repository.gitignore.
Make sure the web server user has write permissions to the module logs/ folder. Example:
mkdir -p modules/tecdefaultcombination/logs
chown -R www-data:www-data modules/tecdefaultcombination/logs
chmod 755 modules/tecdefaultcombination/logs(adjust www-data to your web server user).
- If the cron returns
403 Invalid secure_key, verify the key in the module configuration and that you are calling the cron over HTTPS. - If the cron does not modify products, run a
dry_runfirst to see how many products would be updated. - For large catalogs, use
batch_sizeandstartto process data in smaller chunks. - If logs are not written, check directory permissions and confirm Debug is enabled in the module settings.
See CHANGELOG.md for release notes. The module version 1.0.2 includes persistent secure key support, cron parameter support (dry_run, batch_size, start), debug switch and log trimming, and improved price calculation for combinations.
- Keep the
secure_keyprivate. Do not expose it in public repositories. - Use HTTPS for all cron requests.
- Rotate the secure key periodically if required by your security policy.
Contributions, bug reports and feature requests are welcome. Please open issues or pull requests on the module repository.
When submitting changes, include:
- PrestaShop version used for testing
- PHP version and any relevant server info
- Steps to reproduce the issue
MIT License — see the LICENSE file for details.
Tecnoacquisti.com — support: https://www.tecnoacquisti.com