public function actionBasket() { return $this->render(['items' => Basket::get()]); }
?> </h1> </div> <?php $ids = []; foreach (\app\modules\Shop\services\Basket::get() as $item) { $ids[] = $item['id']; } $unionRows = \app\models\Shop\Product::query(['in', 'gs_unions_shop_product.id', $ids])->innerJoin('gs_unions', 'gs_unions.id = gs_unions_shop_product.union_id')->select(['gs_unions.*'])->groupBy(['gs_unions_shop_product.union_id'])->all(); for ($i = 0; $i < count($unionRows); $i++) { $unionRows[$i]['productList'] = \app\models\Shop\Product::query(['union_id' => $unionRows[$i]['id']])->andWhere(['in', 'gs_unions_shop_product.id', $ids])->all(); for ($j = 0; $j < count($unionRows[$i]['productList']); $j++) { foreach (\app\modules\Shop\services\Basket::get() as $d) { if ($unionRows[$i]['productList'][$j]['id'] == $d['id']) { $unionRows[$i]['productList'][$j]['count'] = $d['count']; continue; } } } } ?> <table class="table table-striped table-hover"> <tr> <th> # </th> <th>