Commit c3c1539f4aabeb5924219a3f5b1f7af8740f557f

Authored by Yarik
1 parent 83ccbace

Tax Option fix

common/behaviors/TechBehavior.php 0 → 100644
  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 33 \ No newline at end of file
... ...
common/modules/product/controllers/ManageController.php
... ... @@ -85,6 +85,7 @@
85 85 public function actionCreate()
86 86 {
87 87 $model = new Product();
  88 + $model->detachBehavior('techSpec');
88 89 $model->generateLangs();
89 90 $product_spec = new ProductSpec();
90 91 $product_spec->generateLangs();
... ...
common/modules/product/models/Product.php
... ... @@ -4,6 +4,7 @@
4 4  
5 5 use common\behaviors\MultipleImgBehavior;
6 6 use common\behaviors\SaveMultipleFileBehavior;
  7 + use common\behaviors\TechBehavior;
7 8 use common\models\ProductCertificate;
8 9 use common\models\ProductSpec;
9 10 use common\models\ProductToRating;
... ... @@ -121,6 +122,9 @@
121 122 'language' => [
122 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 111 $group = TaxGroup::findOne($model->tax_group_id);
112 112 if($model->load(Yii::$app->request->post())) {
113 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 116 if($model->save() && $model->transactionStatus) {
117 117 return $this->redirect([
118 118 'view',
... ...
frontend/controllers/FilterController.php
... ... @@ -54,6 +54,9 @@
54 54 'tax_group.tax_group_id' => 5,
55 55 ])
56 56 ->all();
  57 +// foreach($purposes as $purpose) {
  58 +// var_dump(count($purpose->products));
  59 +// }
57 60 $brands = [];
58 61 foreach($purposes as $purpose) {
59 62 /**
... ...