Commit 8724ec1fa00687f95f985093b7111fb84ae5e0f5

Authored by Karnovsky A
1 parent 10ac5ef9

-

backend/config/bootstrap.php
... ... @@ -2,4 +2,4 @@
2 2 Yii::setAlias('@uploadDir', dirname(dirname(__DIR__)) . '/storage/sync');
3 3 Yii::setAlias('@uploadFileProducts', 'products.csv');
4 4  
5   -Yii::setAlias('@productsDir', 'images/products');
6 5 \ No newline at end of file
  6 +Yii::setAlias('@productsDir', '@frontend/web/images/products');
7 7 \ No newline at end of file
... ...
backend/views/layouts/main-sidebar.php
... ... @@ -45,8 +45,8 @@ use yii\widgets\Menu;
45 45 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'],
46 46 ],
47 47 [
48   - 'label' => 'Статистика импорта',
49   - 'url' => ['/product/manage/import-stat'],
  48 + 'label' => 'Импорт товаров',
  49 + 'url' => ['/product/manage/import'],
50 50 'options' => ['class'=>\Yii::$app->user->can('product') ? '' :'hide'],
51 51 ],
52 52 ]
... ...
common/modules/product/CatalogUrlManager.php
... ... @@ -46,9 +46,9 @@ class CatalogUrlManager implements UrlRuleInterface {
46 46 // Filter
47 47 if (strpos($paths[2], 'filter:') === 0) {
48 48 $this->parseFilter($paths[2], $params);
49   - } elseif (strpos($paths[2], 'word:') === 0) {
  49 + }/* elseif (strpos($paths[2], 'word:') === 0) {
50 50 $params['word'] = substr($paths[2], 5);
51   - }
  51 + }*/
52 52 }
53 53 } elseif ($paths[0] == 'product') {
54 54 $product = ProductSearch::findByAlias($paths[1]);
... ... @@ -99,7 +99,7 @@ class CatalogUrlManager implements UrlRuleInterface {
99 99 } else {
100 100 $url = 'catalog/';
101 101 }
102   - if (!empty($params['word'])) {
  102 + /*if (!empty($params['word'])) {
103 103 if (!is_array($params['word'])) {
104 104 $params['word'] = [$params['word']];
105 105 }
... ... @@ -107,7 +107,7 @@ class CatalogUrlManager implements UrlRuleInterface {
107 107 }
108 108 if (isset($params['word'])) {
109 109 unset($params['word']);
110   - }
  110 + }*/
111 111  
112 112 $this->setFilterUrl($params, $url);
113 113  
... ...
common/modules/product/controllers/ManageController.php
... ... @@ -4,6 +4,7 @@ namespace common\modules\product\controllers;
4 4  
5 5 use common\modules\product\helpers\ProductHelper;
6 6 use common\modules\product\models\Category;
  7 +use common\modules\product\models\Import;
7 8 use common\modules\product\models\ProductImage;
8 9 use common\modules\product\models\ProductVariant;
9 10 use common\modules\product\models\RemoteProductsSearch;
... ... @@ -261,53 +262,16 @@ class ManageController extends Controller
261 262 }
262 263  
263 264 public function actionImport() {
264   - $searchModel = new RemoteProductsSearch();
265   - $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
266   -
267   - return $this->render('remote-products', [
268   - 'searchModel' => $searchModel,
269   - 'dataProvider' => $dataProvider,
270   - ]);
271   - }
  265 + $model = new Import();
272 266  
273   - public function actionImportStat() {
274   - $all_products = $new_products = $linked_products = $orpahed_products = 0;
275   - $remoteProducts = RemoteProducts::find()->all();
276   -
277   - $not_linked_cats = [];
278   -
279   - foreach($remoteProducts as $product) {
280   - if (!empty($product->product->product_id)) {
281   - $linked_products++;
282   - } elseif (!empty($product->remoteCategory) && !empty($product->remoteCategory->category) && !empty($product->remoteCategory->category->category_id)) {
283   - $new_products++;
284   - } else {
285   - if (!empty($product->remoteCategory)) {
286   - if (empty($not_linked_cats[$product->remoteCategory->ID])) {
287   - $not_linked_cats[$product->remoteCategory->ID] = $product->remoteCategory->Name ." (". $product->remoteCategory->ID .")";
288   - }
289   - }
290   - $orpahed_products++;
291   - }
292   - $all_products++;
  267 + if (Yii::$app->request->isPost) {
  268 + $file = UploadedFile::getInstances($model, 'file');
  269 + if (!empty($file[0]) && $model->validate() && $file[0]->saveAs(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFileProducts'))) {
  270 + $model->go();
293 271 }
294   -
295   - $op = [];
296   -
297   - $op[] = "Всего $all_products товаров, $new_products новых и $linked_products уже связанных.";
298   - if (!empty($not_linked_cats)) {
299   - $op[] = "$orpahed_products товаров не привязаны к категориям:";
300   - foreach ($not_linked_cats as $not_linked_cat) {
301   - $op[] = "$not_linked_cat";
302   - }
303   - }
304   -
305   - return $this->render('import-stat', [
306   - 'all_products' => $all_products,
307   - 'new_products' => $new_products,
308   - 'linked_products' => $linked_products,
309   - 'orpahed_products' => $orpahed_products,
310   - 'not_linked_cats' => $not_linked_cats,
  272 + }
  273 + return $this->render('import', [
  274 + 'model' => $model,
311 275 ]);
312 276 }
313 277  
... ...
common/modules/product/models/BrandQuery.php
... ... @@ -20,6 +20,7 @@ class BrandQuery extends \yii\db\ActiveQuery
20 20 */
21 21 public function all($db = null)
22 22 {
  23 + $this->with('brandName');
23 24 return parent::all($db);
24 25 }
25 26  
... ... @@ -29,6 +30,7 @@ class BrandQuery extends \yii\db\ActiveQuery
29 30 */
30 31 public function one($db = null)
31 32 {
  33 + $this->with('brandName');
32 34 return parent::one($db);
33 35 }
34 36  
... ...
common/modules/product/models/BrandSearch.php
... ... @@ -117,11 +117,7 @@ class BrandSearch extends Brand
117 117 }
118 118 }
119 119  
120   - $dataProvider = new ActiveDataProvider([
121   - 'query' => $query,
122   - ]);
123   -
124   - return $dataProvider;
  120 + return $query;
125 121 }
126 122  
127 123 public static function findByAlias($alias) {
... ...
common/modules/product/models/Category.php
... ... @@ -133,6 +133,11 @@ class Category extends \yii\db\ActiveRecord
133 133 return $this->hasOne(ProductUnit::className(), ['product_unit_id' => 'product_unit_id']);
134 134 }
135 135  
  136 + public function getProducts() {
  137 +// return $this->hasMany(Product::className(), ['product_id' => 'product_id'])->viaTable('product_category', ['category_id' => 'category_id']);
  138 + return $this->getRelations('product_categories');
  139 + }
  140 +
136 141 /**
137 142 * @return \yii\db\ActiveQuery
138 143 */
... ...
common/modules/product/models/CategoryQuery.php
... ... @@ -23,6 +23,7 @@ class CategoryQuery extends \yii\db\ActiveQuery
23 23 */
24 24 public function all($db = null)
25 25 {
  26 + $this->with('categoryName');
26 27 return parent::all($db);
27 28 }
28 29  
... ... @@ -32,6 +33,7 @@ class CategoryQuery extends \yii\db\ActiveQuery
32 33 */
33 34 public function one($db = null)
34 35 {
  36 +// $this->joinWith('categoryName');
35 37 return parent::one($db);
36 38 }
37 39 }
... ...
common/modules/product/models/CategorySearch.php
... ... @@ -74,15 +74,15 @@ class CategorySearch extends Category
74 74  
75 75 // grid filtering conditions
76 76 $query->andFilterWhere([
77   - 'category_id' => $this->category_id,
78   - 'parent_id' => $this->parent_id,
79   - 'category_name_id' => $this->category_name_id,
80   - 'product_unit_id' => $this->product_unit_id,
  77 + 'category.category_id' => $this->category_id,
  78 + 'category.parent_id' => $this->parent_id,
  79 + 'category.category_name_id' => $this->category_name_id,
  80 + 'category.product_unit_id' => $this->product_unit_id,
81 81 ]);
82 82  
83   - $query->andFilterWhere(['like', 'alias', $this->alias]);
  83 + $query->andFilterWhere(['like', 'category.alias', $this->alias]);
84 84  
85   - $query->orderBy(['path' => SORT_ASC, 'depth' => SORT_ASC, 'category_id' => SORT_ASC]);
  85 + $query->orderBy(['category.path' => SORT_ASC, 'category.depth' => SORT_ASC, 'category.category_id' => SORT_ASC]);
86 86  
87 87 return $dataProvider;
88 88 }
... ...
common/modules/product/models/import.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\modules\product\models;
  4 +
  5 +use common\modules\product\models\Category;
  6 +use common\modules\product\models\CategoryName;
  7 +use common\modules\product\models\ProductImage;
  8 +use common\modules\product\models\ProductVariantType;
  9 +use common\modules\rubrication\models\TaxOption;
  10 +use common\modules\rubrication\models\TaxValueString;
  11 +use Yii;
  12 +use common\modules\product\models\Brand;
  13 +use common\modules\product\models\BrandName;
  14 +use common\modules\product\models\Product;
  15 +use common\modules\product\models\ProductVariant;
  16 +use common\modules\product\models\RemoteProducts;
  17 +use yii\base\Model;
  18 +
  19 +class Import extends Model {
  20 + public $file;
  21 +
  22 + public $errors = [];
  23 + public $output = [];
  24 +
  25 + /**
  26 + * @inheritdoc
  27 + */
  28 + public function rules()
  29 + {
  30 + return [
  31 +// [['file'], 'safe'],
  32 + [['file'], 'file'],
  33 + ];
  34 + }
  35 +
  36 + /**
  37 + * @inheritdoc
  38 + */
  39 + public function attributeLabels()
  40 + {
  41 + return [
  42 + 'file' => Yii::t('product', 'File'),
  43 + ];
  44 + }
  45 +
  46 + public function go() {
  47 +
  48 + $new_products = $linked_products = 0;
  49 +
  50 + $db = yii::$app->db;
  51 +
  52 + if ( !($handle = $this->getProductsFile()) ) {
  53 + $this->errors[] = 'File not found';
  54 + return FALSE;
  55 + }
  56 +
  57 + $j = 0;
  58 +
  59 + while (($data = fgetcsv ($handle, 10000, ";")) !== FALSE)
  60 + {
  61 + $j++;
  62 + /*if ($j > 10) {
  63 + return TRUE;
  64 + }*/
  65 +
  66 + foreach ($data as &$value)
  67 + {
  68 + //$value = mb_convert_encoding ($value, "UTF-8", mb_detect_encoding ($value));
  69 + $value = iconv ('windows-1251', "UTF-8//TRANSLIT//IGNORE", $value);
  70 + $value = trim ($value);
  71 + }
  72 +
  73 + // будет всегда 19 элементов
  74 + for ($i = 0; $i <= 18; $i++)
  75 + {
  76 + if (! isset ($data[$i]))
  77 + {
  78 + $data[$i] = null;
  79 + }
  80 + }
  81 +
  82 + // 1 Группа (категория)
  83 + $catalog_name = $data[0];
  84 + if (empty ($catalog_name))
  85 + {
  86 + CONTINUE;
  87 + }
  88 +
  89 + // 2 Бренд
  90 + $brand_name = $data[1];
  91 + if (empty ($brand_name))
  92 + {
  93 + CONTINUE;
  94 + }
  95 +
  96 + // 3 Название товара
  97 + $product_name = $data[2];
  98 + if (empty ($product_name))
  99 + {
  100 + CONTINUE;
  101 + }
  102 +
  103 + // 4 Описание Укр
  104 + $product_body_uk = $data[3];
  105 +
  106 + // 5 Описание Рус
  107 + $product_body_ru = $data[4];
  108 +
  109 + // 6 Фильтр (через запятую)
  110 + $filters = explode (',', $data[5]);
  111 +
  112 + // 7 Доп фильтр через запятую
  113 + $filters_extra = explode (',', $data[6]);
  114 +
  115 + // 8 Пол череззапятую (мужской, женский, детский, унисекс)
  116 + $gender = explode (',', $data[7]);
  117 +
  118 + // 9 Год
  119 + $years = explode (',', $data[8]);
  120 +
  121 + // 10 Цена старая
  122 + $product_cost_old = $data[10];
  123 +
  124 + // 11 Цена
  125 + $product_cost = $data[9];
  126 +
  127 + // 12 Акция
  128 + $product_akciya = (bool)$data[11];
  129 +
  130 + // 13 Сопуд. Тов.
  131 + $similar = explode (',', $data[12]);
  132 +
  133 + // 14 Новинки
  134 + $product_new = (bool)$data[13];
  135 +
  136 + // 15 Топ продаж
  137 + $product_top = (bool)$data[14];
  138 +
  139 + // 16 Сетка Характеристик
  140 + $feature = explode ('=', $data[15]);
  141 +
  142 + // 17 ВИДЕО КОД
  143 + $product_video = $data[16];
  144 +
  145 + // 18 Галлерея фото
  146 + $fotos = explode (',', $data[17]);
  147 +
  148 + // 19 Штрих код товара.
  149 + // расшифровал - это модификации товара!
  150 +
  151 + $product_image = explode ('=', $data[18]);
  152 + $product_image = @$product_image[3];
  153 +
  154 + if ( ($_product = Product::find()->filterWhere(['ilike', 'name', trim($product_name)])->one()) === null ) {
  155 + $_product = new Product();
  156 + }
  157 +
  158 + $is_new_product = empty($_product->product_id);
  159 +
  160 + // ==== Set category ====
  161 + if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) === null ) {
  162 + // Create category
  163 + $category = new Category();
  164 + $category->name = trim($catalog_name);
  165 + $category->save();
  166 + }
  167 + $_product->categories = [$category->category_id];
  168 +
  169 + // ===== Set brand ====
  170 + if ( $brand_name ) {
  171 + if ( ($brand = BrandName::find()->filterWhere(['ilike', 'value', trim($brand_name)])->one()) !== null ) {
  172 + $_product->brand_id = $brand->brand_id;
  173 + } else {
  174 + // Create brand
  175 + $brand = new Brand();
  176 + $brand->name = trim($brand_name);
  177 + $brand->save();
  178 + $_product->brand_id = $brand->brand_id;
  179 + }
  180 + }
  181 +
  182 + $_product->name = $product_name;
  183 + $_product->video = $product_video;
  184 + $_product->description = $product_body_ru;
  185 + $_product->is_top = $product_top;
  186 + $_product->akciya = $product_akciya;
  187 + $_product->is_new = $product_new;
  188 +
  189 + if (!$_product->save()) {
  190 + $this->errors[] = 'Product #'. $_product->name .' not saved';
  191 + continue;
  192 + }
  193 +
  194 + // нужно для проставления характеристик относящихся к модификациям
  195 + $MOD_ARRAY = [];
  196 +
  197 + for ($i = 18; $i < count ($data); $i ++)
  198 + {
  199 + if (! empty ($data[$i]))
  200 + {
  201 + $mod_arr = explode ('=', $data[$i]);
  202 + $mod_art = $mod_arr[0];
  203 + $mod_size = $mod_arr[1];
  204 + $mod_color = $mod_arr[2];
  205 + $mod_image = $mod_arr[3];
  206 + $mod_cost = floatval($product_cost);
  207 + $mod_old_cost = floatval($product_cost_old);
  208 +
  209 + // Check product variant
  210 + if ( ($_productVariant = ProductVariant::find()->andFilterWhere(['ilike', 'sku', $mod_art])->andFilterWhere(['product_id' => $_product->product_id])->one()) === null ) {
  211 + $_productVariant = new ProductVariant();
  212 + $_productVariant->product_id = $_product->product_id;
  213 + }
  214 + $_productVariant->product_unit_id = 1;
  215 +
  216 + $_productVariant->sku = $mod_art;
  217 + $_productVariant->price = $mod_cost;
  218 + $_productVariant->price_old = $mod_old_cost;
  219 + $_productVariant->stock = 1;
  220 +
  221 + $product_variant_type_name = '';
  222 + if (! empty ($mod_color)) {
  223 + $product_variant_type_name = 'Цвет';
  224 + $_productVariant->name = $mod_color;
  225 + }
  226 + elseif (! empty ($mod_size)) {
  227 + $product_variant_type_name = 'Размер';
  228 + $_productVariant->name = $mod_size;
  229 + }
  230 +
  231 + // ===== Set variant type ====
  232 + if ( $product_variant_type_name ) {
  233 + if ( ($product_variant_type = ProductVariantType::find()->filterWhere(['ilike', 'name', $product_variant_type_name])->one()) !== null ) {
  234 + $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id;
  235 + } else {
  236 + $product_variant_type = new ProductVariantType();
  237 + $product_variant_type->name = $product_variant_type_name;
  238 + $product_variant_type->save();
  239 + $_productVariant->product_variant_type_id = $product_variant_type->product_variant_type_id;
  240 + }
  241 + }
  242 + $_productVariant->save(false);
  243 +
  244 + $MOD_ARRAY[] = $_productVariant->product_variant_id;
  245 +
  246 + if ($mod_image) {
  247 + $url = 'http://rukzachok.com.ua/upload/mod/' . urlencode($mod_image);
  248 + $image = @file_get_contents($url);
  249 + if ($image) {
  250 + if (($variantImage = ProductImage::find()->andFilterWhere(['ilike', 'image', $mod_image])->andFilterWhere(['product_variant_id' => $_productVariant->product_variant_id])->one()) === null) {
  251 + file_put_contents(Yii::getAlias('@productsDir') . "/" . $mod_image, $image);
  252 + $variantImage = new ProductImage();
  253 + $variantImage->product_id = $_product->product_id;
  254 + $variantImage->product_variant_id = $_productVariant->product_variant_id;
  255 + $variantImage->image = $mod_image;
  256 + $variantImage->save();
  257 + }
  258 + }
  259 + }
  260 + }
  261 + }
  262 +
  263 + $options = [];
  264 +
  265 + if (! empty ($filters)) {
  266 + // Set Naznachenie (tax_group_id = 20)
  267 + foreach($filters as $filter) {
  268 + $filter = trim($filter);
  269 + if (!$filter) {
  270 + continue;
  271 + }
  272 + if ( ($value = TaxValueString::find()->innerJoinWith('taxOption')->andFilterWhere(['ilike', 'value', $filter])->andFilterWhere(['tax_option.tax_group_id' => 20])->one()) === null ) {
  273 + // Create option
  274 + $option = new TaxOption();
  275 + $option->tax_group_id = 20;
  276 + $option->save();
  277 +
  278 + $value = new TaxValueString();
  279 + $value->tax_option_id = $option->tax_option_id;
  280 + $value->value = $filter;
  281 + $value->save();
  282 +
  283 + $option->default_value = $value->tax_value_id;
  284 + $option->save();
  285 + }
  286 + $options[] = $value->tax_option_id;
  287 + }
  288 + }
  289 +
  290 + if (! empty ($years)) {
  291 + // Set God (tax_group_id = 21)
  292 + foreach($years as $filter) {
  293 + $filter = trim($filter);
  294 + if (!$filter) {
  295 + continue;
  296 + }
  297 + if ( ($value = TaxValueString::find()->innerJoinWith('taxOption')->andFilterWhere(['ilike', 'value', $filter])->andFilterWhere(['tax_option.tax_group_id' => 21])->one()) === null ) {
  298 + // Create option
  299 + $option = new TaxOption();
  300 + $option->tax_group_id = 21;
  301 + $option->save();
  302 +
  303 + $value = new TaxValueString();
  304 + $value->tax_option_id = $option->tax_option_id;
  305 + $value->value = $filter;
  306 + $value->save();
  307 +
  308 + $option->default_value = $value->tax_value_id;
  309 + $option->save();
  310 + }
  311 + $options[] = $value->tax_option_id;
  312 + }
  313 + }
  314 +
  315 + if (! empty ($gender)) {
  316 + // Set Pol (tax_group_id = 22)
  317 + foreach($gender as $filter) {
  318 + $filter = trim($filter);
  319 + if (!$filter) {
  320 + continue;
  321 + }
  322 + if ( ($value = TaxValueString::find()->innerJoinWith('taxOption')->andFilterWhere(['ilike', 'value', $filter])->andFilterWhere(['tax_option.tax_group_id' => 22])->one()) === null ) {
  323 + // Create option
  324 + $option = new TaxOption();
  325 + $option->tax_group_id = 22;
  326 + $option->save();
  327 +
  328 + $value = new TaxValueString();
  329 + $value->tax_option_id = $option->tax_option_id;
  330 + $value->value = $filter;
  331 + $value->save();
  332 +
  333 + $option->default_value = $value->tax_value_id;
  334 + $option->save();
  335 + }
  336 + $options[] = $value->tax_option_id;
  337 + }
  338 + }
  339 +
  340 + if (!empty($options)) {
  341 + $_product->options = $options;
  342 + }
  343 +
  344 + $_product->save();
  345 +
  346 + $this->output[] = "$j: Product {$_product->name} #{$_product->product_id} saved (". ($is_new_product ? 'new product' : 'exists product') .")";
  347 + }
  348 +
  349 + fclose ($handle);
  350 +
  351 + return TRUE;
  352 + }
  353 +
  354 + private function getProductsFile() {
  355 + $filename = Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFileProducts');
  356 + if (!is_file($filename)) {
  357 + $this->stderr("File $filename not found");
  358 + return FALSE;
  359 + }
  360 + return fopen ($filename, 'r');
  361 + }
  362 +}
0 363 \ No newline at end of file
... ...
common/modules/product/views/manage/import.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +?>
  6 +
  7 +<div class="product-import-form">
  8 + <?php $form = ActiveForm::begin([
  9 + 'options' => ['enctype' => 'multipart/form-data']
  10 + ]); ?>
  11 +
  12 + <?php if($model->errors) :?>
  13 + <div class="error">
  14 + <?= implode("<br>\n", $model->errors);?>
  15 + </div>
  16 + <?php endif?>
  17 +
  18 + <?php if($model->output) :?>
  19 + <div class="success">
  20 + <?= implode("<br>\n", $model->output);?>
  21 + </div>
  22 + <?php endif?>
  23 +
  24 + <?= $form->field($model, 'file')->widget(\kartik\file\FileInput::classname(), [
  25 + 'language' => 'ru',
  26 + 'options' => [
  27 + 'multiple' => false,
  28 + ],
  29 + 'pluginOptions' => [
  30 + 'allowedFileExtensions' => ['csv'],
  31 + 'overwriteInitial' => true,
  32 + 'showRemove' => false,
  33 + 'showUpload' => false,
  34 + ],
  35 + ])?>
  36 +
  37 + <div class="form-group">
  38 + <?= Html::submitButton(Yii::t('product', 'Import'), ['class' => 'btn btn-primary']) ?>
  39 + </div>
  40 +
  41 + <?php ActiveForm::end(); ?>
  42 +</div>
