Commit b89bd6a361d756357dc6a9330d1bc59da4e9455b

Authored by Alexey Boroda
1 parent 4fb64eb5

26.09.16 filters change

frontend/controllers/CatalogController.php 0 → 100755
  1 +<?php
  2 +
  3 +namespace frontend\controllers;
  4 +
  5 +use common\modules\product\Filter;
  6 +use common\modules\product\helpers\ProductHelper;
  7 +use common\modules\rubrication\models\TaxOptionSearch;
  8 +use frontend\models\ProductFrontendSearch;
  9 +use Yii;
  10 +use common\modules\product\models\Brand;
  11 +use common\modules\product\models\BrandSearch;
  12 +use common\modules\product\models\Category;
  13 +use common\modules\product\models\CategorySearch;
  14 +use common\modules\product\models\Product;
  15 +use common\modules\product\models\ProductCategory;
  16 +use common\modules\product\models\ProductOption;
  17 +use common\modules\product\models\ProductSearch;
  18 +use common\modules\product\models\ProductVariant;
  19 +use common\modules\rubrication\models\TaxGroup;
  20 +use common\modules\rubrication\models\TaxOption;
  21 +use common\modules\rubrication\models\TaxValueString;
  22 +use yii\data\ActiveDataProvider;
  23 +use yii\data\Pagination;
  24 +use yii\data\Sort;
  25 +use yii\db\ActiveQuery;
  26 +use yii\helpers\ArrayHelper;
  27 +use yii\web\HttpException;
  28 +use yii\helpers\VarDumper;
  29 +
  30 +class CatalogController extends \yii\web\Controller
  31 +{
  32 + public function actionSearch() {
  33 + // @todo
  34 + }
  35 +
  36 + public function actionCategory()
  37 + {
  38 +
  39 + /** @var Category $category */
  40 + $category = Yii::$app->request->get('category');
  41 + $filter = Yii::$app->request->get('filters', [ ]);
  42 + $filter_check = $filter;
  43 +
  44 + if(empty( $category->category_id ) && empty( $word )) {
  45 + return $this->render('catalog');
  46 + }
  47 +
  48 + ProductHelper::addLastCategory($category->category_id);
  49 +
  50 + $params = [ ];
  51 +
  52 + $optionsList = ArrayHelper::getColumn(TaxGroup::find()
  53 + ->where([ 'is_filter' => 'TRUE' ])
  54 + ->all(), 'alias');
  55 +
  56 + if(!empty( $filter[ 'brands' ] )) {
  57 + unset( $filter_check[ 'brands' ] );
  58 + $brands = Brand::find()
  59 + ->select('brand_id')
  60 + ->where([
  61 + 'in',
  62 + 'alias',
  63 + $filter[ 'brands' ],
  64 + ])
  65 + ->all();
  66 + $params[ 'brands' ] = [ ];
  67 + foreach($brands as $brand) {
  68 + $params[ 'brands' ][] = $brand->brand_id;
  69 + }
  70 + }
  71 +
  72 + if(!empty( $filter[ 'special' ] )) {
  73 + unset( $filter_check[ 'special' ] );
  74 + if(!is_array($filter[ 'special' ])) {
  75 + $filter[ 'special' ] = [ $filter[ 'special' ] ];
  76 + }
  77 + if(in_array('new', $filter[ 'special' ])) {
  78 + $params[ 'special' ][ 'is_new' ] = true;
  79 + }
  80 + if(in_array('top', $filter[ 'special' ])) {
  81 + $params[ 'special' ][ 'is_top' ] = true;
  82 + }
  83 + if(in_array('promo', $filter[ 'special' ])) {
  84 + $params[ 'special' ][ 'akciya' ] = true;
  85 + }
  86 + }
  87 +
  88 + if(!empty( $filter[ 'prices' ] )) {
  89 + unset( $filter_check[ 'prices' ] );
  90 + $params[ 'prices' ] = $filter[ 'prices' ];
  91 + }
  92 +
  93 + foreach($optionsList as $optionList) {
  94 +
  95 + if(isset( $filter[ $optionList ] )) {
  96 + unset( $filter_check[ $optionList ] );
  97 + $params[ $optionList ] = $filter[ $optionList ];
  98 + }
  99 +
  100 + }
  101 +
  102 + if(!empty( $filter_check )) {
  103 + $filter = array_diff_key($filter, $filter_check);
  104 + Yii::$app->response->redirect([
  105 + 'catalog/category',
  106 + 'category' => $category,
  107 + 'filters' => $filter,
  108 + ], 301);
  109 + }
  110 +
  111 + $productModel = new ProductFrontendSearch();
  112 + //$productQuery = $productModel->getSearchQuery($category, $params);
  113 + $productProvider = $productModel->search($category, $params);
  114 +
  115 + $brandModel = new BrandSearch();
  116 + $brands = $brandModel->getBrands($category, $params)
  117 + ->all();
  118 +
  119 + $groups = $category->getActiveFilters()->all();
  120 +
  121 + $groups = ArrayHelper::index($groups, null, 'name');
  122 +
  123 + $priceLimits = $productModel->priceLimits($category, $params);
  124 +
  125 + /*
  126 + * Greedy search for comments and rating
  127 + */
  128 + $query = $productProvider->query;
  129 + $query->with([
  130 + 'variant',
  131 + 'comments',
  132 + 'averageRating',
  133 + ]);
  134 + /*
  135 + * End of greedy search for rating and comments
  136 + */
  137 + $dataProvider = new ActiveDataProvider([
  138 + 'query' => $query,
  139 + 'pagination' => [
  140 + 'pageSize' => 15,
  141 + ],
  142 + ]);
  143 +
  144 +
  145 + $products = Product::find()->joinWith('categories')
  146 + ->where([
  147 + 'category.category_id' => $category->getChildrenByDepth(2)->column(),
  148 + ]);
  149 + $productsProvider = new ActiveDataProvider([
  150 + 'query' => $products,
  151 + 'pagination' => [
  152 + 'pageSize' => 15,
  153 + ],
  154 + ]);
  155 + return $this->render('products', [
  156 + 'category' => $category,
  157 + 'brandModel' => $brandModel,
  158 + 'dataProvider' => $dataProvider,
  159 + 'brands' => $brands,
  160 + 'filter' => $filter,
  161 + 'params' => $params,
  162 + 'productModel' => $productModel,
  163 + 'productsProvider' => $dataProvider,
  164 + 'groups' => $groups,
  165 + 'priceLimits' => $priceLimits,
  166 + ]);
  167 +
  168 + }
  169 +
  170 + /**
  171 + * @param string $product
  172 + * @param string $variant
  173 + * @return string
  174 + */
  175 + public function actionProduct($product, $variant)
  176 + {
  177 +
  178 +
  179 + $product = Product::find()
  180 + ->joinWith([
  181 + 'variants' => function($query) {
  182 + $query->indexBy('sku');
  183 + }
  184 + ], true, 'INNER JOIN')
  185 + ->where([
  186 + 'product.alias' => $product,
  187 + 'product_variant.sku' => $variant,
  188 + ])->with('category.parent')->one();
  189 + $variant = $product->variants[$variant];
  190 + $variants = $product->variants;
  191 + return $this->render('view', [
  192 + 'variants' => $variants,
  193 + 'product' => $product,
  194 + 'variant' => $variant,
  195 + ]);
  196 + }
  197 +
  198 + public function actionBrands()
  199 + {
  200 + $dataProvider = new ActiveDataProvider([
  201 + 'query' => Brand::find()->orderBy('name'),
  202 + 'pagination' => [
  203 + 'pageSize' => -1,
  204 + ]
  205 + ]);
  206 +
  207 + return $this->render('brands', [
  208 + 'dataProvider' => $dataProvider,
  209 + ]);
  210 + }
  211 +
  212 + public function actionBrand($brand)
  213 + {
  214 + $brand = BrandSearch::findByAlias($brand);
  215 +
  216 + $params = [
  217 + 'brands' => $brand->brand_id,
  218 + ];
  219 +
  220 + $productModel = new ProductFrontendSearch();
  221 + $productProvider = $productModel->search(null, $params);
  222 +
  223 + $priceLimits = $productModel->priceLimits(null, $params);
  224 +
  225 + return $this->render('brand', [
  226 + 'productModel' => $productModel,
  227 + 'productProvider' => $productProvider,
  228 + 'brand' => $brand,
  229 + 'priceLimits' => $priceLimits,
  230 + ]);
  231 + }
  232 +
  233 +}
