Commit c3c1539f4aabeb5924219a3f5b1f7af8740f557f
1 parent
83ccbace
Tax Option fix
Showing
5 changed files
with
42 additions
and
2 deletions
Show diff stats
1 | +<?php | ||
2 | + | ||
3 | + namespace common\behaviors; | ||
4 | + | ||
5 | + use common\models\ProductSpec; | ||
6 | + use common\modules\product\models\Product; | ||
7 | + use yii\base\Behavior; | ||
8 | + use yii\db\ActiveRecord; | ||
9 | + | ||
10 | + /** | ||
11 | + * Class TechBehavior | ||
12 | + * @package common\behaviors | ||
13 | + * @property Product $owner | ||
14 | + */ | ||
15 | + class TechBehavior extends Behavior | ||
16 | + { | ||
17 | + public function events() | ||
18 | + { | ||
19 | + return [ | ||
20 | + ActiveRecord::EVENT_AFTER_INSERT => 'afterInsert', | ||
21 | + ]; | ||
22 | + } | ||
23 | + | ||
24 | + public function afterInsert($event) { | ||
25 | + $owner = $this->owner; | ||
26 | + $spec = new ProductSpec([ | ||
27 | + 'product_id' => $owner->prodcut_id, | ||
28 | + ]); | ||
29 | + $spec->generateLangs(); | ||
30 | + $spec->save(false); | ||
31 | + } | ||
32 | + } | ||
0 | \ No newline at end of file | 33 | \ No newline at end of file |
common/modules/product/controllers/ManageController.php
@@ -85,6 +85,7 @@ | @@ -85,6 +85,7 @@ | ||
85 | public function actionCreate() | 85 | public function actionCreate() |
86 | { | 86 | { |
87 | $model = new Product(); | 87 | $model = new Product(); |
88 | + $model->detachBehavior('techSpec'); | ||
88 | $model->generateLangs(); | 89 | $model->generateLangs(); |
89 | $product_spec = new ProductSpec(); | 90 | $product_spec = new ProductSpec(); |
90 | $product_spec->generateLangs(); | 91 | $product_spec->generateLangs(); |
common/modules/product/models/Product.php
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | 4 | ||
5 | use common\behaviors\MultipleImgBehavior; | 5 | use common\behaviors\MultipleImgBehavior; |
6 | use common\behaviors\SaveMultipleFileBehavior; | 6 | use common\behaviors\SaveMultipleFileBehavior; |
7 | + use common\behaviors\TechBehavior; | ||
7 | use common\models\ProductCertificate; | 8 | use common\models\ProductCertificate; |
8 | use common\models\ProductSpec; | 9 | use common\models\ProductSpec; |
9 | use common\models\ProductToRating; | 10 | use common\models\ProductToRating; |
@@ -121,6 +122,9 @@ | @@ -121,6 +122,9 @@ | ||
121 | 'language' => [ | 122 | 'language' => [ |
122 | 'class' => LanguageBehavior::className(), | 123 | 'class' => LanguageBehavior::className(), |
123 | ], | 124 | ], |
125 | + 'techSpec' => [ | ||
126 | + 'class' => TechBehavior::className(), | ||
127 | + ], | ||
124 | ]; | 128 | ]; |
125 | } | 129 | } |
126 | 130 |
common/modules/rubrication/controllers/TaxOptionController.php
@@ -111,8 +111,8 @@ | @@ -111,8 +111,8 @@ | ||
111 | $group = TaxGroup::findOne($model->tax_group_id); | 111 | $group = TaxGroup::findOne($model->tax_group_id); |
112 | if($model->load(Yii::$app->request->post())) { | 112 | if($model->load(Yii::$app->request->post())) { |
113 | $model->loadLangs(\Yii::$app->request); | 113 | $model->loadLangs(\Yii::$app->request); |
114 | - TaxOption::find() | ||
115 | - ->rebuildMP($model->tax_group_id); | 114 | +// TaxOption::find() |
115 | +// ->rebuildMP($model->tax_group_id); | ||
116 | if($model->save() && $model->transactionStatus) { | 116 | if($model->save() && $model->transactionStatus) { |
117 | return $this->redirect([ | 117 | return $this->redirect([ |
118 | 'view', | 118 | 'view', |
frontend/controllers/FilterController.php
@@ -54,6 +54,9 @@ | @@ -54,6 +54,9 @@ | ||
54 | 'tax_group.tax_group_id' => 5, | 54 | 'tax_group.tax_group_id' => 5, |
55 | ]) | 55 | ]) |
56 | ->all(); | 56 | ->all(); |
57 | +// foreach($purposes as $purpose) { | ||
58 | +// var_dump(count($purpose->products)); | ||
59 | +// } | ||
57 | $brands = []; | 60 | $brands = []; |
58 | foreach($purposes as $purpose) { | 61 | foreach($purposes as $purpose) { |
59 | /** | 62 | /** |