... ...
common/modules/product/views/manage/remote-products.php deleted
1   -<?php
2   -
3   -use yii\helpers\Html;
4   -use kartik\grid\GridView;
5   -
6   -/* @var $this yii\web\View */
7   -/* @var $searchModel common\modules\product\models\RemoteProductsSearch */
8   -/* @var $dataProvider yii\data\ActiveDataProvider */
9   -
10   -$this->title = Yii::t('product', 'Remote Products');
11   -$this->params['breadcrumbs'][] = $this->title;
12   -?>
13   -<div class="remote-products-index">
14   -
15   - <h1><?= Html::encode($this->title) ?></h1>
16   - <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
17   -
18   - <p>
19   - <?= Html::a(Yii::t('product', 'Import selected'), ['import'], ['class' => 'btn btn-success']) ?>
20   - </p>
21   - <?= GridView::widget([
22   - 'dataProvider' => $dataProvider,
23   - 'filterModel' => $searchModel,
24   - 'columns' => [
25   - ['class' => 'yii\grid\SerialColumn'],
26   -
27   - 'Name',
28   - 'ID_chief',
29   - 'Article',
30   - 'Price',
31   - 'Price_old',
32   - 'Brand',
33   - 'ID',
34   - 'Date_create',
35   - 'remoteCategory.category.name',
36   - 'remoteCategory.Name',
37   - // 'local_id',
38   -
39   - ['class' => 'yii\grid\ActionColumn'],
40   - ],
41   - ]); ?>
42   -</div>
common/modules/rubrication/models/TaxOptionQuery.php
... ... @@ -23,6 +23,7 @@ class TaxOptionQuery extends \yii\db\ActiveQuery
23 23 */
24 24 public function all($db = null)
25 25 {
  26 + $this->with('value');
26 27 return parent::all($db);
27 28 }
28 29  
... ... @@ -32,6 +33,7 @@ class TaxOptionQuery extends \yii\db\ActiveQuery
32 33 */
33 34 public function one($db = null)
34 35 {
  36 + $this->with('value');
35 37 return parent::one($db);
36 38 }
37 39 }
... ...
frontend/controllers/CatalogController.php
... ... @@ -39,10 +39,13 @@ class CatalogController extends \yii\web\Controller
39 39 $word = trim(Yii::$app->request->get('word', ''));
40 40  
41 41 if (empty($category->category_id) && empty($word)) {
42   - throw new HttpException(404 ,'Page not found');
  42 + return $this->render(
  43 + 'catalog'
  44 + );
43 45 }
44 46  
45   - if (!empty($word)) {
  47 + if (!empty($word))
  48 + {
46 49 $params = [];
47 50  
48 51 $params['keywords'] = explode(' ', preg_replace("|[\s,.!:&?~();-]|i", " ", $word));
... ... @@ -75,7 +78,9 @@ class CatalogController extends \yii\web\Controller
75 78 ]
76 79 );
77 80  
78   - } else {
  81 + }
  82 + else
  83 + {
79 84 $params = [];
80 85  
81 86 if ( !empty($filter['brands']) ) {
... ... @@ -127,11 +132,11 @@ class CatalogController extends \yii\web\Controller
127 132 $productProvider = $productModel->search($category, $params);
128 133  
129 134 $brandModel = new BrandSearch();
130   - $brandProvider = $brandModel->getBrands($category, $params);
  135 + $brands = $brandModel->getBrands($category, $params)->all();
131 136  
132   - $optionsProvider = $productModel->optionsForCategory($category, $params);
  137 + $optionsQuery = $productModel->optionsForCategory($category, $params);
133 138 $groups = [];
134   - foreach ($optionsProvider->models as $option) {
  139 + foreach ($optionsQuery->all() as $option) {
135 140 if (!isset($groups[$option->tax_group_id])) {
136 141 $groups[$option->tax_group_id] = $option->taxGroup;
137 142 $groups[$option->tax_group_id]->_options = [];
... ... @@ -150,11 +155,10 @@ class CatalogController extends \yii\web\Controller
150 155 [
151 156 'category' => $category,
152 157 'brandModel' => $brandModel,
153   - 'brandProvider' => $brandProvider,
  158 + 'brands' => $brands,
154 159 'filter' => $filter,
155 160 'productModel' => $productModel,
156 161 'productProvider' => $productProvider,
157   - 'optionsProvider' => $optionsProvider,
158 162 'groups' => $groups,
159 163 'priceLimits' => $priceLimits,
160 164 ]
... ...
frontend/models/ProductFrontendSearch.php
... ... @@ -3,6 +3,8 @@
3 3 namespace frontend\models;
4 4  
5 5 use common\modules\product\models\Brand;
  6 +use common\modules\product\models\BrandName;
  7 +use common\modules\product\models\CategoryName;
6 8 use common\modules\product\models\ProductCategory;
7 9 use common\modules\product\models\ProductOption;
8 10 use common\modules\product\models\ProductSearch;
... ... @@ -47,11 +49,12 @@ class ProductFrontendSearch extends Product {
47 49 public function search($category = null, $params = []) {
48 50 if (!empty($category)) {
49 51 /** @var ActiveQuery $query */
50   - $query = $category->getRelations('product_categories');
  52 +// $query = $category->getRelations('product_categories');
  53 + $query = $category->getProducts();
51 54 } else {
52 55 $query = Product::find();
53 56 }
54   - $query->with(['variant', 'brand', 'brand.brandName', 'category', 'category.categoryName']);
  57 + $query->joinWith(['variant', 'brand', 'brand.brandName', 'category', 'category.categoryName']);
55 58  
56 59 $query->groupBy('product.product_id');
57 60  
... ... @@ -123,17 +126,14 @@ class ProductFrontendSearch extends Product {
123 126 $query->andWhere([Product::tableName() .'.brand_id' => $params['brands']]);
124 127 }
125 128  
126   - $dataProvider = new ActiveDataProvider([
127   - 'query' => $query,
128   - ]);
129   -
130   - return $dataProvider;
  129 + return $query;
131 130 }
132 131  
133 132 public function priceLimits($category = null, $params = []) {
134 133 if (!empty($category)) {
135 134 /** @var ActiveQuery $query */
136   - $query = $category->getRelations('product_categories');
  135 +// $query = $category->getRelations('product_categories');
  136 + $query = $category->getProducts();
137 137 } else {
138 138 $query = Product::find();
139 139 }
... ... @@ -158,7 +158,9 @@ class ProductFrontendSearch extends Product {
158 158 $params['keywords'] = [$params['keywords']];
159 159 }
160 160 foreach ($params['keywords'] as $keyword) {
161   - $query->andFilterWhere(['ilike', Product::tableName() .'.name', $keyword]);
  161 + $query->orFilterWhere(['ilike', Product::tableName() .'.name', $keyword]);
  162 + $query->orFilterWhere(['ilike', BrandName::tableName() .'.value', $keyword]);
  163 + $query->orFilterWhere(['ilike', CategoryName::tableName() .'.value', $keyword]);
162 164 }
163 165 }
164 166 if (!empty($params['special'])) {
... ...
frontend/views/catalog/catalog.php 0 → 100644
  1 +<?php
  2 +use yii\helpers\Url;
  3 +use yii\widgets\Breadcrumbs;
  4 +
  5 +$this->title = 'Каталог';
  6 +$this->params['breadcrumbs'][] = ['label' => 'Каталог'];
  7 +?>
  8 +
  9 +<nav class="bread-crumbs">
  10 + <?= Breadcrumbs::widget ([
  11 + 'links' => $this->params['breadcrumbs'],
  12 + ])
  13 + ?>
  14 + <div class="both"></div>
  15 +</nav>
  16 +
  17 +<div class="loyout">
  18 + <div class="content">
  19 + <h1>Каталог</h1>
  20 + <?= \frontend\widgets\Rubrics::widget(['wrapper' => 'rubrics', 'includes' => [124,125,126,127,128]])?>
  21 + </div>
  22 + <div class="both"></div>
  23 +
  24 + <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'promo'])?>
  25 + <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'new'])?>
  26 + <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'top'])?>
  27 + <?= \common\modules\product\widgets\lastProducts::widget()?>
  28 +</div>
... ...
frontend/views/catalog/product.php
... ... @@ -8,9 +8,10 @@ $this-&gt;title = $product-&gt;fullname;
8 8 //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]);
9 9 //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]);
10 10  
11   -foreach($product->category->getParents()->all() as $parent) {
12   - $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
13   -}
  11 +//foreach($product->category->getParents()->all() as $parent) {
  12 +// $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
  13 +//}
  14 +$this->params['breadcrumbs'][] = ['label' => 'Каталог', 'url' => ['catalog/category']];
14 15 $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]];
15 16 $this->params['breadcrumbs'][] = $product->fullname .' #'. $product->variant->sku;
16 17  
... ... @@ -82,13 +83,9 @@ $this-&gt;registerJs (&quot;
82 83  
83 84 <nav class="bread-crumbs">
84 85 <?= Breadcrumbs::widget ([
85   - 'links' => [
86   - ['label' => 'Каталог', 'url' => ['catalog/all']],
87   - // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]],
88   - ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]],
89   - $product->fullname,
90   - ],
91   - ]) ?>
  86 + 'links' => $this->params['breadcrumbs'],
  87 + ])
  88 + ?>
