Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Nov 29, 2024
1 parent 5d0de8f commit b8ce3ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down

0 comments on commit b8ce3ba

Please sign in to comment.