... ...
frontend/models/ProductFrontendSearch.php 0 → 100755
  1 +<?php
  2 +
  3 +namespace frontend\models;
  4 +
  5 +/**
  6 + * @var Category $category
  7 + */
  8 +
  9 +use common\modules\product\helpers\ProductHelper;
  10 +use common\modules\product\models\Category;
  11 +use common\modules\product\models\ProductCategory;
  12 +use common\modules\product\models\ProductOption;
  13 +use common\modules\rubrication\models\TaxGroup;
  14 +use common\modules\rubrication\models\TaxOption;
  15 +use Yii;
  16 +use yii\base\Model;
  17 +use yii\data\ActiveDataProvider;
  18 +use yii\db\ActiveQuery;
  19 +
  20 +use common\modules\product\models\Product;
  21 +use common\modules\product\models\ProductVariant;
  22 +
  23 +class ProductFrontendSearch extends Product {
  24 +
  25 +
  26 + public $price_interval;
  27 + public $brands;
  28 +
  29 +
  30 + /**
  31 + * @inheritdoc
  32 + */
  33 + public function rules()
  34 + {
  35 + return [
  36 + [['price_interval', 'brands'], 'safe'],
  37 + ];
  38 + }
  39 +
  40 + /**
  41 + * @inheritdoc
  42 + */
  43 + public function scenarios()
  44 + {
  45 + // bypass scenarios() implementation in the parent class
  46 + return Model::scenarios();
  47 + }
  48 +
  49 + /**
  50 + * Creates data provider instance with search query applied for frontend
  51 + *
  52 + * @param array $params
  53 + * @param Category $category
  54 + *
  55 + * @return ActiveDataProvider
  56 + */
  57 + public function search($category = null, $params = []) {
  58 +
  59 + $dataProvider = new ActiveDataProvider([
  60 + 'query' => $this->getSearchQuery($category, $params),
  61 + 'pagination' => [
  62 + 'pageSize' => 15,
  63 + ],
  64 + 'sort' => [
  65 + 'attributes' => [
  66 + 'name' => [
  67 + 'asc' => ['name' => SORT_ASC],
  68 + 'desc' => ['name' => SORT_DESC],
  69 + 'default' => SORT_DESC,
  70 + 'label' => 'имени',
  71 + ],
  72 + 'price' => [
  73 + 'asc' => [ProductVariant::tableName() .'.price' => SORT_ASC],
  74 + 'desc' => [ProductVariant::tableName() .'.price' => SORT_DESC],
  75 + 'default' => SORT_DESC,
  76 + 'label' => 'по цене',
  77 + ],
  78 + ],
  79 + ]
  80 + ]);
  81 +
  82 + if (!$this->validate()) {
  83 + return $dataProvider;
  84 + }
  85 +
  86 +
  87 +
  88 + return $dataProvider;
  89 + }
  90 +
  91 + /**
  92 + * @param null|Category $category
  93 + * @param array $params
  94 + * @return ActiveQuery
  95 + */
  96 + public function getSearchQuery($category = null, $params = []) {
  97 + if (!empty($category)) {
  98 + /** @var ActiveQuery $query */
  99 +// $query = $category->getRelations('product_categories');
  100 + $query = $category->getProducts();
  101 + } else {
  102 + $query = Product::find();
  103 + }
  104 + $query->select(['product.*']);
  105 + $query->joinWith(['enabledVariants','brand','options', 'category']);
  106 +
  107 + $query->groupBy(['product.product_id', 'product_variant.price']);
  108 +
  109 + ProductHelper::_setQueryParams($query, $params);
  110 +
  111 + $query->andWhere(['!=', ProductVariant::tableName() .'.stock', 0]);
  112 +
  113 + return $query;
  114 + }
  115 +
  116 + public function optionsForCategory($category = null, $params = []) {
  117 + $query = TaxOption::find()
  118 + ->select([
  119 + TaxOption::tableName() .'.*',
  120 + ])
  121 + ->leftJoin(ProductOption::tableName(), ProductOption::tableName() .'.option_id='. TaxOption::tableName() .'.tax_option_id')
  122 + ->joinWith('taxGroup')
  123 + ->where([TaxGroup::tableName() .'.is_filter' => true]);
  124 +
  125 + $query->innerJoin('product_variant', 'product_variant.product_id = '. ProductOption::tableName() .'.product_id');
  126 + $query->andWhere(['!=', 'product_variant.stock', 0]);
  127 + $query->groupBy(TaxOption::tableName() .'.tax_option_id');
  128 +// $query->having(['>', 'COUNT(product_variant.product_variant_id)', 0]);
  129 +
  130 + if (!empty($category)) {
  131 + $query->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. ProductOption::tableName() .'.product_id');
  132 + $query->andWhere([ProductCategory::tableName() .'.category_id' => $category->category_id]);
  133 + }
  134 +
  135 + $query->orderBy(TaxOption::tableName() .'.sort', SORT_ASC);
  136 + $query->limit(null);
  137 +
  138 +// $queryCount = ProductOption::find()
  139 +// ->select(['COUNT('. ProductOption::tableName() .'.product_id)'])
  140 +// ->where(ProductOption::tableName() .'.option_id = '. TaxOption::tableName() .'.tax_option_id');
  141 +// $queryCount->andWhere('(SELECT COUNT(pv.product_variant_id) FROM "product_variant" "pv" WHERE pv.stock != 0 AND pv.product_id = '. ProductOption::tableName() .'.product_id) > 0');
  142 +// if (!empty($category)) {
  143 +// $queryCount->andWhere('(SELECT COUNT(pc.product_id) FROM product_category pc WHERE pc.product_id = '. ProductOption::tableName() .'.product_id AND pc.category_id = '. $category->category_id .') > 0');
  144 +// }
  145 +// if (!empty($params['options'])) {
  146 +// $queryCount->innerJoin('tax_option', 'tax_option.tax_option_id = product_option.option_id');
  147 +// $queryCount->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id');
  148 +// foreach ($params['options'] as $group => $options) {
  149 +// $queryCount->andWhere([
  150 +// 'tax_group.alias' => $group,
  151 +// 'tax_option.alias' => $options
  152 +// ]);
  153 +// }
  154 +// }
  155 +// if (!empty($params['brands'])) {
  156 +// $queryCount->innerJoin(Product::tableName(), 'product.product_id='. ProductOption::tableName() .'.product_id');
  157 +// $queryCount->andWhere(['product.brand_id' => $params['brands']]);
  158 +// }
  159 +// if (!empty($params['prices'])) {
  160 +// if ($params['prices']['min'] > 0) {
  161 +// $queryCount->andWhere(['>=', 'pv.price', $params['prices']['min']]);
  162 +// }
  163 +// if ($params['prices']['max'] > 0) {
  164 +// $queryCount->andWhere(['<=', 'pv.price', $params['prices']['max']]);
  165 +// }
  166 +// }
  167 +// $query->addSelect(['_items_count' => $queryCount]);
  168 +
  169 + return $query;
  170 + }
  171 +
  172 + public function priceLimits($category = null, $params = []) {
  173 + if (!empty($category)) {
  174 + /** @var ActiveQuery $query */
  175 +// $query = $category->getRelations('product_categories');
  176 + $query = $category->getProducts();
  177 + } else {
  178 + $query = Product::find();
  179 + }
  180 + $query->joinWith('variant');
  181 +
  182 + // Price filter fix
  183 + unset($params['prices']);
  184 +
  185 + ProductHelper::_setQueryParams($query, $params, false);
  186 +
  187 +// $query->select([
  188 +// 'MIN('. ProductVariant::tableName() .'.price) AS priceMIN',
  189 +// 'MAX('. ProductVariant::tableName() .'.price) AS priceMAX',
  190 +// ]);
  191 +
  192 + return [
  193 + 'min' => $query->min(ProductVariant::tableName() .'.price'),
  194 + 'max' => $query->max(ProductVariant::tableName() .'.price'),
  195 + ];
  196 + }
  197 +}