92 89 <div class="both"></div>
93 90 </nav>
94 91 <?php if ($flash = Yii::$app->session->getFlash ('success')): ?>
... ... @@ -110,7 +107,6 @@ $this-&gt;registerJs (&quot;
110 107 data-imageoriginal="<?= $variant->imageUrl ?>"
111 108 title="<?= $product->fullname ?>">
112 109 <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?>
113   -
114 110 </a>
115 111 </li>
116 112 <?php endforeach; ?>
... ...
frontend/views/catalog/product.tmp.php deleted
1   -<?php
2   -/** @var $this \yii\web\View */
3   -/** @var $dataProvider \yii\data\ActiveDataProvider */
4   -$this->title = $product->name;
5   -foreach($product->category->getParents()->all() as $parent) {
6   - $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
7   -}
8   -$this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]];
9   -$this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku;
10   -?>
11   -<h1 class="open_card_item_title"><?= $product->name .' '. $product->variant->name?></h1>
12   -
13   -<div class="item_3_blocks_wrap" id="one_item_block" data-id="<?= $product->variant->product_variant_id?>"> <!-- flex container -->
14   - <div class="item_img_block"> <!-- блок с фотографиями -->
15   - <div class="main_img">
16   - <?php if (empty($product->image)) :?>
17   - <img src="/images/no_photo_big.png" alt="<?= $product->name?>">
18   - <?php else :?>
19   - <img src="<?= $product->image->imageUrl?>" alt="<?= $product->image->alt ? $product->image->alt : $product->name?>">
20   - <?php endif?>
21   -
22   - <!--<span class="new">НОВИНКА</span>
23   - <span class="top">ТОП</span>-->
24   - </div>
25   - <div class="product_service">
26   - <ul>
27   - <li class="item1"><a id="add_to_bookmarks" href="#">Добавить в закладки</a>
28   - </li>
29   - <li class="item3"><a id="add_to_compare" href="#">Добавить в сравнение</a></li>
30   - </ul>
31   - </div>
32   - <?php if (!empty($product->images)) :?>
33   - <div class="main_img_slide">
34   - <?php foreach($product->images as $image) :?>
35   - <div class="small_img_block active">
36   - <img src="<?= $image->imageUrl?>" alt="<?= $image->alt ? $image->alt : $product->name?>">
37   - </div>
38   - <?php endforeach?>
39   -
40   - <img class="slider_arrow_right" src="/images/slider_right.png" alt="">
41   - <img class="slider_arrow_left" src="/images/slider_left.png" alt="">
42   - </div>
43   - <?php endif?>
44   -
45   - </div> <!-- конец блока с фотографиями -->
46   -
47   -
48   - <div class="busket_block"> <!-- блок с счетчиком и кнопкой добавить в корзину -->
49   - <div class="top_code">
50   - <span class="code">Код: <?= $product->variant->sku?></span>
51   - <span class="have"><img src="/images/ok_icon_green.png" alt=""><?= $product->stock !== 0 && $product->variant->price > 0 ? ' есть в наличии' : ' нет в наличии'?></span>
52   - </div>
53   -
54   - <div class="grey_bg">
55   - <div class="counter">
56   - <?php if ($product->variant->price > 0) :?>
57   - <div class="price">
58   - <?= $product->variant->price?>
59   - </div>
60   - <div class="sign">грн.</div>
61   - <?php else :?>
62   - <div class="price"></div>
63   - <?php endif?>
64   -
65   - <div class="count_block">
66   - <input type="text" name="" class="form-control buy_one_item" value="1">
67   - <div class="count_buttons">
68   - <div class="button_plus">+</div>
69   - <div class="button_minus">-</div>
70   - </div>
71   - </div>
72   - </div>
73   -
74   - <div class="in_cart_btn">
75   - <a href="#">
76   - <button class="cart_btn" data-id="<?= $product->variant->product_variant_id?>"> в корзину <img src="/images/ico_basket_white.png" alt=""></button>
77   - </a>
78   - </div>
79   -
80   - <!--<div class="to_compare_link">
81   - <img src="/images/ico_scales.png" alt="">
82   - <a href="#" class="add_to_compare">добавить к сравнению</a>
83   - </div>-->
84   - </div>
85   - <div class="quick_order">
86   - <form action="">
87   - <span class="text">БЫСТРЫЙ ЗАКАЗ</span>
88   - <input type="text" class="quick_order_phone" name="quick_order_phone" placeholder="(0XX) XXX-XX-XX">
89   - <button type="submit">заказать</button>
90   - </form>
91   - </div>
92   -
93   - <div class="delivery">
94   - <p>
95   - Доставка товара на следующий день после выставления счета. Мы доставим “День в <br> день” — уточните это у менеджера.
96   - </p>
97   - <a href="#">Подробно о доставке</a>
98   - </div>
99   -
100   - </div><!-- конец блока с счетчиком и кнопкой добавить в корзину -->
101   -
102   - <div class="character_block"> <!-- блок с характеристиками -->
103   - <?php if (!empty($properties)) :?>
104   - <h3>Характеристики</h3>
105   - <ul>
106   - <?php foreach($properties as $group) :?>
107   - <li>
108   - <div class="each">
109   - <div class="title"><?= $group->name?></div>
110   - <div class="tech">
111   - <?php foreach($group->_options as $option) :?>&nbsp;<?= $option->ValueRenderHTML?><?php endforeach?>
112   - </div>
113   - </div>
114   - </li>
115   - <?php endforeach?>
116   - </ul>
117   - <?php endif?>
118   -
119   - <!--<div class="tech_links">
120   - <a href="#">Описание</a>
121   - <a href="#">Видео</a>
122   - <a href="#">Отзывы(12)</a>
123   - </div>-->
124   -
125   - </div><!-- закрытие блока с характеристиками -->
126   - <hr>
127   -
128   - <h1 class="with_this">С этим товаром покупают</h1>
129   -
130   - <div class="flex_container"><!-- блок - с этим также покупают -->
131   -
132   - <div class="my_custom_card">
133   - <div class="new">АКЦИЯ</div>
134   - <div class="top">Toп</div>
135   - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div>
136   - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a>
137   - <div class="brand">Бренд: <span>Knauf</span></div>
138   - <div class="type">Штукатурки</div>
139   - <div class="price">102.05 <span>грн.</span></div>
140   - <button class="basket_add_but">в корзину</button>
141   - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a>
142   - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt="">
143   - </div>
144   -
145   - <div class="my_custom_card">
146   - <div class="new">АКЦИЯ</div>
147   - <div class="top">Toп</div>
148   - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div>
149   - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a>
150   - <div class="brand">Бренд: <span>Knauf</span></div>
151   - <div class="type">Штукатурки</div>
152   - <div class="price">102.05 <span>грн.</span></div>
153   - <button class="basket_add_but">в корзину</button>
154   - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a>
155   - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt="">
156   - </div>
157   -
158   - <div class="my_custom_card">
159   - <div class="new">АКЦИЯ</div>
160   - <div class="top">Toп</div>
161   - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div>
162   - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a>
163   - <div class="brand">Бренд: <span>Knauf</span></div>
164   - <div class="type">Штукатурки</div>
165   - <div class="price">102.05 <span>грн.</span></div>
166   - <button class="basket_add_but">в корзину</button>
167   - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a>
168   - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt="">
169   - </div>
170   -
171   - <div class="my_custom_card">
172   - <div class="new">АКЦИЯ</div>
173   - <div class="top">Toп</div>
174   - <a href="#" class="item_link"><div class="pic"><img src="/images/no_photo.png"></div>
175   - <div class="title_item">Штукатурка гипсовая Кнауф Ротбанд 30 кг белая</div></a>
176   - <div class="brand">Бренд: <span>Knauf</span></div>
177   - <div class="type">Штукатурки</div>
178   - <div class="price">102.05 <span>грн.</span></div>
179   - <button class="basket_add_but">в корзину</button>
180   - <a href="#" class="compare_add_but"><span>добавить к сравнению</span></a>
181   - <img class="item_bottom_img" src="/images/nc_item_bottom.png" alt="">
182   - </div>
183   -
184   - </div> <!-- конец блока - с этим также покупают -->
185   - <div class="tabs_block"> <!-- Табы с описанием видео и отзывами -->
186   - <div class="ionTabs" id="tabs_1" data-name="Tabs_Group_name">
187   - <ul class="ionTabs__head">
188   - <?php if (!empty($properties)) :?>
189   - <li class="ionTabs__tab" data-target="Tab_1_name">Характеристики</li>
190   - <?php endif?>
191   - <?php if (TRUE || !empty($product->description)) :?>
192   - <li class="ionTabs__tab" data-target="Tab_2_name">Описание</li>
193   - <?php endif?>
194   - <?php if (TRUE || !empty($product->video)) :?>
195   - <li class="ionTabs__tab" data-target="Tab_3_name">Видео</li>
196   - <?php endif?>
197   -<!-- <li class="ionTabs__tab" data-target="Tab_4_name">Отзывы(12)</li>-->
198   - </ul>
199   - <div class="ionTabs__body">
200   - <?php if (!empty($properties)) :?>
201   - <div class="ionTabs__item character_block" data-name="Tab_1_name">
202   - <ul>
203   - <?php foreach($properties as $group) :?>
204   - <li>
205   - <div class="each">
206   - <div class="title"><?= $group->name?></div>
207   - <div class="tech">
208   - <?php foreach($group->_options as $option) :?>&nbsp;<?= $option->ValueRenderHTML?><?php endforeach?>
209   - </div>
210   - </div>
211   - </li>
212   - <?php endforeach?>
213   - </ul>
214   - </div>
215   - <?php else :?>
216   - <?php endif?>
217   - <?php if (!empty($product->description)) :?>
218   - <div class="ionTabs__item" data-name="Tab_2_name">
219   - <?= $product->description?>
220   - </div>
221   - <?php endif?>
222   - <?php if (!empty($product->video)) :?>
223   - <div class="ionTabs__item" data-name="Tab_3_name">
224   - <?= $product->video?>
225   - </div>
226   - <?php endif?>
227   -
228   - <div class="ionTabs__preloader"></div>
229   - </div>
230   - </div>
231   -
232   - </div> <!-- конец табов с описанием видео и отзывами -->
233   - <div style="clear: both;"></div>
234   -
235   - <?php if(!empty($last_products)) :?>
236   - <hr>
237   - <div class="watched_block">
238   - <h1>Вы недавно просматривали</h1>
239   - <div class="flex-container">
240   - <?php foreach($last_products as $product) :?>
241   - <?php require(__DIR__ .'/product_smart.php')?>
242   - <?php endforeach?>
243   - </div>
244   - </div>
245   - <?php endif?>
246   -
247   -</div> <!-- end flex container -->
frontend/views/catalog/products.old.php deleted
1   -<?php
2   -/** @var $this \yii\web\View */
3   -/** @var $dataProvider \yii\data\ActiveDataProvider */
4   -
5   -$this->title = $category->categoryName->value;
6   -foreach($category->getParents()->all() as $parent) {
7   - $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'alias' => $parent->alias]];
8   -}
9   -$this->params['breadcrumbs'][] = $category->categoryName->value;
10   -?>
11   -<script type="text/javascript">
12   - $(document).ready(function() {
13   - // price rangeslider (filter price slider)
14   - $("#price_interval").ionRangeSlider({
15   - type: "double",
16   - min: <?= $priceMin?>,
17   - max: <?= $priceMax?>,
18   - from: <?= $priceMinCurr?>,
19   - to: <?= $priceMaxCurr?>,
20   - grid: false
21   - });
22   - });
23   -</script>
24   -<div class="w_960">
25   - <!-- side bar with all filters -->
26   - <div class="cat_p_filter_bar">
27   - <div class="title">ФИЛЬТРЫ</div>
28   - <div class="filter_list">
29   - <form action="#" name="filter_catalog_page_form">
30   - <ul>
31   - <li>Цена:
32   - <div class="arrow"><img src="/images/head_up.png" alt=""></i></div>
33   - <div class="price_filter first_price_li">
34   - <div class="price_slider">
35   - <input type="text" id="price_interval" name="price_interval" value="" />
36   - </div>
37   - <!--<div class="checkbox">
38   - <label><input type="checkbox" name="venecia" value="0" /></label>
39   - <a href="#">Акции</a>
40   - </div>
41   - <div class="checkbox">
42   - <label><input type="checkbox" name="venecia" value="0" /></label>
43   - <a href="#">Товар в наличии</a>
44   - </div>
45   - <div class="checkbox">
46   - <label><input type="checkbox" name="venecia" value="0" /></label>
47   - <a href="#">Хит продаж</a>
48   - </div>-->
49   - </div>
50   - </li>
51   -
52   - <?php if ($brands_count) :?>
53   - <li>Бренд
54   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
55   - <div class="price_filter<?= !empty($_brands)?' active-field':''?>">
56   - <?php foreach($brands as $brand) :?>
57   - <div class="checkbox">
58   - <label><input type="checkbox" name="brand[]" value="<?= $brand->alias?>"<?= isset($_GET['brand']) && in_array($brand->alias, $_GET['brand']) ? ' checked' : ''?> /></label>
59   - <a href="#<?php /*= \yii\helpers\Url::to(['brand', 'alias' => $brand->alias])*/?>"><?= $brand->name?><!-- (<?php /*= $brand->getProducts()->count()*/?>)--></a>
60   - </div>
61   - <?php endforeach?>
62   - <!--<div class="checkbox see_all">
63   - <i class="fa fa-plus-circle"></i>
64   - <a href="#">посмотреть все</a>
65   - </div>-->
66   - </div>
67   - </li>
68   - <?php endif?>
69   -
70   - <?php if (!empty($groups)) :?>
71   - <div class="title_2">ПОДБОР ПО ПАРАМЕТРАМ</div>
72   -
73   - <?php foreach($groups as $group) :?>
74   - <li><?= $group->name?>
75   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
76   - <div class="price_filter<?= isset($options[$group->alias])?' active-field':''?>">
77   - <?php foreach($group->_options as $option) :?>
78   - <div class="checkbox">
79   - <label><input type="checkbox" name="option[<?= $group->alias?>][]" value="<?= $option->alias?>"<?= (isset($options[$group->alias]) && in_array($option->alias, $options[$group->alias])) ? ' checked' : ''?> /></label>
80   - <a href="#"><?= $option->ValueRenderHTML?>&nbsp;(<?= $option->_items_count?>)</a>
81   - </div>
82   - <?php endforeach?>
83   - </div>
84   - </li>
85   - <?php endforeach?>
86   - <?php endif?>
87   -
88   - </ul>
89   -
90   - <div class="filter_accept_bloc">
91   - <button type="submit" class="filter_accept_btn">применить</button>
92   - <a href="#" class="form_checkbox_reset">сбросить фильтры</a>
93   - </div>
94   - </form>
95   - <!--<div class="product_list">
96   - <h2 class="title">КАТАЛОГ ТОВАРОВ</h2>
97   - <ul>
98   - <li>Битумная черепица
99   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
100   - <div class="price_filter">
101   - <a href="#">RUUKI</a>
102   - <a href="#">Venecia</a>
103   - </div>
104   - </li>
105   -
106   - <li>Комплектация кровли
107   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
108   - <div class="price_filter">
109   - <a href="#">RUUKI</a>
110   - <a href="#">Venecia</a>
111   - </div>
112   - </li>
113   -
114   - <li>Водосточные системы
115   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
116   - <div class="price_filter">
117   - <a href="#">RUUKI</a>
118   - <a href="#">Venecia</a>
119   - </div>
120   - </li>
121   -
122   - <li>Чердачные лестницы
123   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
124   - <div class="price_filter">
125   - <a href="#">RUUKI</a>
126   - <a href="#">Venecia</a>
127   - </div>
128   - </li>
129   -
130   - <li>Мансардные окна
131   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
132   - <div class="price_filter">
133   - <a href="#">RUUKI</a>
134   - <a href="#">Venecia</a>
135   - </div>
136   - </li>
137   -
138   - <li>Металлочерепица
139   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
140   - <div class="price_filter">
141   - <a href="#">RUUKI</a>
142   - <a href="#">Venecia</a>
143   - </div>
144   - </li>
145   -
146   - <li>Плоская кровля
147   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
148   - <div class="price_filter">
149   - <a href="#">RUUKI</a>
150   - <a href="#">Venecia</a>
151   - </div>
152   - </li>
153   -
154   - <li>Профнастил
155   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
156   - <div class="price_filter">
157   - <a href="#">RUUKI</a>
158   - <a href="#">Venecia</a>
159   - </div>
160   - </li>
161   -
162   - <li>Ондулин
163   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
164   - <div class="price_filter">
165   - <a href="#">RUUKI</a>
166   - <a href="#">Venecia</a>
167   - </div>
168   - </li>
169   -
170   - <li>OSB плиты
171   - <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
172   - <div class="price_filter">
173   - <a href="#">RUUKI</a>
174   - <a href="#">Venecia</a>
175   - </div>
176   - </li>
177   -
178   - </ul>
179   - </div>-->
180   - </div>
181   -
182   -
183   - </div>
184   -
185   - <!-- catalog list with all item cards -->
186   - <div class="cat_p_catalog_list">
187   - <div class="title"><?= $category->categoryName->value?> <span>(<?= $all_count?>)</span></div>
188   -
189   - <?php if (empty($products)) :?>
190   - <h2>По данному запросу товары не найдены.</h2><br>
191   - <p>Показать <a href="<?= \yii\helpers\Url::to(['catalog/category', 'alias' => $category->alias])?>">все товары из категории "<?= $category->categoryName->value?>"</a></p>
192   - <?php else :?>
193   - <!-- sort menu -->
194   - <div class="sort_menu">
195   -
196   - <div class="sort_price">
197   - <span>Сортировка:</span>
198   - <?= \yii\widgets\LinkSorter::widget([
199   - 'sort' => $sort,
200   - 'attributes' => [
201   - 'name',
202   - 'price',
203   - ]
204   - ]);
205   - ?>
206   - <!--
207   - <select name="sort_price" id="" class="sort_price_select">
208   - <option value="price">по цене</option>
209   - <option value="popular">новые</option>
210   - <option value="sale">по акции</option>
211   - </select>
212   - <i class="fa fa-angle-down"></i>-->
213   - </div>
214   -
215   - <div class="show">
216   - <!--<span>Показывать по:</span>
217   - <ul>
218   - <li><a class="active" href="#">24</a></li>
219   - <li><a href="#">48</a></li>
220   - <li><a href="#">96</a></li>
221   - </ul>-->
222   - </div>
223   -
224   - <div class="show_pages">
225   - <?php if ($pages->totalCount > $pages->pageSize) :?>
226   - <span>Страница:</span>
227   - <?= \yii\widgets\LinkPager::widget([
228   - 'pagination' => $pages,
229   - 'options' => ['class' => 'pagination pull-right'],
230   - ]);
231   - ?>
232   - <!--<i class="fa fa-caret-right"></i>-->
233   - <?php endif?>
234   - </div>
235   -
236   - </div>
237   -
238   -
239   - <div class="cat_p_item_card_list">
240   - <div class="novelty">
241   - <div class="content">
242   - <div class="novelty_cont">
243   - <?php foreach($products as $product) :?>
244   - <?php require(__DIR__ .'/product_item.php')?>
245   - <?php endforeach?>
246   - </div>
247   -
248   - <?php if ($pages->totalCount > $pages->pageSize) :?>
249   - <!-- LOAD MORE BUTTON -->
250   - <!--button class="load_more_btn">Загрузить еще <?= $per_page?> товара</button-->
251   -
252   - <div class="show_pages">
253   - Страница:
254   - <?= \yii\widgets\LinkPager::widget([
255   - 'pagination' => $pages,
256   - 'options' => ['class' => 'pagination pull-right'],
257   - ]);
258   - ?>
259   - <!--<i class="fa fa-caret-right"></i>-->
260   - </div>
261   - <?php endif?>
262   - <hr>
263   -
264   - <?php if(!empty($category->description)) :?>
265   - <div class="description">
266   - <?= $category->description?>
267   -
268   - <div class="empty_padding_400"></div>
269   - </div>
270   - <?php endif?>
271   - </div>
272   - </div>
273   - </div>
274   -
275   - <?php endif?>
276   - </div>
277   -</div>
278   -
frontend/views/catalog/products.php
1 1 <?php
2 2 /** @var $this \yii\web\View */
3 3 /** @var $productProvider \yii\data\ActiveDataProvider */
4   -/** @var $brandProvider \yii\data\ActiveDataProvider */
5 4  
6 5  
7 6 use yii\helpers\Url;
... ... @@ -10,9 +9,10 @@ use yii\web\View;
10 9 use common\modules\product\helpers\ProductHelper;
11 10  
12 11 $this->title = $category->categoryName->value;
13   -foreach($category->getParents()->all() as $parent) {
14   - $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
15   -}
  12 +//foreach($category->getParents()->all() as $parent) {
  13 +// $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
  14 +//}
  15 +$this->params['breadcrumbs'][] = ['label' => 'Каталог', 'url' => ['catalog/category']];
