EmicoEcommerce / Magento2Tweakwise

Magento 2 module for Tweakwise integration
Other
4 stars 16 forks source link

Prevent duplicate slug values #159

Closed ah-net closed 3 months ago

ah-net commented 4 months ago

When attribute values have different spellings (Black and Black"), that may cause filters to return no products.

How to Reproduce the Issue:

  1. Utilize the path slug for the URL strategy.
  2. Create an attribute with identical values but different spellings. For instance, "Black," "black," or "black''."
  3. This leads to duplicate values in the tweakwise_attribute_slug table. This may cause (depending on the order) to cause an tweakwise filter with the same value to return no products.

How to test

  1. Utilize the path slug for the URL strategy.
  2. Create an attribute with identical values but different spellings. For instance, "Black," "black," or "black''."
  3. Check if the tweakwise_attribute_slug table has duplicate values.

Solution Implemented in the Pull Request:

To address this issue, the pull request introduces a fix by appending an extra dash and an number at the end of the slug value. This ensures that the slug value remains unique at all times. To fix duplicate values the only thing the customer has to do is to save the attribute with duplicate values.

ah-net commented 4 months ago

There seems to be another bug in this code. If you have Black, first in your attribute options and then black,, the slug of Black, will be overwritten in the database. Scherm­afbeelding 2024-03-01 om 12 59 00

Tweakwise gives the same result if you send black or Black. So no changes needed for this.