Blame view

frontend/views/catalog/products.php 11.8 KB
8df80521   Alexander Karnovsky   not fixed commite
1
2
  <?php
  /** @var $this \yii\web\View */
6fa713ca   Karnovsky A   Catalog v 1.2
3
4
5
  /** @var $productProvider \yii\data\ActiveDataProvider */
  /** @var $brandProvider \yii\data\ActiveDataProvider */
  
585f04ca   Administrator   15.04.16 seo widget
6
  
6fa713ca   Karnovsky A   Catalog v 1.2
7
8
  use yii\helpers\Url;
  use common\modules\product\helpers\ProductHelper;
8df80521   Alexander Karnovsky   not fixed commite
9
  
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
10
  $this->title =  $category->categoryName->value;
8df80521   Alexander Karnovsky   not fixed commite
11
  foreach($category->getParents()->all() as $parent) {
6fa713ca   Karnovsky A   Catalog v 1.2
12
      $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
8df80521   Alexander Karnovsky   not fixed commite
13
  }
14eadb86   Karnovsky A   Eager loading for...
14
  $this->params['breadcrumbs'][] = $category->categoryName->value;
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
15
  
585f04ca   Administrator   15.04.16 seo widget
16
17
18
19
20
  $this->params['seo']['seo_text'] = 'TEST SEO TEXT';
  $this->params['seo']['h1'] = 'TEST H1';
  $this->params['seo']['description'] = 'TEST DESCRIPTION';
  $this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD';
  $this->params['seo']['key']= 'product_list';
8df80521   Alexander Karnovsky   not fixed commite
21
  ?>
b519af22   Karnovsky A   Base-product func...
22
  <script type="text/javascript">
6fa713ca   Karnovsky A   Catalog v 1.2
23
  <?php if ($priceLimits['min'] < $priceLimits['max']) :?>
b519af22   Karnovsky A   Base-product func...
24
25
26
27
      $(document).ready(function() {
          // price rangeslider (filter price slider)
          $("#price_interval").ionRangeSlider({
              type: "double",
6fa713ca   Karnovsky A   Catalog v 1.2
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
              min: <?= $priceLimits['min']?>,
              max: <?= $priceLimits['max']?>,
              from: <?= empty($filter['prices']['min']) ? $priceLimits['min'] : $filter['prices']['min']?>,
              to: <?= empty($filter['prices']['max']) ? $priceLimits['max'] : $filter['prices']['max']?>,
              grid: false,
              onFinish: function(e) {
  <?php
  $filterWhitoutPrice = $filter;
  $filterWhitoutPrice['prices'] = [
      'min' => '{from}',
      'max' => '{to}',
  ];
  ?>
                  var url = "<?= Url::to(['catalog/category', 'category' => $category, 'filter' => $filterWhitoutPrice])?>";
                  var from = e.from;
                  var to = e.to;
                  document.location = url.replace('{from}', from).replace('{to}', to);
              }
          });
      });
  <?php endif?>
  <?php /*
      $(document).ready(function() {
          $('form.filter-catalog-form').each(function() {
              var form = $(this);
              form.submit(function(e) {
                  e.preventDefault();
                  var brands = '';
                  // Get brands values
                  $('input[type=checkbox].brands-option:checked', form).each(function() {
                      var filter_value = $(this).val().replace(',', '~').replace('/', '&s;');
                      if (brands) {
                          brands += ','+ filter_value;
                      } else {
                          brands = filter_value;
                      }
                  });
                  // Formate query and redirect
                  var filter = '';
                  if (brands) {
                      filter += 'brands='+ brands;
                  }
                  filter += ';';
  
                  if (filter) {
                      var request = '<?= Url::toRoute(['catalog/category/filter', 'alias' => $category->alias, 'filter' => '+ filter .'])?>';
                      window.location.href = request;
                  }
              });
b519af22   Karnovsky A   Base-product func...
77
78
          });
      });
6fa713ca   Karnovsky A   Catalog v 1.2
79
  */?>
b519af22   Karnovsky A   Base-product func...
80
81
82
83
84
85
  </script>
  <div class="w_960">
      <!-- side bar with all filters -->
      <div class="cat_p_filter_bar">
          <div class="title">ФИЛЬТРЫ</div>
          <div class="filter_list">
6fa713ca   Karnovsky A   Catalog v 1.2
86
87
88
89
90
91
92
              <form action="#" name="filter_catalog_page_form" class="filter-catalog-form">
                  <?php if (!empty($filter)) :?>
                  <div class="filter_accept_bloc">
                      <!--                    <button type="submit" class="filter_accept_btn">применить</button>-->
                      <a href="<?= Url::to(['catalog/category', 'category' => $category])?>" class="_form_checkbox_reset">сбросить фильтры</a>
                  </div>
                  <?php endif?>