16 16 $this->params['breadcrumbs'][] = $category->categoryName->value;
17 17  
18 18 $this->params['seo']['title'] = $category->name;
... ... @@ -102,11 +102,11 @@ $this-&gt;registerJsFile (Yii::getAlias(&#39;@web/js/ion.rangeSlider.js&#39;));
102 102 <a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a>
103 103 </div>
104 104 <?php endif?>
105   - <?php if ($brandProvider->totalCount > 0) :?>
  105 + <?php if ($brands) :?>
106 106 <div class="filters">
107 107 <div class="begin">Бренды</div>
108 108 <ul>
109   - <?php foreach($brandProvider->models as $brand) :
  109 + <?php foreach($brands as $brand) :
110 110 $checked = !empty($filter['brands']) && in_array($brand->alias, $filter['brands']);
111 111 $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'brands', $brand->alias, $checked)]);
112 112 ?>
... ...
frontend/views/catalog/search.php
... ... @@ -11,116 +11,62 @@ $page_data = [
11 11 'keywords' => implode(' ', $keywords),
12 12 ];
13 13  
  14 +$this->params['breadcrumbs'][] = ['label' => 'Поиск', 'url' => ['catalog/category', 'word' => implode(' ', $keywords)]];
14 15 if (!empty($category)) {
  16 + $this->params['breadcrumbs'][] = $category->categoryName->value;
15 17 $page_data['category'] = $category->name;
16 18 }
17 19  
18 20 $this->title = Yii::t('product', "Search for \"{keywords}\"". (empty($category) ? '' : ' in category \"{category}\"'), $page_data);
19 21  
20   -$this->params['seo']['seo_text'] = 'TEST SEO TEXT';
21   -$this->params['seo']['h1'] = 'TEST H1';
22   -$this->params['seo']['description'] = 'TEST DESCRIPTION';
23   -$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD';
24   -$this->params['seo']['key']= 'product_list';
  22 +//$this->params['seo']['seo_text'] = 'TEST SEO TEXT';
  23 +//$this->params['seo']['h1'] = 'TEST H1';
  24 +//$this->params['seo']['description'] = 'TEST DESCRIPTION';
  25 +//$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD';
  26 +//$this->params['seo']['key']= 'product_list';