0 198 \ No newline at end of file
... ...
frontend/views/catalog/_product_list.php 0 → 100755
  1 +<?php
  2 +
  3 +use common\components\artboximage\ArtboxImageHelper;
  4 +use common\modules\product\models\Product;
  5 +use yii\helpers\Url;
  6 +use yii\widgets\ListView;
  7 +
  8 +/**
  9 + * @var Product $model
  10 + * @var mixed $key
  11 + * @var integer $index
  12 + * @var ListView $widget
  13 + */
  14 +
  15 +?>
  16 +
  17 +<div class="col-md-4 col-sm-6">
  18 + <div class="tile_1">
  19 + <a href="<?php echo Url::to([
  20 + 'catalog/product',
  21 + 'product' => $model->alias,
  22 + 'variant' => $model->variant->sku,
  23 + ])?>">
  24 + <div class="picture" style="background-image:url('<?php
  25 + echo ArtboxImageHelper::getImageSrc($model->getImageUrl(), 'product_list_item');
  26 + ?>');"></div>
  27 + <div class="title_1"><?php echo $model->name; ?></div>
  28 + <div class="title_2"><?php echo $model->variant->sku; ?></div>
  29 + </a>
  30 + </div>
  31 +</div>
... ...
frontend/views/catalog/products.php 0 → 100755
  1 +<?php
  2 +
  3 +/**
  4 + * @var ActiveDataProvider $dataProvider
  5 + * @var View $this
  6 + * @var ActiveDataProvider $productsProvider
  7 + * @var Category $category
  8 + */
  9 +use common\modules\product\models\Category;
  10 +use yii\data\ActiveDataProvider;
  11 +use yii\web\View;
  12 +use yii\widgets\ListView;
  13 +use frontend\widgets\FilterWidget;
  14 +$this->title = $category->first_text;
  15 +$this->params['breadcrumbs'][] = $this->title;
  16 +
  17 +?>
  18 +<?= FilterWidget::widget([
  19 + 'category'=>$category,
  20 + 'groups'=> $groups,
  21 + 'filter'=> $filter,
  22 +])?>
  23 +<div class="col-md-12">
  24 + <div class="col-md-3 filters">
  25 + <div class="button1"><a href="#" class="punkt">Акции / Скидки</a></div>
  26 + <div class="filters_block">
  27 + <div class="button2">
  28 + <a href="#" class="punkt">Складская программа</a>
  29 + <div class="spoiler">
  30 + <ul>
  31 + <li><a href="#">J&V <span>/ Италия</span></a></li>
  32 + <li><a href="#">Paravox <span>/ Германия</span></a></li>
  33 + <li><a href="#">Marburg <span>/ Германия</span></a></li>
  34 + <li><a href="#">Rasch Textile <span>/ Германия</span></a></li>
  35 + <li><a href="#">Sirpi <span>/ Италия</span></a></li>
  36 + <li><a href="#">AV Design Studio</a></li>
  37 + <li><a href="#">Deco Print <span>/ Бельгия</span></a></li>
  38 + </ul>
  39 + </div>
  40 + </div>
  41 + <div class="button2">
  42 + <a href="#" class="punkt">Под заказ</a>
  43 + <div class="spoiler">
  44 + <ul>
  45 + <li><a href="#">Armani/Casa <span>/ Италия</span></a></li>
  46 + <li><a href="#">Jab Ansroetz <span>/ Германия</span></a></li>
  47 + <li><a href="#">Carlucci <span>/ Германия</span></a></li>
  48 + <li><a href="#">Chivasso <span>/ Германия</span></a></li>
  49 + <li><a href="#">Soleil Bleu <span>/ Германия</span></a></li>
  50 + <li><a href="#">Fuggerhaus <span>/ Германия</span></a></li>
  51 + <li><a href="#">Rasch <span>/ Германия</span></a></li>
  52 + <li><a href="#">Marburg <span>/ Германия</span></a></li>
  53 + <li><a href="#">Paravox <span>/ Германия</span></a></li>
  54 + <li><a href="#">BN <span>/ Италия</span></a></li>
  55 + <li><a href="#">Sirpi <span>/ Италия</span></a></li>
  56 + <li><a href="#">J&V <span>/ Бельгия</span></a></li>
  57 + <li><a href="#">Elitis <span>/ Франция</span></a></li>
  58 + <li><a href="#">Giardini <span>/ Италия</span></a></li>
  59 + <li><a href="#">Arlin <span>/ Италия</span></a></li>
  60 + <li><a href="#">Casamance <span>/ Франция</span></a></li>
  61 + <li><a href="#">Calcutta <span>/ Бельгия</span></a></li>
  62 + <li><a href="#">Sangiorgio <span>/ Италия</span></a></li>
  63 + <li><a href="#">Zuber and Cie <span>/ Франция</span></a></li>
  64 + <li><a href="#">Studio 465 <span>/ Америка</span></a></li>
  65 + <li><a href="#">Wallquest <span>/ США</span></a></li>
  66 + <li><a href="#">Eiiffinger <span>/ Голландия</span></a></li>
  67 + <li><a href="#">Arte <span>/ Бельгия</span></a></li>
  68 + <li><a href="#">Architects Paper <span>/ Германия</span></a></li>
  69 + <li><a href="#">AV Design Studio <span>/ Бельгия</span></a></li>
  70 + <li><a href="#">Cole & Son <span>/ Англия</span></a></li>
  71 + <li><a href="#">Coordonne <span>/ Испания</span></a></li>
  72 + <li><a href="#">Clarke & Clarke <span>/ Англия</span></a></li>
  73 + <li><a href="#">Designer Guilds <span>/ Англия</span></a></li>
  74 + <li><a href="#">Flocart <span>/ Бельгия</span></a></li>
  75 + <li><a href="#">Harlequin <span>/ Англия</span></a></li>
  76 + <li><a href="#">Hookedonwalls <span>/ Бельгия</span></a></li>
  77 + <li><a href="#">Hohenberger <span>/ Германия</span></a></li>
  78 + <li><a href="#">KollizArt <span>/ Германия</span></a></li>
  79 + <li><a href="#">Osborne & Little <span>/ Англия</span></a></li>
  80 + <li><a href="#">Omexco <span>/ Бельгия</span></a></li>
  81 + <li><a href="#">Print 4 <span>/ Италия</span></a></li>
  82 + <li><a href="#">Texam <span>/ Франция</span></a></li>
  83 + <li><a href="#">Thibaut <span>/ США</span></a></li>
  84 + <li><a href="#">Zambaiti Parati <span>/ Италия</span></a></li>
  85 + </ul>
  86 + </div>
  87 + </div>
  88 + <div class="title">Фильтры</div>
  89 + <div><input type="text" placeholder="Артикул"></div>
  90 + <div class="button3">
  91 + <a href="#" class="punkt">Дизайн</a>
  92 + <div class="spoiler caps">
  93 + <div class="form-group field-orderform-username">
  94 + <label class="control-label" for="orderform-username"></label>
  95 + <input type="hidden" name="OrderForm[username]" value="">
  96 + <div id="orderform-username">
  97 + <label><input type="radio" name="OrderForm[username]" value="value1">Black & White</label>
  98 + <label><input type="radio" name="OrderForm[username]" value="value2">Лофт</label>
  99 + <label><input type="radio" name="OrderForm[username]" value="value2">Прованс</label>
  100 + <label><input type="radio" name="OrderForm[username]" value="value2">Скандинавский стиль</label>
  101 + <label><input type="radio" name="OrderForm[username]" value="value2">Арт-деко</label>
  102 + <label><input type="radio" name="OrderForm[username]" value="value2">Классика</label>
  103 + <label><input type="radio" name="OrderForm[username]" value="value2">Модерн</label>
  104 + <label><input type="radio" name="OrderForm[username]" value="value2">Африканский стиль</label>
  105 + <label><input type="radio" name="OrderForm[username]" value="value2">Минимализм / Хай-тек</label>
  106 + <label><input type="radio" name="OrderForm[username]" value="value2">Детские</label>
  107 + </div>
  108 + </div>
  109 + </div>
  110 + </div>
  111 + <div class="button3">
  112 + <a href="#" class="punkt">Узор / имитация</a>
  113 + <div class="spoiler caps">
  114 + <div class="form-group field-orderform-username">
  115 + <label class="control-label" for="orderform-username"></label>
  116 + <input type="hidden" name="OrderForm[username]" value="">
  117 + <div id="orderform-username">
  118 + <label><input type="radio" name="OrderForm[username]" value="value1">Полоска</label>
  119 + <label><input type="radio" name="OrderForm[username]" value="value2">Клетка</label>
  120 + <label><input type="radio" name="OrderForm[username]" value="value2">Графика / Геометрия</label>
  121 + <label><input type="radio" name="OrderForm[username]" value="value2">Птицы / Животные</label>
  122 + <label><input type="radio" name="OrderForm[username]" value="value2">Тропики / Цветы</label>
  123 + <label><input type="radio" name="OrderForm[username]" value="value2">Индия / Пейсли</label>
  124 + <label><input type="radio" name="OrderForm[username]" value="value2">Имитация кожи</label>
  125 + <label><input type="radio" name="OrderForm[username]" value="value2">Имитация металла</label>
  126 + <label><input type="radio" name="OrderForm[username]" value="value2">Под штукатурку</label>
  127 + </div>
  128 + </div>
  129 + </div>
  130 + </div>
  131 + <div class="button3">
  132 + <a href="#" class="punkt">Материал</a>
  133 + <div class="spoiler caps">
  134 + <div class="form-group field-orderform-username">
  135 + <label class="control-label" for="orderform-username"></label>
  136 + <input type="hidden" name="OrderForm[username]" value="">
  137 + <div id="orderform-username">
  138 + <label><input type="radio" name="OrderForm[username]" value="value1">Бумажные</label>
  139 + <label><input type="radio" name="OrderForm[username]" value="value2">Виниловые</label>
  140 + <label><input type="radio" name="OrderForm[username]" value="value2">Текстильные</label>
  141 + <label><input type="radio" name="OrderForm[username]" value="value2">Флизелиновые</label>
  142 + <label><input type="radio" name="OrderForm[username]" value="value2">Бамбуковые</label>
  143 + </div>
  144 + </div>
  145 + </div>
  146 + </div>
  147 + <div class="button3">
  148 + <a href="#" class="punkt">Размер</a>
  149 + <div class="spoiler caps">
  150 + <div class="form-group field-orderform-username">
  151 + <label class="control-label" for="orderform-username"></label>
  152 + <input type="hidden" name="OrderForm[username]" value="">
  153 + <div id="orderform-username">
  154 + <label><input type="radio" name="OrderForm[username]" value="value1">М/П</label>
  155 + <label><input type="radio" name="OrderForm[username]" value="value2">1 X 10,75</label>
  156 + <label><input type="radio" name="OrderForm[username]" value="value2">0,75 X 10,05</label>
  157 + <label><input type="radio" name="OrderForm[username]" value="value2">0,70 X 10,05</label>
  158 + <label><input type="radio" name="OrderForm[username]" value="value2">0,52 X 10,05</label>
  159 + <label><input type="radio" name="OrderForm[username]" value="value2">0,685 X 8,2</label>
  160 + <label><input type="radio" name="OrderForm[username]" value="value2">Имитация кожи</label>
  161 + <label><input type="radio" name="OrderForm[username]" value="value2">Имитация металла</label>
  162 + <label><input type="radio" name="OrderForm[username]" value="value2">Под штукатурку</label>
  163 + </div>
  164 + </div>
  165 + </div>
  166 + </div>
  167 + <div class="button3">
  168 + <a class="punkt nonit" href="#">Страна</a>
  169 + <div class="spoiler caps">
  170 + <div class="form-group field-orderform-username">
  171 + <label class="control-label" for="orderform-username"></label>
  172 + <input type="hidden" name="OrderForm[username]" value="">
  173 + <div id="orderform-username">
  174 + <label><input type="radio" name="OrderForm[username]" value="value1">Германия</label>
  175 + <label><input type="radio" name="OrderForm[username]" value="value2">Италия</label>
  176 + <label><input type="radio" name="OrderForm[username]" value="value2">Испания</label>
  177 + <label><input type="radio" name="OrderForm[username]" value="value2">Бельгия</label>
  178 + <label><input type="radio" name="OrderForm[username]" value="value2">Франция</label>
  179 + <label><input type="radio" name="OrderForm[username]" value="value2">Англия</label>
  180 + <label><input type="radio" name="OrderForm[username]" value="value2">Америка</label>
  181 + <label><input type="radio" name="OrderForm[username]" value="value2">Другие страны</label>
  182 + </div>
  183 + </div>
  184 + </div>
  185 + </div>
  186 + <div class="button3">
  187 + <a class="punkt nonit" href="#">Цена</a>
  188 + <div class="spoiler">
  189 + <div class="form-group field-orderform-username">
  190 + <label class="control-label" for="orderform-username"></label>
  191 + <input type="hidden" name="OrderForm[username]" value="">
  192 + <div id="orderform-username">
  193 + <label><input type="radio" name="OrderForm[username]" value="value1">до 30 €</label>
  194 + <label><input type="radio" name="OrderForm[username]" value="value2">30 - 60 €</label>
  195 + <label><input type="radio" name="OrderForm[username]" value="value2">60 - 90 €</label>
  196 + <label><input type="radio" name="OrderForm[username]" value="value2">90-120 €</label>
  197 + <label><input type="radio" name="OrderForm[username]" value="value2">от 120 € и выше</label>
  198 + </div>
  199 + </div>
  200 + </div>
  201 + </div>
  202 + </div>
  203 + </div>
  204 + <div class="col-md-9">
  205 + <div class="blocks_2">
  206 +
  207 + <?php echo ListView::widget([
  208 + 'dataProvider' => $productsProvider,
  209 + 'itemView' => '_product_list',
  210 + 'layout' => '{items}{pager}',
  211 + ])?>
  212 +
  213 + </div>
  214 + </div>
  215 +</div>
  216 +<div class="textile_bottom">
  217 + <div class="title1 left">Стильные элитные обои для вашего дома.</div>
  218 + <div class="post_1_main">Продумывая дизайн своей квартиры, мы непременно тщательно выбираем «одежду» для стен — красивые модные обои.</div>
  219 + <div class="more"><a href="#">Узнать больше</a></div>
  220 +</div>
  221 +<div style="clear:both;"></div>