b519af22   Karnovsky A   Base-product func...
93
                  <ul>
6fa713ca   Karnovsky A   Catalog v 1.2
94
                      <?php if ($priceLimits['min'] < $priceLimits['max']) :?>
b519af22   Karnovsky A   Base-product func...
95
96
97
98
99
100
                      <li>Цена:
                          <div class="arrow"><img src="/images/head_up.png" alt=""></i></div>
                          <div class="price_filter first_price_li">
                              <div class="price_slider">
                                  <input type="text" id="price_interval" name="price_interval" value="" />
                              </div>
b519af22   Karnovsky A   Base-product func...
101
102
                          </div>
                      </li>
6fa713ca   Karnovsky A   Catalog v 1.2
103
                      <?php endif?>
b519af22   Karnovsky A   Base-product func...
104
  
6fa713ca   Karnovsky A   Catalog v 1.2
105
106
107
108
109
110
111
112
113
114
115
116
117
                      <?php if ($brandProvider->totalCount > 0) :?>
                          <li>Бренд
                              <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                              <div class="price_filter<?= !empty($filter['brands'])?' active-field':''?>">
                                  <?php foreach($brandProvider->models as $brand) :
                                      $checked = !empty($filter['brands']) && in_array($brand->alias, $filter['brands']);
                                      $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'brands', $brand->alias, $checked)]);
                                      ?>
                                      <div class="checkbox">
                                          <label><input type="checkbox" class="brands-option" <?php /*name="brands[]" value="<?= $brand->alias?>"*/?><?= $checked ? ' checked' : ''?> onchange="document.location='<?= $option_url?>'" /></label>
                                          <a href="<?= $option_url?>"><?= $brand->name?> (<?= $brand->getProducts()->count()?>)</a>
                                      </div>
                                  <?php endforeach?>
b519af22   Karnovsky A   Base-product func...
118
                              </div>
6fa713ca   Karnovsky A   Catalog v 1.2
119
                          </li>
b519af22   Karnovsky A   Base-product func...
120
121
                      <?php endif?>
  
b15c889e   Karnovsky A   Base-product#2 fu...
122
                      <?php if (!empty($groups)) :?>
6fa713ca   Karnovsky A   Catalog v 1.2
123
                          <div class="title_2">ПОДБОР ПО ПАРАМЕТРАМ</div>
b519af22   Karnovsky A   Base-product func...
124
  
b15c889e   Karnovsky A   Base-product#2 fu...
125
                          <?php foreach($groups as $group) :?>
6fa713ca   Karnovsky A   Catalog v 1.2
126
127
128
129
130
131
132
133
134
135
136
137
                              <li><?= $group->name?>
                                  <div class="arrow"><img src="/images/head_down.png" alt=""></i></div>
                                  <div class="price_filter<?= isset($filter['options'][$group->alias])?' active-field':''?>">
                                      <?php foreach($group->_options as $option) :
                                          $checked = (isset($filter['options'][$group->alias]) && in_array($option->alias, $filter['options'][$group->alias]));
                                          $option_url = Url::to(['catalog/category', 'category' => $category, 'filter' => ProductHelper::getFilterForOption($filter, 'options', [$option->group->alias => [$option->alias]], $checked)]);
                                          ?>
                                          <div class="checkbox">
                                              <label><input type="checkbox" class="features-option" onchange="document.location='<?= $option_url?>'" <?php /* name="option[<?= $group->alias?>][]"value="<?= $option->alias?>"*/?><?= $checked ? ' checked' : ''?> /></label>
                                              <a href="<?= $option_url?>"><?= $option->ValueRenderHTML?>&nbsp;(<?= $option->_items_count?>)</a>
                                          </div>
                                      <?php endforeach?>
b15c889e   Karnovsky A   Base-product#2 fu...
138
                                  </div>
6fa713ca   Karnovsky A   Catalog v 1.2
139
                              </li>
b15c889e   Karnovsky A   Base-product#2 fu...
140
141
                          <?php endforeach?>
                      <?php endif?>
b519af22   Karnovsky A   Base-product func...
142
                  </ul>
b519af22   Karnovsky A   Base-product func...
143
              </form>
b519af22   Karnovsky A   Base-product func...
144
          </div>
b519af22   Karnovsky A   Base-product func...
145
146
147
148
      </div>
  
      <!-- catalog list with all item cards -->
      <div class="cat_p_catalog_list">
6fa713ca   Karnovsky A   Catalog v 1.2
149
          <div class="title"><?= $category->categoryName->value?> <span>(<?= $productProvider->totalCount?>)</span></div>
6fa713ca   Karnovsky A   Catalog v 1.2
150
          <?php if (!$productProvider->count) :?>
2c4d173e   Karnovsky A   Base-product#6 fu...
151
              <h2>По данному запросу товары не найдены.</h2><br>
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
152
              <?php if (!empty($category)) :?>
