Skip to content

Conversation

@joshheald
Copy link
Contributor

Description

This PR prevents variations from getting duplicated attributes in their names.

Previously, if a variable product was edited, its attributes would be added to the database again on the next incremental sync. This resulted in its variation's names showing the same components multiple times, making it harder to fit and identify a variation by name.

Cause

Attributes were duplicated in the database because although we use save, which upserts items, they wouldn't update, because they use an auto-incremented primary key. This is due to "local attributes" all having an ID of 0 (local to the product, not related to local catalog.)

GRDB identified the attributes as new, and inserted them instead, which meant that the calculation of the variation's name pulled in all the copies of the attribuet.

Fix

To fix this, we simply delete all attributes for updated products before inserting them again during incremental syncs. The catalog always includes all attributes, even if they're unchanged, so this is safe (unlike with variations.)

Test Steps

  1. Open POS and perform a full sync in settings
  2. Edit a variable parent product in wp-admin (it doesn't matter what you edit)
  3. Pull to refresh to force an incremental sync
  4. Exit POS and open it again
  5. Open the variable product
  6. Observe that all the attributes used for the variation names are not duplicated

N.B. I noticed that changes to attributes don't trigger observation updates for variation names which should change, which is why you need to exit and reopen POS to see the changes. I'll fix that separately.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@joshheald joshheald added this to the 23.8 milestone Nov 25, 2025
@joshheald joshheald added type: task An internally driven task. feature: POS labels Nov 25, 2025
@wpmobilebot
Copy link
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16399-b357920
Version23.7
Bundle IDcom.automattic.alpha.woocommerce
Commitb357920
Installation URL0ud8ud0mta2eo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

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

Good catch, worth adding this to the test plan if it hasn't yet, might uncover some other little details when testing in different stores

LGTM! 🚢

@joshheald joshheald merged commit de35e32 into trunk Nov 26, 2025
21 of 23 checks passed
@joshheald joshheald deleted the woomob-1740-local-catalog-variations-can-get-duplicated-attributes-in branch November 26, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants