Blame view

common/behaviors/TechBehavior.php 775 Bytes
c3c1539f   Yarik   Tax Option fix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  <?php
      
      namespace common\behaviors;
      
      use common\models\ProductSpec;
      use common\modules\product\models\Product;
      use yii\base\Behavior;
      use yii\db\ActiveRecord;
  
      /**
       * Class TechBehavior
       * @package common\behaviors
       * @property Product $owner
       */
      class TechBehavior extends Behavior
      {
          public function events()
          {
              return [
                  ActiveRecord::EVENT_AFTER_INSERT => 'afterInsert',
              ];
          }
          
          public function afterInsert($event) {
              $owner = $this->owner;
              $spec = new ProductSpec([
d9591db1   Yarik   Behavior gfix
27
                  'product_id' => $owner->product_id,
c3c1539f   Yarik   Tax Option fix
28
29
30
31
32
              ]);
              $spec->generateLangs();
              $spec->save(false);
          }
      }