-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
191 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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,24 @@ | ||
--- | ||
name: Bug Report | ||
about: Report an issue or unexpected behavior | ||
labels: | ||
- bug # Linear | ||
- Plugins # Linear | ||
- Plugins → Shopify # Linear | ||
--- | ||
|
||
### Description | ||
|
||
|
||
|
||
### Steps to reproduce | ||
|
||
1. | ||
2. | ||
|
||
### Additional info | ||
|
||
- Craft version: | ||
- PHP version: | ||
- Database driver & version: | ||
- Plugins & versions: |
This file contains 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 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 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 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
47 changes: 47 additions & 0 deletions
47
src/migrations/m240402_105857_add_metafields_property_to_variants.php
This file contains 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,47 @@ | ||
<?php | ||
|
||
namespace craft\shopify\migrations; | ||
|
||
use craft\db\Migration; | ||
use craft\db\Query; | ||
|
||
/** | ||
* m240402_105857_add_metafields_property_to_variants migration. | ||
*/ | ||
class m240402_105857_add_metafields_property_to_variants extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp(): bool | ||
{ | ||
$productRows = (new Query()) | ||
->select(['shopifyId', 'variants']) | ||
->from('{{%shopify_productdata}}') | ||
->all(); | ||
|
||
foreach ($productRows as $product) { | ||
$variants = json_decode($product['variants'], true); | ||
foreach ($variants as &$variant) { | ||
if (isset($variant['metafields'])) { | ||
continue; | ||
} | ||
|
||
$variant['metafields'] = []; | ||
} | ||
|
||
$this->update('{{%shopify_productdata}}', ['variants' => json_encode($variants)], ['shopifyId' => $product['shopifyId']]); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown(): bool | ||
{ | ||
echo "m240402_105857_add_metafields_property_to_variants cannot be reverted.\n"; | ||
return false; | ||
} | ||
} |
This file contains 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 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 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