Skip to content

Commit

Permalink
Merge pull request #50 from heseya/bugfix/fix-migration-creating-defa…
Browse files Browse the repository at this point in the history
…ult-channels-for-each-price-map

Fix bug in migration that creates sales channels for each currency
  • Loading branch information
daVitekPL authored Sep 4, 2024
2 parents af04dfb + e576c8a commit 9d8b5d7
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@ public function up(): void
/** @var PriceMap $priceMap */
$priceMap = PriceMap::find($case->getDefaultPriceMapId());
if ($priceMap->salesChannels->count() === 0) {
$salesChannel = SalesChannel::factory()->create([
SalesChannel::factory()->create([
'name' => 'Default channel for ' . $case->value,
'price_map_id' => $priceMap->id,
'status' => SalesChannelStatus::PRIVATE->value,
'activity' => SalesChannelActivityType::ACTIVE->value,
'default' => false,
]);
} else {
$salesChannel = $priceMap->salesChannels->first();
}

Price::query()
->where('currency', $case->value)
->where('model_type', (new Product())->getMorphClass())
->whereNull('sales_channel_id')
->update(['sales_channel_id' => $salesChannel->getKey()]);
}
}

Expand Down

0 comments on commit 9d8b5d7

Please sign in to comment.