diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php index 9a1c239..24efaa1 100755 --- a/common/modules/product/models/Category.php +++ b/common/modules/product/models/Category.php @@ -14,9 +14,7 @@ /** * This is the model class for table "category". - * * @todo Write doc for ArtboxTreeBehavior - * * @property integer $category_id * @property integer $remote_id * @property integer $parent_id @@ -24,6 +22,7 @@ * @property integer $depth * @property string $image * @property integer $product_unit_id + * @property Brand[] $activeBrands * * From language behavior * * @property CategoryLang $lang * @property CategoryLang[] $langs @@ -155,7 +154,16 @@ ->select('brand.*') ->joinWith('brand') ->groupBy('brand.brand_id'); - + } + + /** + * Improved getBrands() + * @return ActiveQuery + */ + public function getActiveBrands() + { + return $this->hasMany(Brand::className(), [ 'brand_id' => 'brand_id' ]) + ->via('products'); } public function getTaxGroupsByLevel($level) diff --git a/common/translation/ru/app.php b/common/translation/ru/app.php index e293b2f..ed53a55 100755 --- a/common/translation/ru/app.php +++ b/common/translation/ru/app.php @@ -182,4 +182,5 @@ return [ 'Поиск' => 'Поиск', 'Результаты поиска для' => 'Результаты поиска для', 'certs' => 'Сертификаты', + 'All-list ' => 'Весь ', ]; \ No newline at end of file diff --git a/common/translation/ua/app.php b/common/translation/ua/app.php index a348839..ad5a831 100755 --- a/common/translation/ua/app.php +++ b/common/translation/ua/app.php @@ -182,4 +182,5 @@ return [ 'Поиск' => 'Пошук', 'Результаты поиска для' => 'Результати пошуку для', 'certs' => 'Сертифікати', + 'All-list ' => 'Весь ', ]; \ No newline at end of file diff --git a/frontend/controllers/FilterController.php b/frontend/controllers/FilterController.php index dcfe0f8..a300a97 100755 --- a/frontend/controllers/FilterController.php +++ b/frontend/controllers/FilterController.php @@ -6,6 +6,7 @@ use common\modules\product\models\Category; use common\modules\product\models\ProductSearch; use common\modules\rubrication\models\TaxOption; + use yii\db\ActiveQuery; use yii\web\Controller; use yii\web\NotFoundHttpException; @@ -38,11 +39,13 @@ /** * Filter by type. + * * @return string */ public function actionCategory($id) { $category = $this->findCategory($id); + $brandsAll = $category->activeBrands; $purposes = TaxOption::find() ->joinWith('lang', true, 'INNER JOIN') ->joinWith([ @@ -80,14 +83,16 @@ } } return $this->render('category', [ - 'category' => $category, - 'purposes' => $purposes, - 'brands' => $brands, + 'category' => $category, + 'purposes' => $purposes, + 'brands' => $brands, + 'brandsAll' => $brandsAll, ]); } /** * Filter by purpose. + * * @return string */ public function actionPurpose($id) @@ -136,6 +141,9 @@ $searchModel = new ProductSearch(); $dataProvider = $searchModel->search(\Yii::$app->request->queryParams); $dataProvider->pagination = false; + /** + * @var ActiveQuery $query + */ $query = $dataProvider->query; $query->with('variants.lang') ->joinWith('brand.lang') @@ -155,6 +163,42 @@ ]); } + public function actionCategoryBrand($category_id, $brand_id) + { + $category = $this->findCategory($category_id); + $brand = $this->findBrand($brand_id); + $searchModel = new ProductSearch(); + $dataProvider = $searchModel->search(\Yii::$app->request->queryParams); + $dataProvider->pagination = false; + /** + * @var ActiveQuery $query + */ + $query = $dataProvider->query; + $query->with('variants.lang') + ->joinWith('brand.lang') + ->joinWith('categories.lang') + ->andWhere([ + 'category.category_id' => $category->category_id, + 'brand.brand_id' => $brand->brand_id, + ]); + return $this->render('category-brand', [ + 'category' => $category, + 'brand' => $brand, + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + public function actionCategoryBrands($category_id) + { + $category = $this->findCategory($category_id); + $brands = $category->activeBrands; + return $this->render('category-brands', [ + 'category' => $category, + 'brands' => $brands, + ]); + } + /** * @param $id * diff --git a/frontend/views/filter/category-brand.php b/frontend/views/filter/category-brand.php new file mode 100644 index 0000000..7b1d203 --- /dev/null +++ b/frontend/views/filter/category-brand.php @@ -0,0 +1,82 @@ +title = $category->lang->name . ' ' . $brand->lang->name . ' ' . mb_strtolower($purpose->lang->value); + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $category->lang->name, + 'url' => [ + 'filter/category', + 'id' => $category->category_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $purpose->lang->value, + 'url' => [ + 'filter/purpose', + 'id' => $purpose->tax_option_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $category->lang->name . ' ' . mb_strtolower($purpose->lang->value), + 'url' => [ + 'filter/index', + 'category_id' => $category->category_id, + 'purpose_id' => $purpose->tax_option_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
title ?>
+
+
+
+
+
+ getImageUrl(), 'article_list'); + ?> +
+
+
+
+ lang->seo_text; + ?> +
+
+
+ getImageUrl(), 'brand_image_filter'); + ?> +
+
+ $dataProvider, + 'itemView' => '_brand_item', + 'itemOptions' => [ + 'class' => 'brands-list_', + ], + 'options' => [ + 'class' => 'style brands-list-wr', + ], + 'layout' => '{items}', + ]); + ?> +
+
\ No newline at end of file diff --git a/frontend/views/filter/category-brands.php b/frontend/views/filter/category-brands.php new file mode 100644 index 0000000..d0d7666 --- /dev/null +++ b/frontend/views/filter/category-brands.php @@ -0,0 +1,52 @@ +title = \Yii::t('product', 'Brands').' '.$category->lang->name; + $this->params[ 'breadcrumbs' ][] = [ + 'label' => $category->lang->name, + 'url' => [ + 'filter/category', + 'id' => $category->category_id, + ], + ]; + $this->params[ 'breadcrumbs' ][] = $this->title; +?> +
title; ?>
+
+
+
+
+ getImageUrl(), 'full_filter'); + ?> +
+
+ lang->seo_text; + ?> +
+
+ +
+ +
+
+
\ No newline at end of file diff --git a/frontend/views/filter/category.php b/frontend/views/filter/category.php index 6e3ff0b..5eb9218 100755 --- a/frontend/views/filter/category.php +++ b/frontend/views/filter/category.php @@ -1,15 +1,18 @@ title = $category->lang->name; $this->params[ 'breadcrumbs' ][] = $this->title; @@ -18,6 +21,53 @@
+
+
+ lang->name), [ + 'filter/category-brands', + 'category_id' => $category->category_id, + ], [ + 'class' => 'link-cat', + 'style' => 'background-image: url("' . ArtboxImageHelper::getImageSrc($category->getImageUrl(), 'filter_image') . '")', + ]); + ?> +
+
+
    + lang->name, [ + 'filter/category-brand', + 'category_id' => $category->category_id, + 'brand_id' => $brand->brand_id, + ])); + } + ?> +
+ 5) { + ?> +
+

+ + + +
+
+
+
+ +
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index b8d2b9a..b28eb87 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -7,7 +7,7 @@ use common\models\Page; use common\modules\language\models\Language; - use common\modules\product\models\Category; + use common\modules\rubrication\models\TaxGroup; use yii\helpers\Html; use frontend\assets\AppAsset; use yii\widgets\ActiveForm; @@ -37,17 +37,23 @@ ], ]; } - $categories = Category::find() - ->joinWith('lang', true, 'INNER JOIN') - ->where([ 'depth' => 0 ]) - ->all(); + /** + * @var TaxGroup $purposes + */ + $purposes = TaxGroup::find() + ->where([ + 'tax_group.tax_group_id' => 5, + 'level' => 0, + ]) + ->joinWith('options.lang') + ->one(); $submenu_items = []; - foreach($categories as $category) { + foreach($purposes->options as $option) { $submenu_items[] = [ - 'label' => $category->lang->name, + 'label' => $option->lang->value, 'url' => [ - 'filter/category', - 'id' => $category->category_id, + 'filter/purpose', + 'id' => $option->tax_option_id, ], ]; } -- libgit2 0.21.4