Commit b044365b573fed715726e979384a7ccfc282e822

Authored by Administrator
1 parent a4516a4d

add variantSku

Showing 1 changed file with 21 additions and 0 deletions   Show diff stats
models/ProductVariant.php
... ... @@ -5,6 +5,7 @@
5 5 use artweb\artbox\behaviors\MultipleImgBehavior;
6 6 use artweb\artbox\behaviors\SaveMultipleFileBehavior;
7 7 use artweb\artbox\language\behaviors\LanguageBehavior;
  8 + use frontend\models\Catalog;
8 9 use Yii;
9 10 use yii\base\InvalidParamException;
10 11 use yii\db\ActiveQuery;
... ... @@ -492,4 +493,24 @@
492 493 return $option->lang->value;
493 494 }
494 495 }
  496 +
  497 + public function beforeSave($insert)
  498 + {
  499 + if (parent::beforeSave($insert)) {
  500 + Catalog::addRecord($this->product);
  501 + return true;
  502 + } else {
  503 + return false;
  504 + }
  505 + }
  506 +
  507 + public function beforeDelete()
  508 + {
  509 + if (parent::beforeDelete()) {
  510 + Catalog::deleteRecord($this->product);
  511 + return true;
  512 + } else {
  513 + return false;
  514 + }
  515 + }
495 516 }
... ...