25 27 ?>
26   -<div class="w_960">
27   - <?php if(!empty($categories)) :?>
28   - <!-- side bar with all filters -->
29   - <div class="cat_p_filter_bar">
30   - <div class="title">Категории</div>
31   - <div class="filter_list">
32   - <ul>
33   - <?php foreach ($categories as $_category) :?>
34   - <li><a href="<?= Url::to(['catalog/category', 'category' => $_category, 'word' => implode(' ', $keywords)])?>"><?= $_category->name?></a></li>
35   - <?php endforeach?>
36   - </ul>
37   - </div>
38   - </div>
39   - <?php endif?>
40 28  
41   - <!-- catalog list with all item cards -->
42   - <div class="cat_p_catalog_list">
43   - <div class="title"><?= Yii::t('product', "Search for \"{keywords}\"". (empty($category) ? '' : ' in category "{category}"'), $page_data)?><span><?= $productProvider->totalCount ? ' ('.$productProvider->totalCount .')' : ''?></span></div>
44   - <?php if (!$productProvider->count) :?>
45   - <h2>По данному запросу товары не найдены.</h2><br>
46   - <?php if (!empty($category)) :?>
47   - <p>Показать <a href="<?= Url::to(['catalog/category', 'category' => $category])?>">все товары из категории "<?= $category->name?>"</a></p>
48   - <?php endif?>
49   - <?php else :?>
50   - <!-- sort menu -->
51   - <div class="sort_menu">
52   -
53   - <div class="sort_price">
54   - <span>Сортировка:</span>
55   - <?= \yii\widgets\LinkSorter::widget([
56   - 'sort' => $productProvider->sort,
57   - 'attributes' => [
58   - 'name',
59   - 'price',
60   - ]
61   - ]);
62   - ?>
63   - </div>
64   -
65   - <div class="show">
66   - <!--<span>Показывать по:</span>
67   - <ul>
68   - <li><a class="active" href="#">24</a></li>
69   - <li><a href="#">48</a></li>
70   - <li><a href="#">96</a></li>
71   - </ul>-->
72   - </div>
73   -
74   - <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
75   - <div class="show_pages">
76   - Страница:
77   - <?= \yii\widgets\LinkPager::widget([
78   - 'pagination' => $productProvider->pagination,
79   - 'options' => ['class' => 'pagination pull-right'],
80   - ]);
81   - ?>
82   - </div>
83   - <?php endif?>
84   -
85   - </div>
  29 +<nav class="bread-crumbs">
  30 + <?= \yii\widgets\Breadcrumbs::widget ([
  31 + 'links' => $this->params['breadcrumbs'],
  32 + ])
  33 + ?>
