diff --git a/models/Product.php b/models/Product.php index 658e608..6fdcffe 100755 --- a/models/Product.php +++ b/models/Product.php @@ -8,6 +8,7 @@ use artweb\artbox\ecommerce\behaviors\DefaultVariantBehavior; use artweb\artbox\behaviors\MultipleImgBehavior; use artweb\artbox\behaviors\SaveMultipleFileBehavior; + use artweb\artbox\event\models\Event; use artweb\artbox\language\behaviors\LanguageBehavior; use Yii; use yii\base\InvalidParamException; @@ -274,7 +275,20 @@ { return $this->getVariant(); } - + + + + + + /** + * @return \yii\db\ActiveQuery + */ + public function getEvents(){ + return $this->hasMany(Event::className(), ['id' => 'event_id'])->viaTable('events_to_products', ['product_id' => 'id'])->where(['status'=>Event::ACTIVE]); + } + + + /** * Get ProductVariant query fetching only available in stock to current Product * -- libgit2 0.21.4