... ...
frontend/views/catalog/view.php 0 → 100755
  1 +<?php
  2 +/**
  3 + * @var Product $product
  4 + * @var ProductVariant $variant
  5 + * @var View $this
  6 + * @var ProductVariant[] $variants
  7 + */
  8 +use common\components\artboximage\ArtboxImageHelper;
  9 +use common\modules\product\models\Product;
  10 +use common\modules\product\models\ProductVariant;
  11 +use yii\helpers\Html;
  12 +use yii\helpers\Url;
  13 +use yii\web\View;
  14 +use yii\widgets\Pjax;
  15 +
  16 +$this->title = $product->name . ' - ' . $variant->sku;
  17 +$this->params['breadcrumbs'][] = [
  18 + 'label' => $product->category->parent->parent->name,
  19 + 'url' => Url::to([
  20 + 'category/index',
  21 + 'id' => $product->category->parent->parent->category_id,
  22 + ]),
  23 +];
  24 +$this->params['breadcrumbs'][] = [
  25 + 'label' => $product->category->parent->name,
  26 + 'url' => Url::to([
  27 + 'category/brand',
  28 + 'id' => $product->category->parent->category_id,
  29 + ]),
  30 +];
  31 +$this->params['breadcrumbs'][] = [
  32 + 'label' => $product->category->name,
  33 + 'url' => Url::to([
  34 + 'category/collection',
  35 + 'id' => $product->category->category_id,
  36 + ]),
  37 +];
  38 +$this->params['breadcrumbs'][] = $this->title;
  39 +
  40 +?>
  41 +
  42 +<?php Pjax::begin([
  43 + 'id' => 'pjax-reload',
  44 + 'timeout' => 5000,
  45 +]); ?>
  46 +<div class="col-md-12">
  47 + <div class="col-md-8 col-sm-12">
  48 + <div class="pic">
  49 + <?php
  50 + echo ArtboxImageHelper::getImage($variant->getImageUrl(), 'product_main');
  51 + ?>
  52 + </div>
  53 + </div>
  54 + <div class="col-lg-3 col-md-4 col-sm-12 mat-opt-list">
  55 + <div class="name1"><?php echo $product->name; ?></div>
  56 + <div class="name2"><?php echo $product->category->name; ?></div>
  57 + <div class="name3"><?php echo $product->category->parent->name; ?></div>
  58 +
  59 + <ul>
  60 + <li><span>Артикул:</span> <?php echo $variant->sku; ?></li>
  61 + <li><span>Размер:</span> 384 x 300 см</li>
  62 + <li><span>Состав:</span> 100% шелк</li>
  63 + </ul>
  64 + </div>
  65 +</div>
  66 +<div class="col-md-12 mat_pics">
  67 + <?php
  68 + foreach ($variants as $oneVariant) {
  69 + ?>
  70 + <div class="col-md-2 col-sm-3 col-xs-4 mat_pic">
  71 + <?php
  72 + echo Html::a(ArtboxImageHelper::getImage($oneVariant->getImageUrl(), 'product_variant_main'), [
  73 + 'product/view',
  74 + 'product_id' => $product->product_id,
  75 + 'variant_id' => $oneVariant->product_variant_id,
  76 + ]);
  77 + ?>
  78 + </div>
  79 + <?php } ?>
  80 +</div>
  81 +<?php Pjax::end(); ?>