86 34  
87   - <div class="cat_p_item_card_list">
88   - <div class="novelty">
89   - <div class="content">
90   - <div class="novelty_cont">
91   - <?php foreach($productProvider->models as $product) :?>
92   - <?php require(__DIR__ .'/product_item.php')?>
93   - <?php endforeach?>
94   - </div>
95 35  
96   - <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
97   - <!-- LOAD MORE BUTTON -->
98   - <!--button class="load_more_btn">Загрузить еще <?= $productProvider->pagination->pageSize?> товара</button-->
  36 + <div class="both"></div>
  37 +</nav>
99 38  
100   - <div class="show_pages">
101   - Страница:
102   - <?= \yii\widgets\LinkPager::widget([
103   - 'pagination' => $productProvider->pagination,
104   - 'options' => ['class' => 'pagination pull-right'],
105   - ]);
106   - ?>
107   - </div>
108   - <?php endif ?>
109   - <hr>
110   -
111   - <?php if(!empty($category->description)) :?>
112   - <div class="description">
113   - <?= $category->description?>
114   -
115   - <div class="empty_padding_400"></div>
116   - </div>
117   - <?php endif?>
118   - </div>
119   - </div>
  39 +<div class="loyout">
  40 + <?php if(!empty($categories)) :?>
  41 + <div class="leftbar">
  42 + <form action="#" name="filter_catalog_page_form" class="filter-catalog-form">
  43 + <div class="filters">
  44 + <div class="begin">Категории</div>
  45 + <ul>
  46 + <?php foreach ($categories as $_category) :
  47 + $checked = !empty($category) && $category->category_id == $_category->category_id;
  48 + $option_url = $checked ? Url::to(['catalog/category', 'word' => implode(' ', $keywords)]) : Url::to(['catalog/category', 'category' => $_category, 'word' => implode(' ', $keywords)]);
  49 + ?>
  50 + <li>
  51 + <input type="checkbox" class="brands-option" <?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" />
  52 + <a href="<?= $option_url?>"><?= $_category->name?><?php // @todo count?></a>
  53 + </li>
  54 + <?php endforeach?>
  55 + </ul>
