Skip to content

[8.x] Fix images, variants and metafields syncing in reverse order - #236

Merged
nfourtythree merged 7 commits into
8.xfrom
bugfix/161-image-sort-order-8x
Oct 19, 2026
Merged

nfourtythree merged 7 commits into
8.xfrom
bugfix/161-image-sort-order-8x

Conversation

@nfourtythree

Copy link
Copy Markdown
Contributor

Description

Since 8.2.0 the bulk operation file is read from the last line to the first, so children get saved before their parent product. Child rows are now inserted in reverse Shopify order, and Api::getShopifyDataByType() was sorting by id, so Product.images (and variants and metafields) came back reversed.

Each row now stores its line index from the bulk file in a new position column, and getShopifyDataByType() sorts by position, then id. Rows without a position (anything synced before this) fall back to id, so nothing changes for them until the next sync. A re-sync fixes order for sites already affected on 8.2.0.

Added a job test that runs a product with five images through several small batches and checks they come back in file order. I also re-synced a store on the next database and checked the image order against Shopify's API and in the control panel.

Related issues

#161

@nfourtythree nfourtythree self-assigned this Oct 16, 2026
@nfourtythree
nfourtythree requested a review from a team as a code owner October 16, 2026 09:35
nfourtythree and others added 5 commits October 19, 2026 08:18
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
[7.x] Fix images, variants and metafields syncing in reverse order
# Conflicts:
#	CHANGELOG.md
#	src/Plugin.php
# Conflicts:
#	src/records/ShopifyData.php

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

Static review identified no blocking issues in the ordering logic, schema updates, or regression coverage; tests were not executed.

No open issues 🎉

What changed in this PR

Restores Shopify’s original image, variant, and metafield order during bulk syncing, addressing #161.

Changes:

  • Stores bulk-file positions and retrieves rows by position, then ID.
  • Adds the position column for existing and new installations.
  • Adds a regression test covering image order across multiple batches.
File Description
tests/​unit/​jobs/​ProcessBulkOperationDataTest.php Tests image ordering across batches.
src/​services/​Api.php Sorts by position, then ID.
src/​records/​ShopifyData.php Documents the position property.
src/​Plugin.php Bumps the schema version.
src/​migrations/​m261016_090000_add_position_to_data_table.php Adds position to existing installations.
src/​migrations/​Install.php Includes position in new installations.
src/​jobs/​ProcessBulkOperationData.php Saves each row’s bulk-file position.
CHANGELOG.md Records the ordering fix and new property.

Review effort: Balanced

@nfourtythree
nfourtythree merged commit bf0a00d into 8.x Oct 19, 2026
15 checks passed
@nfourtythree
nfourtythree deleted the bugfix/161-image-sort-order-8x branch October 19, 2026 16:29
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.

2 participants