diff --git a/models/Basket.php b/models/Basket.php index ca86649..a8eb432 100755 --- a/models/Basket.php +++ b/models/Basket.php @@ -4,6 +4,7 @@ use artbox\catalog\models\Variant; use yii\base\Component; + use yii\db\ActiveQuery; use yii\helpers\Json; use yii\web\Cookie; use yii\web\NotFoundHttpException; @@ -263,6 +264,48 @@ ->indexBy('id') ->all(); } + + public function findModelsWithOptions(array $variant_ids) + { + if (empty($variant_ids)) { + return []; + } + return Variant::find() + ->where([ 'variant.id' => $variant_ids ]) + ->joinWith( + [ + 'variantOptionExcls' => function (ActiveQuery $query) { + $query->with( + [ + 'group', + 'lang', + ] + ); + }, + ] + ) + ->joinWith('lang') + ->joinWith( + [ + 'product' => function ($query) { + /** + * @var \yii\db\ActiveQuery $query + */ + $query->with( + [ + 'lang', + 'image', + ] + ); + }, + ] + ) + ->with( + 'image' + ) + ->indexBy('id') + ->all(); + } /** * Clear basket -- libgit2 0.21.4