120 56 </div>
121   -
122   - <?php endif?>
  57 + </form>
  58 + </div>
  59 + <?php endif?>
  60 + <div class="content">
  61 + <h1>Поиск</h1>
  62 + <div class="ten"></div>
  63 + <div class="products pn">
  64 + <ul>
  65 + <?php foreach($productProvider->models as $product) :?>
  66 + <?= $this->render('/catalog/product_item.php', ['product' => $product])?>
  67 + <?php endforeach?>
  68 + </ul>
  69 + <div class="both"></div>
  70 + </div>
123 71 </div>
124   -
125   - <?= \common\modules\product\widgets\lastProducts::widget()?>
126 72 </div>
127 73 \ No newline at end of file
... ...
frontend/views/site/index.php
... ... @@ -30,7 +30,7 @@ echo &#39;&lt;div class=&quot;home_banner_up&quot;&gt;&#39;;
30 30 echo '</div>'
31 31 ?>
32 32  
33   -<?= \frontend\widgets\Rubrics::widget(['wrapper' => 'rubrics', 'includes' => [117,118,119,120,121]])?>
  33 +<?= \frontend\widgets\Rubrics::widget(['wrapper' => 'rubrics', 'includes' => [124,125,126,127,128]])?>
34 34  
35 35 <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'promo'])?>
36 36 <?= \common\modules\product\widgets\specialProducts::widget(['type' => 'new'])?>
... ...
frontend/widgets/Rubrics.php
... ... @@ -39,7 +39,7 @@ class Rubrics extends Widget {
39 39 continue;
40 40 }
41 41 $items[] = $category;[
42   - 'label' => $category->name ,
  42 + 'label' => $category->name,
43 43 'url' => Url::to(['catalog/category', 'category' => $category]),
44 44 'active' => !empty($categoryObject) && $categoryObject->alias == $category->alias ? true : false,
45 45 ];
... ...