6fa713ca   Karnovsky A   Catalog v 1.2
153
              <p>Показать <a href="<?= Url::to(['catalog/category', 'category' => $category])?>">все товары из категории "<?= $category->categoryName->value?>"</a></p>
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
154
              <?php endif?>
2c4d173e   Karnovsky A   Base-product#6 fu...
155
          <?php else :?>
6fa713ca   Karnovsky A   Catalog v 1.2
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
              <!-- sort menu -->
              <div class="sort_menu">
  
                  <div class="sort_price">
                      <span>Сортировка:</span>
                      <?= \yii\widgets\LinkSorter::widget([
                          'sort' => $productProvider->sort,
                          'attributes' => [
                              'name',
                              'price',
                          ]
                      ]);
                      ?>
                      <!--
                      <select name="sort_price" id="" class="sort_price_select">
                          <option value="price">по цене</option>
                          <option value="popular">новые</option>
                          <option value="sale">по акции</option>
                      </select>
                      <i class="fa fa-angle-down"></i>-->
                  </div>
b519af22   Karnovsky A   Base-product func...
177
  
6fa713ca   Karnovsky A   Catalog v 1.2
178
179
180
181
182
183
184
185
                  <div class="show">
                      <!--<span>Показывать по:</span>
                      <ul>
                          <li><a class="active" href="#">24</a></li>
                          <li><a href="#">48</a></li>
                          <li><a href="#">96</a></li>
                      </ul>-->
                  </div>
b519af22   Karnovsky A   Base-product func...
186
  
6fa713ca   Karnovsky A   Catalog v 1.2
187
188
189
190
191
192
193
194
195
196
                  <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
                  <div class="show_pages">
                      Страница:
                      <?= \yii\widgets\LinkPager::widget([
                          'pagination' => $productProvider->pagination,
                          'options' => ['class' => 'pagination pull-right'],
                      ]);
                      ?>
                      <!--<i class="fa fa-caret-right"></i>-->
                  </div>
8df80521   Alexander Karnovsky   not fixed commite
197
                  <?php endif?>
b519af22   Karnovsky A   Base-product func...
198
  
6fa713ca   Karnovsky A   Catalog v 1.2
199
              </div>
b519af22   Karnovsky A   Base-product func...
200
  
6fa713ca   Karnovsky A   Catalog v 1.2
201
202
203
204
205
206
207
208
              <div class="cat_p_item_card_list">
                  <div class="novelty">
                      <div class="content">
                          <div class="novelty_cont">
                              <?php foreach($productProvider->models as $product) :?>
                                  <?php require(__DIR__ .'/product_item.php')?>
                              <?php endforeach?>
                          </div>
b519af22   Karnovsky A   Base-product func...
209
  
6fa713ca   Karnovsky A   Catalog v 1.2
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
                          <?php if ($productProvider->totalCount > $productProvider->pagination->pageSize) :?>
                              <!-- LOAD MORE BUTTON -->
                              <!--button class="load_more_btn">Загрузить еще <?= $productProvider->pagination->pageSize?> товара</button-->
  
                              <div class="show_pages">
                                  Страница:
                                  <?= \yii\widgets\LinkPager::widget([
                                      'pagination' => $productProvider->pagination,
                                      'options' => ['class' => 'pagination pull-right'],
                                  ]);
                                  ?>
                                  <!--<i class="fa fa-caret-right"></i>-->
                              </div>
                          <?php endif ?>
                          <hr>
b519af22   Karnovsky A   Base-product func...
225
  
6fa713ca   Karnovsky A   Catalog v 1.2
226
227
228
                          <?php if(!empty($category->description)) :?>
                              <div class="description">
                                  <?= $category->description?>
b519af22   Karnovsky A   Base-product func...
229
  
6fa713ca   Karnovsky A   Catalog v 1.2
230
231
232
                                  <div class="empty_padding_400"></div>
                              </div>
                          <?php endif?>
b519af22   Karnovsky A   Base-product func...
233
                      </div>
b519af22   Karnovsky A   Base-product func...
234
235
                  </div>
              </div>
2c4d173e   Karnovsky A   Base-product#6 fu...
236
237
  
          <?php endif?>
b519af22   Karnovsky A   Base-product func...
238
      </div>
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
239
240
241
242
243
244
245
246
247
248
249
250
  
      <?php if(!empty($last_products)) :?>
          <hr>
          <div class="watched_block">
              <h1>Вы недавно просматривали</h1>
              <div class="flex-container">
                  <?php foreach($last_products as $product) :?>
                      <?php require(__DIR__ .'/product_smart.php')?>
                  <?php endforeach?>
              </div>
          </div>
      <?php endif?>
6fa713ca   Karnovsky A   Catalog v 1.2
251
  </div>