[8.0] Make shopifyId and shopifyGid consistent across the system #221
Merged
Conversation
# Conflicts: # CHANGELOG-WIP.md
This reverts commit 42d0c30.
Contributor
There was a problem hiding this comment.
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
shopifyId→shopifyGid(data + bulk operations) and introduces a generatedshopifyIdnumeric segment column forshopify_data. - Updates services/jobs/models to use
shopifyGidconsistently, 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 shopifyId → shopifyGid. |
| tests/fixtures/data/shopify-bulk-operations.php | Fixture data keys renamed from shopifyId → shopifyGid. |
| 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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.shopify_datatable'sshopifyIdcolumn has been renamed toshopifyGid. A new generatedshopifyIdcolumn containing the numeric ID (the last segment of the GID) has been added.shopify_bulkoperationstable'sshopifyIdcolumn has been renamed toshopifyGid.craft\shopify\models\Variant::$shopifyIdnow consistently holds the numeric Shopify ID. The full GID is now available via the new$shopifyGidproperty.craft\shopify\models\BulkOperation::$shopifyIdhas been replaced with$shopifyGid.*ByShopifyGid()methods have been added toProductsandBulkOperationsservices. The old*ByShopifyId()methods are deprecated and now delegate to their GID equivalents.