Compare View
Commits (2)
Showing
2 changed files
Show diff stats
common/modules/product/models/Product.php
| @@ -233,7 +233,20 @@ class Product extends \yii\db\ActiveRecord | @@ -233,7 +233,20 @@ class Product extends \yii\db\ActiveRecord | ||
| 233 | 233 | ||
| 234 | public function getOptions() { | 234 | public function getOptions() { |
| 235 | return $this->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id'])->viaTable('product_option', ['product_id' => 'product_id']); | 235 | return $this->hasMany(TaxOption::className(), ['tax_option_id' => 'option_id'])->viaTable('product_option', ['product_id' => 'product_id']); |
| 236 | -// return $this->getRelations('product_option'); | 236 | + } |
| 237 | + | ||
| 238 | + public function getProperties() { | ||
| 239 | + $groups = $options = []; | ||
| 240 | + foreach ($this->options as $option) { | ||
| 241 | + $options[$option->tax_group_id][] = $option; | ||
| 242 | + } | ||
| 243 | + foreach (TaxGroup::find()->where(['tax_group_id' => array_keys($options)])->all() as $group) { | ||
| 244 | + if (!empty($options[$group->tax_group_id])) { | ||
| 245 | + $group->_options = $options[$group->tax_group_id]; | ||
| 246 | + $groups[] = $group; | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + return $groups; | ||
| 237 | } | 250 | } |
| 238 | 251 | ||
| 239 | public function getStocks() { | 252 | public function getStocks() { |
| @@ -374,18 +387,4 @@ class Product extends \yii\db\ActiveRecord | @@ -374,18 +387,4 @@ class Product extends \yii\db\ActiveRecord | ||
| 374 | } | 387 | } |
| 375 | return $op; | 388 | return $op; |
| 376 | } | 389 | } |
| 377 | - | ||
| 378 | - public function getProperties() { | ||
| 379 | - $groups = $options = []; | ||
| 380 | - foreach ($this->options as $option) { | ||
| 381 | - $options[$option->tax_group_id][] = $option; | ||
| 382 | - } | ||
| 383 | - foreach (TaxGroup::find()->where(['tax_group_id' => array_keys($options)])->all() as $group) { | ||
| 384 | - if (!empty($options[$group->tax_group_id])) { | ||
| 385 | - $group->_options = $options[$group->tax_group_id]; | ||
| 386 | - $groups[] = $group; | ||
| 387 | - } | ||
| 388 | - } | ||
| 389 | - return $groups; | ||
| 390 | - } | ||
| 391 | } | 390 | } |
console/config/bootstrap.php
| 1 | <?php | 1 | <?php |
| 2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); | 2 | Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync'); |
| 3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); | 3 | Yii::setAlias('@uploadFileProducts', 'products.csv'); |
| 4 | -Yii::setAlias('@uploadFilePrices', 'prices.csv'); | 4 | +Yii::setAlias('@uploadFilePrices', 'file_1.csv'); |
| 5 | Yii::setAlias('@uploadFilePricesAway', 'price_product_away.csv'); | 5 | Yii::setAlias('@uploadFilePricesAway', 'price_product_away.csv'); |
| 6 | Yii::setAlias('@uploadFilePricesDuplicate', 'price_duplicate.csv'); | 6 | Yii::setAlias('@uploadFilePricesDuplicate', 'price_duplicate.csv'); |
| 7 | Yii::setAlias('@uploadFilePricesNoVariant', 'price_no_variant.csv'); | 7 | Yii::setAlias('@uploadFilePricesNoVariant', 'price_no_variant.csv'); |