public function showGallery() { $app = Yii::$app; $groups = Group::getRoots(); $products = []; if (!empty($groups)) { $default_group = $groups[0]->id; $group = $app->request->getQueryParam('group', $default_group); $products = Group::findOne($group)->linkedProducts; } return $this->renderPartial('_gallery', ['groups' => (array) $groups, 'products' => (array) $products]); }