Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent duplicate slug values #159

Merged
merged 2 commits into from Mar 12, 2024
Merged

Conversation

ah-net
Copy link
Collaborator

@ah-net ah-net commented Feb 29, 2024

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 ah-net requested a review from jansentjeu March 1, 2024 09:11
Copy link
Collaborator

@jansentjeu jansentjeu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Api/Data/AttributeSlugInterface.php Outdated Show resolved Hide resolved
Model/AttributeSlug.php Outdated Show resolved Hide resolved
Model/AttributeSlugRepository.php Outdated Show resolved Hide resolved
Model/AttributeSlugRepository.php Outdated Show resolved Hide resolved
@ah-net
Copy link
Collaborator Author

ah-net commented Mar 1, 2024

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.

@ah-net ah-net merged commit 5d31268 into master Mar 12, 2024
3 checks passed
@ah-net ah-net deleted the bugfix-prevent-duplicate-slug-values branch March 12, 2024 08:36
ah-net added a commit that referenced this pull request Mar 15, 2024
* Prevent duplicate slug values (#159)

Prevent duplicate slug values

* Fix notice missing variables (#157)

* Bump version

* chore: Added semantic release (#158)

* chore: Added semantic release

* chore: Added develop branch to semantic release

* chore: Set beta branch as prerelease branch

* chore: Only trigger release workflow for master and beta branch (#160)

* chore: Updated README for semantic release

---------

Co-authored-by: Tjeu Jansen <161043478+jansentjeu@users.noreply.github.com>
Co-authored-by: tjeujansen <tjansen@emico.nl>
ah-net added a commit that referenced this pull request Apr 10, 2024
* chore: Added semantic release (#158)

* chore: Added semantic release

* chore: Added develop branch to semantic release

* chore: Set beta branch as prerelease branch

* chore: Only trigger release workflow for master and beta branch (#160)

* chore: Updated README for semantic release

* Merge master back to beta branch (#165)

* Prevent duplicate slug values (#159)

Prevent duplicate slug values

* Fix notice missing variables (#157)

* Bump version

* chore: Added semantic release (#158)

* chore: Added semantic release

* chore: Added develop branch to semantic release

* chore: Set beta branch as prerelease branch

* chore: Only trigger release workflow for master and beta branch (#160)

* chore: Updated README for semantic release

---------

Co-authored-by: Tjeu Jansen <161043478+jansentjeu@users.noreply.github.com>
Co-authored-by: tjeujansen <tjansen@emico.nl>

* chore: Added Youwe Testing Suite

* chore: Added Magento secrets in testing suite action

* chore: Fixed phpmd linter

* chore: Run grumphp directly with PHP

* perf: Applied phpcs and phpmd rules

BREAKING CHANGE: Code is refactored based on phpcs and phpmd rules.

* Fixed phpcs issues in AttributeSlugRepository

* chore(release): 6.0.0-beta.1 [skip ci]

# [6.0.0-beta.1](v5.8.3...v6.0.0-beta.1) (2024-03-29)

### Performance Improvements

* Applied phpcs and phpmd rules ([9a499fd](9a499fd))

### BREAKING CHANGES

* Code is refactored based on phpcs and phpmd rules.

* feat: searchable filters (#166)

When the filtersearch option is enabled within Tweakwise for a specific filter in the filter template, a search box will now appear above the filter. This search box allows users to conveniently search through the filter values associated with that particular filter.

In cases where no filters are found, the designated text for displaying no results as configured in Tweakwise will be shown.

Additionally, users have the option to specify placeholder text for the search box within Tweakwise.

These modifications have been implemented within the default filter view. If you have customized your own view, please ensure to incorporate these changes accordingly.

* chore(release): 6.0.0-beta.2 [skip ci]

# [6.0.0-beta.2](v6.0.0-beta.1...v6.0.0-beta.2) (2024-04-09)

### Features

* searchable filters ([#166](#166)) ([bebd6c6](bebd6c6))

* Fix spacing

* Add filterpath to url if url no filter exists (#169)

* Bump version nr

---------

Co-authored-by: Tjeu Jansen <161043478+jansentjeu@users.noreply.github.com>
Co-authored-by: tjeujansen <tjansen@emico.nl>
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants