Can I limit how many PrestaShop products a visitor can compare?
Yes, the maximum comparison size is configurable. The MAX_ITEMS setting defaults to four on install, the front script refuses to add more items once the limit is reached, and the AJAX product endpoint slices incoming IDs to the same configured maximum.
On install, MAX_ITEMS is created with the value 4; the admin controller saves it with a minimum of 1. That value is sent to the browser in mprCompareConfig.maxItems and also assigned to the comparison page template as maxItems.
var max = config.maxItems || 4;The duplicate enforcement is client-side as well: if the product is already in localStorage, the add function returns without adding it again. The AJAX endpoint still slices the requested ID list to the configured maximum, so a manually edited request cannot make the comparison page load more products than the configured cap.
Was this answer helpful?
Related products
Still have questions?
Can't find what you're looking for? Send us your question and we'll get back to you.