... ...
frontend/widgets/FilterWidget.php 0 → 100755
  1 +<?php
  2 +namespace frontend\widgets;
  3 +
  4 +use yii\base\Widget;
  5 +
  6 +class FilterWidget extends Widget
  7 +{
  8 +
  9 + public $category;
  10 + public $groups;
  11 + public $filter;
  12 +
  13 +
  14 + public function init(){
  15 +
  16 + parent::init();
  17 +
  18 + }
  19 +
  20 +
  21 + public function run()
  22 + {
  23 +
  24 +
  25 +
  26 + return $this->render('_filter_view',[
  27 + 'category'=>$this->category,
  28 + 'groups'=>$this->groups,
  29 + 'filter'=>$this->filter,
  30 + ]);
  31 +
  32 + }
  33 +
  34 +}
  35 +?>
... ...
frontend/widgets/views/_filter_view.php 0 → 100755
  1 +<?php
  2 +use common\modules\product\helpers\FilterHelper;
  3 +use yii\helpers\Url;
  4 +use yii\web\View;
  5 +
  6 +?>
  7 +
  8 +<div class="filters">
  9 +
  10 + <div class="properties">
  11 +
  12 + <div id="filters_main" class="active_tab tab">
  13 +
  14 +
  15 + <div class="filterPanel">
  16 +
  17 + <div class="filtersList"><br />
  18 +
  19 + <div class="properties_block">
  20 + <div class="finput"><input type="text" id="finput" value="" placeholder="Артикул"></div>
  21 + <button class="sok" style="display: none;" disabled>Найти</button>
  22 + </div>
  23 +
  24 +
  25 + <div class="filterCat">
  26 +
  27 + <?php foreach($groups as $group_name => $group) :?>
  28 + <div class="properties_block closed">
  29 +
  30 + <div class="block_title"><i></i><?= $group_name?></div>
  31 +
  32 + <ul class="chechboxes" style="display: none;">
  33 + <?php foreach($group as $option) :
  34 + $checked = (isset($filter[$option['group_alias']]) && in_array($option['option_alias'], $filter[$option['group_alias']]));
  35 + $option_url = Url::to(['catalog/category', 'category' => $category, 'filters' => FilterHelper::getFilterForOption($filter, $option['group_alias'], $option['option_alias'], $checked)]);
  36 + ?>
  37 + <li>
  38 +
  39 + <input type="checkbox" onchange="document.location='<?= $option_url?>'" class="features-option" <?= $checked ? ' checked' : ''?> />
  40 + <div>
  41 + <label for="filter3278">
  42 + <a href="<?= $option_url?>"><?= $option['value']?></a>
  43 + </label>
  44 + </div>
  45 + <div class="clearfix"></div>
  46 +
  47 + </li>
  48 + <?php endforeach?>
  49 +
  50 + </ul>
  51 +
  52 +
  53 + </div>
  54 + <?php endforeach?>
  55 +
  56 + </div>
  57 +
  58 +
  59 + </div>
  60 +
  61 + </div>
  62 +
  63 +
  64 +
  65 +
  66 +
  67 + </div>
  68 +
  69 + </div>
  70 +
  71 +</div>
  72 +
  73 +<?php
  74 +
  75 +$js = "
  76 +
  77 +
  78 +
  79 + $('.properties_block').each(function(){
  80 + var block = $(this);
  81 + $(this).find('input[type=checkbox]').each(function(){
  82 + if(this.checked){
  83 + block.removeClass('closed').addClass('opened');
  84 + block.find('ul').css({\"display\":\"block\"})
  85 + return true;
  86 + }
  87 +
  88 + });
  89 +
  90 + });
  91 +
  92 + $('#finput').keyup(function() {
  93 +
  94 + var empty = false;
  95 + $('#finput').each(function() {
  96 + if ($(this).val() == '') {
  97 + empty = true;
  98 + }
  99 + });
  100 +
  101 + if (empty) {
  102 + $('.sok').attr('disabled', 'disabled').css('display','none');
  103 + } else {
  104 + $('.sok').removeAttr('disabled').css('display','inline-block');
  105 + }
  106 +
  107 + });
  108 +
  109 +
  110 +
  111 +
  112 +
  113 +
  114 + $('.price_tooltip_close').on('click',function(){
  115 + $(this).parent().hide();
  116 + });
  117 +
  118 + $('.pok').click(function(event) {
  119 + url = $('#purl').val();
  120 + price_min = $('#min_price').val();
  121 + price_max = $('#max_price').val();
  122 +
  123 + document.location.href = url + \"&pmin=\" + price_min + \"&pmax=\" + price_max;
  124 + });
  125 +
  126 + $('.sok').click(function(event) {
  127 + if ($('#finput').val() != \"Артикул\" && $('#finput').val() != \"\") {
  128 +
  129 +
  130 + document.location.href = \"/search?word=\"+$('#finput').val();
  131 +
  132 +
  133 + }
  134 + });
  135 +
  136 + ";
  137 +
  138 +
  139 +$this->registerJs($js,
  140 + View::POS_LOAD
  141 +); ?>
... ...