-
Notifications
You must be signed in to change notification settings - Fork 30
[8.0] Make shopifyId and shopifyGid consistent across the system
#221
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f2f6a57
WIP make `shopifyId` and `shopifyGid` consistent across the system
nfourtythree 42d0c30
WIP PW tests
nfourtythree 947fd92
bump deps
nfourtythree 86ee523
Merge branch '8.0' into bugfix/8.0-shopify-id-and-gid-consistency
nfourtythree c281062
Revert "WIP PW tests"
nfourtythree 19b60ce
fix cs
nfourtythree 810561e
More tests
nfourtythree 33175e3
Metafield normalization tidy
nfourtythree 07f4688
Tweak delete product
nfourtythree 5e25d3c
bump schema version
nfourtythree bee928a
Add default for little extra security
nfourtythree 7b583af
Tweak changeling
nfourtythree c6b73c2
Tweak deprecated method
nfourtythree 32236cb
Merge branch 'bugfix/8.0-shopify-id-and-gid-consistency' of github.co…
nfourtythree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,25 @@ | ||
| # WIP Release Notes for Shopify 8.0 | ||
|
|
||
| - Shopify for Craft now requires Craft CMS 5.10.7 or later. | ||
| ### Extensibility | ||
|
|
||
| - Added `craft\shopify\models\BulkOperation::$shopifyGid`. | ||
| - Added `craft\shopify\models\Variant::$shopifyGid`. | ||
| - Added `craft\shopify\jobs\ProcessBulkOperationData::$bulkOperationShopifyGid`. | ||
| - Added `craft\shopify\services\BulkOperations::getBulkOperationByShopifyGid()`. | ||
| - Added `craft\shopify\services\Products::deleteProductByShopifyGid()`. | ||
| - Added `craft\shopify\services\Products::deleteShopifyDataByShopifyGid()`. | ||
| - Added `craft\shopify\services\Products::syncProductByShopifyGid()`. | ||
| - `craft\shopify\models\Variant::$shopifyId` now holds the numeric Shopify ID. The full GID is now available via `$shopifyGid`. | ||
| - `craft\shopify\records\ShopifyData::$shopifyId` is now a generated (read-only) column containing the numeric Shopify ID. The full GID is now available via `$shopifyGid`. | ||
| - Renamed `craft\shopify\jobs\ProcessBulkOperationData::$bulkOperationShopifyId` to `$bulkOperationShopifyGid`. | ||
| - Renamed `craft\shopify\models\BulkOperation::$shopifyId` to `$shopifyGid`. | ||
| - Deprecated `craft\shopify\services\BulkOperations::getBulkOperationByShopifyId()`. Use `getBulkOperationByShopifyGid()` instead. | ||
| - Deprecated `craft\shopify\services\Products::deleteProductByShopifyId()`. Use `deleteProductByShopifyGid()` instead. | ||
| - Deprecated `craft\shopify\services\Products::deleteShopifyDataByShopifyId()`. Use `deleteShopifyDataByShopifyGid()` instead. | ||
| - Deprecated `craft\shopify\services\Products::syncProductByShopifyId()`. Use `syncProductByShopifyGid()` instead. | ||
|
|
||
| ### System | ||
|
|
||
| - The `shopify_data` table's `shopifyId` column has been renamed to `shopifyGid`. A new generated `shopifyId` column (the numeric ID at the end of the GID) has been added. | ||
| - The `shopify_bulkoperations` table's `shopifyId` column has been renamed to `shopifyGid`. | ||
| - Shopify for Craft now requires Craft CMS 5.10.7 or later. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <?php | ||
| /** | ||
| * @link https://craftcms.com/ | ||
| * @copyright Copyright (c) Pixel & Tonic, Inc. | ||
| * @license https://craftcms.github.io/license/ | ||
| */ | ||
|
|
||
| namespace craft\shopify\helpers; | ||
|
|
||
| use craft\helpers\Json; | ||
| use craft\shopify\records\ShopifyData; | ||
|
|
||
| /** | ||
| * Shopify Metafield Helper. | ||
| * | ||
| * @author Pixel & Tonic, Inc. <support@pixelandtonic.com> | ||
| * @since 8.0.0 | ||
| */ | ||
| class Metafield | ||
| { | ||
| /** | ||
| * Normalizes an iterable of metafield data into a flat key => value map. | ||
| * | ||
| * Accepts either: | ||
| * - [[ShopifyData]] ActiveRecord objects (from [[Api::getShopifyDataByType()]] with `$returnRecords = true`), | ||
| * where each record's `data` column holds a JSON-encoded `{key, value}` object. | ||
| * - Pre-decoded associative arrays (from [[Api::getShopifyDataByType()]] without `$returnRecords`), | ||
| * where each item already has `key` and `value` keys. | ||
| * | ||
| * Rows that do not carry both `key` and `value` are silently skipped. | ||
| * | ||
| * @param iterable $rows | ||
| * @return array<string, mixed> | ||
| */ | ||
| public static function normalizeToMap(iterable $rows): array | ||
| { | ||
| return collect($rows) | ||
| ->mapWithKeys(function($d) { | ||
| $data = match (true) { | ||
| $d instanceof ShopifyData => Json::decodeIfJson($d->data), | ||
| is_string($d) => Json::decodeIfJson($d), | ||
| default => $d, | ||
| }; | ||
|
|
||
| if (!is_array($data) || !isset($data['key']) || !isset($data['value'])) { | ||
| return []; | ||
| } | ||
|
|
||
| return [$data['key'] => Json::decodeIfJson($data['value'])]; | ||
| }) | ||
| ->all(); | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.