Skip to content

[8.0] Make shopifyId and shopifyGid consistent across the system #221

Merged
nfourtythree merged 14 commits into
8.0from
bugfix/8.0-shopify-id-and-gid-consistency
Jun 30, 2026
Merged

[8.0] Make shopifyId and shopifyGid consistent across the system #221
nfourtythree merged 14 commits into
8.0from
bugfix/8.0-shopify-id-and-gid-consistency

Conversation

@nfourtythree

Copy link
Copy Markdown
Contributor

Description

The plugin previously used the term "Shopify ID" inconsistently, sometimes referring to the full GID string (gid://shopify/Product/123456789), sometimes the numeric ID at the end of it. This PR makes that distinction explicit and consistent throughout.

  • The shopify_data table's shopifyId column has been renamed to shopifyGid. A new generated shopifyId column containing the numeric ID (the last segment of the GID) has been added.
  • The shopify_bulkoperations table's shopifyId column has been renamed to shopifyGid.
  • craft\shopify\models\Variant::$shopifyId now consistently holds the numeric Shopify ID. The full GID is now available via the new $shopifyGid property.
  • craft\shopify\models\BulkOperation::$shopifyId has been replaced with $shopifyGid.
  • New *ByShopifyGid() methods have been added to Products and BulkOperations services. The old *ByShopifyId() methods are deprecated and now delegate to their GID equivalents.

@nfourtythree nfourtythree self-assigned this Jun 23, 2026
@nfourtythree nfourtythree requested a review from a team as a code owner June 23, 2026 14:21

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.

Pull request overview

This PR standardizes Shopify identifier usage across the plugin by explicitly separating the full GraphQL GID (shopifyGid) from the numeric ID segment (shopifyId), and updates storage, services, jobs, and tests to match.

Changes:

  • Renames DB columns from shopifyIdshopifyGid (data + bulk operations) and introduces a generated shopifyId numeric segment column for shopify_data.
  • Updates services/jobs/models to use shopifyGid consistently, with deprecated wrappers where applicable.
  • Adds/updates unit tests and fixtures to validate the new semantics.

Reviewed changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/unit/services/ProductsTest.php Updates product deletion tests to use shopifyGid and adds delegation coverage.
tests/unit/services/BulkOperationsTest.php Updates bulk operation lookups to shopifyGid and adds delegation coverage.
tests/unit/models/VariantTest.php New tests asserting Variant exposes both shopifyGid and numeric shopifyId.
tests/unit/models/BulkOperationTest.php New tests asserting BulkOperation uses shopifyGid.
tests/unit/jobs/ProcessBulkOperationDataTest.php Updates job tests/fixtures to use shopifyGid columns and properties.
tests/unit/elements/ProductTest.php New tests for Product element shopifyId (int) + shopifyGid (string) behavior.
tests/fixtures/ShopifyDataFixture.php Fixture loader updated to insert shopifyGid.
tests/fixtures/data/shopify-data.php Fixture data keys renamed from shopifyIdshopifyGid.
tests/fixtures/data/shopify-bulk-operations.php Fixture data keys renamed from shopifyIdshopifyGid.
tests/fixtures/BulkOperationsFixture.php Fixture loader updated to set shopifyGid on models.
src/services/Products.php Adds *ByShopifyGid() APIs, deprecates *ByShopifyId(), updates deletion + metafields loading.
src/services/BulkOperations.php Adds getBulkOperationByShopifyGid() and updates internal usage to shopifyGid.
src/services/Api.php Stores Shop record id into shopifyGid instead of shopifyId.
src/records/ShopifyData.php Updates record phpdoc to include shopifyGid.
src/records/Product.php Fixes relation to join by shopifyGid.
src/records/BulkOperation.php Updates record phpdoc to shopifyGid.
src/Plugin.php Bumps schema version and updates GC query join to data.shopifyGid.
src/models/Variant.php Adds shopifyGid, clarifies numeric shopifyId, and normalizes metafields handling.
src/models/BulkOperation.php Renames model property to shopifyGid.
src/migrations/m260617_100001_rename_shopifyId_to_shopifyGid_in_bulk_operations_table.php Migration to rename bulk operations column to shopifyGid.
src/migrations/m260617_100000_rename_shopifyId_to_shopifyGid_in_data_table.php Migration to rename data column and add generated numeric shopifyId.
src/migrations/Install.php New installs create shopifyGid columns and generated numeric shopifyId.
src/jobs/ProcessBulkOperationData.php Renames job property to bulkOperationShopifyGid and updates lookups accordingly.
src/helpers/Product.php Updates data lookup to use shopifyGid.
src/helpers/Metafield.php Introduces helper to normalize metafields into key/value maps.
src/handlers/Webhook.php Webhooks now call *ByShopifyGid() service methods.
src/gql/types/Variant.php Aligns GraphQL fields with Variant model’s new shopifyId/shopifyGid semantics.
src/fieldlayoutelements/VariantsField.php Variant admin link now uses numeric shopifyId directly.
src/elements/Product.php Metafields normalization updated and deletion hook switched to deleteShopifyDataByShopifyGid().
src/elements/db/ProductQuery.php Joins against data.shopifyGid rather than data.shopifyId.
src/collections/VariantCollection.php Ensures shopifyGid is carried into Variant models.
composer.lock Updates Craft CMS dependency version.
CHANGELOG-WIP.md Documents new APIs/semantics and system-level schema changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/jobs/ProcessBulkOperationData.php
Comment thread src/jobs/ProcessBulkOperationData.php
Comment thread src/jobs/ProcessBulkOperationData.php
Comment thread src/services/Products.php
Comment thread CHANGELOG-WIP.md Outdated
nfourtythree and others added 4 commits June 30, 2026 14:01
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…m:craftcms/shopify into bugfix/8.0-shopify-id-and-gid-consistency
@nfourtythree nfourtythree merged commit d80e96d into 8.0 Jun 30, 2026
11 checks passed
@nfourtythree nfourtythree deleted the bugfix/8.0-shopify-id-and-gid-consistency branch June 30, 2026 14:32
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