e-commerce icon indicating copy to clipboard operation
e-commerce copied to clipboard

[IMP]website_sale_product_assortment: Apply assortments to accessory & alternative products

Open LuisAlejandroS opened this issue 9 months ago • 1 comments

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)

  1. Configure product assortments with visibility and/or sale restrictions
  2. Add accessory and alternative products to a main product
  3. 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

LuisAlejandroS avatar Mar 18 '25 10:03 LuisAlejandroS

Hi @CarlosRoca13, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar Mar 18 '25 10:03 OCA-git-bot

@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?

PieterPaulussen avatar May 28 '25 11:05 PieterPaulussen

Hi @PieterPaulussen,

Maybe what you suggest is what has been solved in https://github.com/OCA/e-commerce/pull/1023?

Regards.

danielduqma avatar May 28 '25 14:05 danielduqma