From b8ce3ba6f51f7374ebf53f5bd77c4bb8dd8dfe40 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 29 Nov 2024 15:10:06 +0000 Subject: [PATCH] Tweaks --- src/Plugin.php | 2 +- ...41128_174712_fix_maxLevels_structured_productTypes.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 831b393d94..8fef95aa8d 100755 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -257,7 +257,7 @@ public static function editions(): array /** * @inheritDoc */ - public string $schemaVersion = '5.2.0.6'; + public string $schemaVersion = '5.2.7.0'; /** * @inheritdoc diff --git a/src/migrations/m241128_174712_fix_maxLevels_structured_productTypes.php b/src/migrations/m241128_174712_fix_maxLevels_structured_productTypes.php index 4ead158992..f07f69385d 100644 --- a/src/migrations/m241128_174712_fix_maxLevels_structured_productTypes.php +++ b/src/migrations/m241128_174712_fix_maxLevels_structured_productTypes.php @@ -2,8 +2,10 @@ namespace craft\commerce\migrations; +use craft\commerce\db\Table; use craft\db\Migration; use craft\db\Query; +use craft\db\Table as CraftTable; /** * m241128_174712_fix_maxLevels_structured_productTypes migration. @@ -17,14 +19,14 @@ public function safeUp(): bool { // Get all product types from Commerce project config $structuredProductTypesWithMaxLevels = (new Query()) - ->from('{{%commerce_producttypes}}') - ->where(['isStructure' => 1]) + ->from(Table::PRODUCTTYPES) + ->where(['isStructure' => true]) ->andWhere(['not', ['maxLevels' => null]]) ->collect(); // Loop through and update the `maxLevels` column in the `structures` table $structuredProductTypesWithMaxLevels->each(function($productType) { - $this->update('{{%structures}}', ['maxLevels' => $productType['maxLevels']], ['id' => $productType['structureId']]); + $this->update(CraftTable::STRUCTURES, ['maxLevels' => $productType['maxLevels']], ['id' => $productType['structureId']]); }); return true;