Skip to content

Commit

Permalink
Only add super attributes if they're also in the flat table (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-GG authored Dec 6, 2023
1 parent bed0dd5 commit d912784
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Casts/QuoteItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function get($model, $key, $value, $attributes)
// which joins the catalog_product_super_attribute_label table.
$attributeModel = config('rapidez.models.attribute');
$superAttributes = Arr::pluck($attributeModel::getCachedWhere(function ($attribute) {
return $attribute['super'];
return $attribute['super'] && $attribute['flat'];
}), 'name', 'id');

$items = json_decode($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/MagentoSettingsHealthcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function handle()
];
}

$superAttributesCount = count($attributeModel::getCachedWhere(fn ($attribute) => $attribute['super']));
$superAttributesCount = count($attributeModel::getCachedWhere(fn ($attribute) => $attribute['super'] && $attribute['flat']));
$joinCount = ($superAttributesCount * 2) + (count($nonFlatAttributes) * 3) + 4;

if ($joinCount > 58) {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Scopes/Product/WithProductChildrenScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function apply(Builder $builder, Model $model)
$attributeModel = config('rapidez.models.attribute');

$superAttributes = Arr::pluck($attributeModel::getCachedWhere(function ($attribute) {
return $attribute['super'];
return $attribute['super'] && $attribute['flat'];
}), 'code');

$grammar = $builder->getQuery()->getGrammar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function apply(Builder $builder, Model $model)
{
$attributeModel = config('rapidez.models.attribute');
$superAttributes = Arr::pluck($attributeModel::getCachedWhere(function ($attribute) {
return $attribute['super'];
return $attribute['super'] && $attribute['flat'];
}), 'code', 'id');

$grammar = $builder->getQuery()->getGrammar();
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Traits/Product/CastSuperAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protected function getSuperAttributeCasts(): array
{
$attributeModel = config('rapidez.models.attribute');
$superAttributes = Arr::pluck($attributeModel::getCachedWhere(function ($attribute) {
return $attribute['super'];
return $attribute['super'] && $attribute['flat'];
}), 'code');

foreach ($superAttributes as $superAttribute) {
Expand Down

0 comments on commit d912784

Please sign in to comment.