Commit a57c9f4db5b7ab024fe7891ab91767e219891e7f
1 parent
8e0b0623
-
Showing
1 changed file
with
3 additions
and
2 deletions
Show diff stats
common/modules/product/models/Product.php
@@ -187,13 +187,14 @@ class Product extends \yii\db\ActiveRecord | @@ -187,13 +187,14 @@ class Product extends \yii\db\ActiveRecord | ||
187 | { | 187 | { |
188 | $variants = []; | 188 | $variants = []; |
189 | foreach ($this->enabledVariants as $variant) { | 189 | foreach ($this->enabledVariants as $variant) { |
190 | - $variants[$variant->product_variant_type_id][] = $variant; | 190 | + $variants[$variant->product_variant_type_id ? $variant->product_variant_type_id : 1][] = $variant; |
191 | } | 191 | } |
192 | if (empty($variants)) { | 192 | if (empty($variants)) { |
193 | return []; | 193 | return []; |
194 | } | 194 | } |
195 | + $ids = array_keys($variants); | ||
195 | $variants_type = []; | 196 | $variants_type = []; |
196 | - foreach(ProductVariantType::find()->where(['product_variant_type_id' => array_keys($variants)])->all() as $variant_type) { | 197 | + foreach(ProductVariantType::find()->select(['product_variant_type_id', 'name2'])->where(['product_variant_type_id' => $ids])->all() as $variant_type) { |
197 | $variant_type->_variants = $variants[$variant_type->product_variant_type_id]; | 198 | $variant_type->_variants = $variants[$variant_type->product_variant_type_id]; |
198 | $variants_type[] = $variant_type; | 199 | $variants_type[] = $variant_type; |
199 | } | 200 | } |