/** * @param $path * @throws CHttpException */ public function actionView($path) { $category = StoreCategory::model()->published()->findByPath($path); if (null === $category) { throw new CHttpException(404); } $data = Yii::app()->getRequest()->getQueryString() ? $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_CATEGORY => [$category->id]]), $this->attributeFilter->getTypeAttributesForSearchFromQuery(Yii::app()->getRequest())) : $this->productRepository->getListForCategory($category); $this->render('view', ['dataProvider' => $data, 'category' => $category]); }
/** * */ public function actionIndex() { $typesSearchParam = $this->attributeFilter->getTypeAttributesForSearchFromQuery(Yii::app()->getRequest()); $mainSearchParam = $this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => Yii::app()->getRequest()->getQuery(AttributeFilter::MAIN_SEARCH_QUERY_NAME)]); if (!empty($mainSearchParam) || !empty($typesSearchParam)) { $data = $this->productRepository->getByFilter($mainSearchParam, $typesSearchParam); } else { $data = $this->productRepository->getListForIndexPage(); } $this->render('index', ['dataProvider' => $data]); }