products.php
11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
/** @var $this \yii\web\View */
/** @var $productProvider \yii\data\ActiveDataProvider */
/** @var $brandProvider \yii\data\ActiveDataProvider */
use yii\helpers\Url;
use common\modules\product\helpers\ProductHelper;
$this->title = $category->categoryName->value;
foreach($category->getParents()->all() as $parent) {
$this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
}
$this->params['breadcrumbs'][] = $category->categoryName->value;
$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';
?>
<script type="text/javascript">
<?php if ($priceLimits['min'] < $priceLimits['max']) :?>
$(document).ready(function() {
// price rangeslider (filter price slider)
$("#price_interval").ionRangeSlider({
type: "double",
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;
}
});
});
});
*/?>
</script>
<div class="w_960">
<!-- side bar with all filters -->
<div class="cat_p_filter_bar">
<div class="title">ФИЛЬТРЫ</div>
<div class="filter_list">
<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?>
<ul>
<?php if ($priceLimits['min'] < $priceLimits['max']) :?>
<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>
</div>
</li>
<?php endif?>
<?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?></a>
</div>
<?php endforeach?>
</div>
</li>
<?php endif?>
<?php if (!empty($groups)) :?>
<div class="title_2">ПОДБОР ПО ПАРАМЕТРАМ</div>
<?php foreach($groups as $group) :?>
<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?></a>
</div>
<?php endforeach?>
</div>
</li>
<?php endforeach?>
<?php endif?>
</ul>
</form>
</div>
</div>
<!-- catalog list with all item cards -->
<div class="cat_p_catalog_list">
<div class="title"><?= $category->categoryName->value?> <span>(<?= $productProvider->totalCount?>)</span></div>
<?php if (!$productProvider->count) :?>
<h2>По данному запросу товары не найдены.</h2><br>
<?php if (!empty($category)) :?>
<p>Показать <a href="<?= Url::to(['catalog/category', 'category' => $category])?>">все товары из категории "<?= $category->categoryName->value?>"</a></p>
<?php endif?>
<?php else :?>
<!-- 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>
<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>
<?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>
<?php endif?>
</div>
<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>
<?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>
<?php if(!empty($category->description)) :?>
<div class="description">
<?= $category->description?>
<div class="empty_padding_400"></div>
</div>
<?php endif?>
</div>
</div>
</div>
<?php endif?>
</div>
<?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?>
</div>