[IMP]website_sale_product_assortment: Apply assortments to accessory & alternative products
Issue
- Previously, product assortment restrictions were not correctly applied to accessory and alternative products displayed in website carousels. This created inconsistencies in product visibility and allowed users to add restricted products to their cart from the accessories section.
Solution
- Implemented proper filtering for accessory products based on assortment restrictions
- Extended the same restriction logic to alternative products in website carousels
- Fixed cart view to prevent purchasing restricted products
Reproduction Steps (in Runboat)
- Configure product assortments with visibility and/or sale restrictions
- Add accessory and alternative products to a main product
- Visit the website and observe product carousels and cart behavior
Before fix: Restricted products remained visible in carousels, and accessory products could be added to cart despite restrictions.
After fix: Products are properly filtered according to assortment rules across all website sections, ensuring consistent visibility and purchasing restrictions.
Technical Approach
- Created helper method _get_allowed_show_products in product.template to ensure consistent filtering logic
- Enhanced the existing accessory/alternative product methods to incorporate assortment restrictions: _get_website_accessory_product _get_website_alternative_product _get_products_alternative_products (website snippet filter)
- Added _show_quick_add_accesory_assortments method in product.product specifically for controlling "Add to cart" button visibility in the cart view for accessory products
- Modified cart template view to use this new method, preventing addition of restricted accessory products
FL-556-4432
Hi @CarlosRoca13, some modules you are maintaining are being modified, check this out!
@LuisAlejandroS This is a very good addition to the module. I have one additional suggestion: the e-commerce search filter also needs to respect these domains. Would you be able to add this? Can you forward port this to V18 please?
Hi @PieterPaulussen,
Maybe what you suggest is what has been solved in https://github.com/OCA/e-commerce/pull/1023?
Regards.