Commit 44a8a98996f0ba6b0af248b54d8af1c385200c5e

Authored by Alexey Boroda
2 parents a7a60934 27270c21

Merge remote-tracking branch 'origin/master'

backend/web/js/galleryWidget.js
@@ -32,7 +32,7 @@ $( @@ -32,7 +32,7 @@ $(
32 .on( 32 .on(
33 'click', '#add-image', function(e) { 33 'click', '#add-image', function(e) {
34 var hash = Math.floor(Math.random() * 89999) + 10000; 34 var hash = Math.floor(Math.random() * 89999) + 10000;
35 - var content = '<div class="col-md-4 gw-item"><input id="' + hash + '" class="gw-image-input" name ="images[' + hash + ']" ' + 'data-img="' + hash + '_img" data-name="' + hash + '_name" type ="hidden"> ' + '<img id="' + hash + '_img" class="img-rounded" src="/admin/product/create" alt="">' + '<p id="' + hash + '_name" class="text-info"></p>' + '<button type="button" class="open-modal-imagemanager btn btn-primary" data-aspect-ratio="" data-crop-view-mode="1" ' + 'data-input-id="' + hash + '"><i class="fa fa-folder-open"></i></button><button type="button" class="remove-img btn btn-danger">' + '<i class="fa fa-trash"></i></button></div>'; 35 + var content = '<div class="col-md-2 gw-item"><input id="' + hash + '" class="gw-image-input" name ="images[' + hash + ']" ' + 'data-img="' + hash + '_img" data-name="' + hash + '_name" type ="hidden"> ' + '<div class="image_gall"><img id="' + hash + '_img" alt=""></div>' + '<p id="' + hash + '_name" class="text-info"></p>' + '<button type="button" class="open-modal-imagemanager btn btn-primary" data-aspect-ratio="" data-crop-view-mode="1" ' + 'data-input-id="' + hash + '"><i class="fa fa-folder-open"></i></button><button type="button" class="remove-img btn btn-danger">' + '<i class="fa fa-trash"></i></button></div>';
36 $('.gw-container') 36 $('.gw-container')
37 .append(content); 37 .append(content);
38 // if (document.querySelectorAll(".gw-container > .gw-item").length % 3 === 0) { 38 // if (document.querySelectorAll(".gw-container > .gw-item").length % 3 === 0) {
frontend/controllers/CategoryController.php
1 <?php 1 <?php
2 namespace frontend\controllers; 2 namespace frontend\controllers;
3 - 3 +
  4 + use artbox\catalog\helpers\FilterHelper;
4 use artbox\catalog\models\Category; 5 use artbox\catalog\models\Category;
5 use artbox\core\components\SeoComponent; 6 use artbox\core\components\SeoComponent;
6 - use artbox\core\models\Page;  
7 use yii\data\ActiveDataProvider; 7 use yii\data\ActiveDataProvider;
8 use yii\db\ActiveQuery; 8 use yii\db\ActiveQuery;
9 use yii\web\Controller; 9 use yii\web\Controller;
@@ -31,15 +31,22 @@ @@ -31,15 +31,22 @@
31 $model = $this->findModel($id); 31 $model = $this->findModel($id);
32 /** 32 /**
33 * @var SeoComponent $seo 33 * @var SeoComponent $seo
  34 + * @var FilterHelper $filterHelper
34 */ 35 */
35 $seo = Yii::$app->get('seo'); 36 $seo = Yii::$app->get('seo');
36 $seo->setModel($model->lang); 37 $seo->setModel($model->lang);
37 $filterHelper = \Yii::$app->get('filter'); 38 $filterHelper = \Yii::$app->get('filter');
38 $filterHelper->setFilter($filter); 39 $filterHelper->setFilter($filter);
39 - $query = $filterHelper->buildQuery(); 40 + $query = $filterHelper->buildQuery()
  41 + ->innerJoinWith('category', false)
  42 + ->andWhere([ 'product_to_category.category_id' => $model->id ])
  43 + ->with('images', 'variants', 'lang');
40 $dataProvider = new ActiveDataProvider( 44 $dataProvider = new ActiveDataProvider(
41 [ 45 [
42 - 'query' => $query, 46 + 'query' => $query,
  47 + 'pagination' => [
  48 + 'pageSize' => 18,
  49 + ],
43 ] 50 ]
44 ); 51 );
45 52
@@ -57,7 +64,7 @@ @@ -57,7 +64,7 @@
57 * 64 *
58 * @param $id 65 * @param $id
59 * 66 *
60 - * @return \artbox\core\models\Page 67 + * @return Category
61 * @throws \yii\web\NotFoundHttpException 68 * @throws \yii\web\NotFoundHttpException
62 */ 69 */
63 protected function findModel($id) 70 protected function findModel($id)
@@ -67,10 +74,10 @@ @@ -67,10 +74,10 @@
67 */ 74 */
68 $seo = Yii::$app->get('seo'); 75 $seo = Yii::$app->get('seo');
69 /** 76 /**
70 - * @var Page $model 77 + * @var Category $model
71 */ 78 */
72 $model = Category::findWithFilters($id) 79 $model = Category::findWithFilters($id)
73 - ->with('lang') 80 + ->with('lang.alias')
74 ->with('categories.lang') 81 ->with('categories.lang')
75 ->with( 82 ->with(
76 [ 83 [
@@ -83,6 +90,7 @@ @@ -83,6 +90,7 @@
83 ] 90 ]
84 ) 91 )
85 ->one(); 92 ->one();
  93 + $seo->setAlias($model->lang->alias);
86 if (!empty( $model )) { 94 if (!empty( $model )) {
87 if ($model->lang->alias_id !== $seo->aliasId) { 95 if ($model->lang->alias_id !== $seo->aliasId) {
88 throw new NotFoundHttpException('Wrong language'); 96 throw new NotFoundHttpException('Wrong language');
frontend/controllers/ProductController.php 0 → 100755
  1 +<?php
  2 + namespace frontend\controllers;
  3 +
  4 + use artbox\catalog\models\Product;
  5 + use artbox\core\components\SeoComponent;
  6 + use yii\db\ActiveQuery;
  7 + use yii\web\Controller;
  8 + use yii\web\NotFoundHttpException;
  9 + use Yii;
  10 +
  11 + /**
  12 + * Class ProductController
  13 + *
  14 + * @package frontend\controllers
  15 + */
  16 + class ProductController extends Controller
  17 + {
  18 + /**
  19 + * Show product by ID
  20 + *
  21 + * @param int $id
  22 + *
  23 + * @return string
  24 + */
  25 + public function actionView($id)
  26 + {
  27 + $model = $this->findModel($id);
  28 + /**
  29 + * @var SeoComponent $seo
  30 + */
  31 + $seo = Yii::$app->get('seo');
  32 + $seo->setModel($model->lang);
  33 + $variant = $model->variants[ 0 ];
  34 + $groups = $variant->getSortedGroups();
  35 + $similar = $model->getSimilarProducts(8);
  36 +
  37 + return $this->render(
  38 + 'view',
  39 + [
  40 + 'model' => $model,
  41 + 'variant' => $variant,
  42 + 'groups' => $groups,
  43 + 'similar' => $similar,
  44 + ]
  45 + );
  46 + }
  47 +
  48 + /**
  49 + * Find product by ID
  50 + *
  51 + * @param $id
  52 + *
  53 + * @return Product
  54 + * @throws \yii\web\NotFoundHttpException
  55 + */
  56 + protected function findModel($id)
  57 + {
  58 + /**
  59 + * @var SeoComponent $seo
  60 + */
  61 + $seo = \Yii::$app->get('seo');
  62 + /**
  63 + * @var Product $model
  64 + */
  65 + $model = Product::findWithFilters()
  66 + ->with('lang', 'images')
  67 + ->with(
  68 + [
  69 + 'category' => function ($query) {
  70 + /**
  71 + * @var ActiveQuery $query
  72 + */
  73 + $query->with('lang')
  74 + ->with('parent.lang');
  75 + },
  76 + ]
  77 + )
  78 + ->where([ 'id' => $id ])
  79 + ->one();
  80 + if (!empty( $model )) {
  81 + if ($model->lang->alias_id !== $seo->aliasId) {
  82 + throw new NotFoundHttpException('Wrong language');
  83 + }
  84 + return $model;
  85 + } else {
  86 + throw new NotFoundHttpException('Model not found');
  87 + }
  88 + }
  89 + }
0 \ No newline at end of file 90 \ No newline at end of file
frontend/views/category/_product_item.php 0 → 100644
  1 +<?php
  2 + use artbox\catalog\models\Product;
  3 + use yii\helpers\Html;
  4 + use yii\web\View;
  5 +
  6 + /**
  7 + * @var View $this
  8 + * @var Product $product
  9 + */
  10 +?>
  11 +<div class="col-md-4 col-sm-6">
  12 + <div class="product">
  13 + <div class="image">
  14 + <?php
  15 + if (!empty( $product->images )) {
  16 + $image = $product->images[ 0 ];
  17 + } else {
  18 + $image = null;
  19 + }
  20 + echo Html::a(
  21 + Html::img(
  22 + $image ? $image->getUrl() : '/img/no-image.png',
  23 + [
  24 + 'class' => 'img-responsive-image1',
  25 + ]
  26 + ),
  27 + [
  28 + 'product/view',
  29 + 'id' => $product->id,
  30 + ]
  31 + );
  32 + ?>
  33 + </div>
  34 + <!-- /.image -->
  35 + <div class="text">
  36 + <h3>
  37 + <?php
  38 + echo Html::a(
  39 + $product->lang->title,
  40 + [
  41 + 'product/view',
  42 + 'id' => $product->id,
  43 + ]
  44 + );
  45 + ?>
  46 + </h3>
  47 + <p class="price">
  48 + <?php
  49 + if ($product->variants[ 0 ]->price_old) {
  50 + echo Html::tag('del', $product->variants[ 0 ]->price_old);
  51 + }
  52 + echo $product->variants[ 0 ]->price;
  53 + ?></p>
  54 + <p class="buttons">
  55 + <?php
  56 + echo Html::a(
  57 + Html::tag(
  58 + 'i',
  59 + '',
  60 + [
  61 + 'class' => 'fa fa-shopping-cart',
  62 + ]
  63 + ) . \Yii::t('app', 'В корзину'),
  64 + '#',
  65 + [ 'class' => 'btn btn-template-main' ]
  66 + );
  67 + ?>
  68 + </p>
  69 + </div>
  70 + <!-- /.text -->
  71 + <?php
  72 + if ($product->is(1)) {
  73 + ?>
  74 + <div class="ribbon new">
  75 + <div class="theribbon"><?php echo \Yii::t('app', 'Новое'); ?></div>
  76 + <div class="ribbon-background"></div>
  77 + </div>
  78 + <?php
  79 + }
  80 + if ($product->is(2)) {
  81 + ?>
  82 + <div class="ribbon sale">
  83 + <div class="theribbon"><?php echo \Yii::t('app', 'Акция'); ?></div>
  84 + <div class="ribbon-background"></div>
  85 + </div>
  86 + <?php
  87 + }
  88 + ?>
  89 +
  90 + <!-- /.ribbon -->
  91 + </div>
  92 + <!-- /.product -->
  93 +</div>
frontend/views/category/view.php
@@ -5,16 +5,21 @@ @@ -5,16 +5,21 @@
5 use artbox\catalog\models\Product; 5 use artbox\catalog\models\Product;
6 use artbox\core\components\SeoComponent; 6 use artbox\core\components\SeoComponent;
7 use yii\bootstrap\Html; 7 use yii\bootstrap\Html;
  8 + use yii\data\ActiveDataProvider;
8 use yii\web\View; 9 use yii\web\View;
  10 + use yii\widgets\LinkPager;
  11 + use yii\widgets\ListView;
9 12
10 /** 13 /**
11 - * @var View $this  
12 - * @var Category $model  
13 - * @var SeoComponent $seo  
14 - * @var FilterHelper $filterHelper 14 + * @var View $this
  15 + * @var Category $model
  16 + * @var SeoComponent $seo
  17 + * @var FilterHelper $filterHelper
  18 + * @var ActiveDataProvider $dataProvider
15 */ 19 */
16 $seo = \Yii::$app->get('seo'); 20 $seo = \Yii::$app->get('seo');
17 $filterHelper = \Yii::$app->get('filter'); 21 $filterHelper = \Yii::$app->get('filter');
  22 + $view = $this;
18 $this->params[ 'breadcrumbs' ][] = $seo->title; 23 $this->params[ 'breadcrumbs' ][] = $seo->title;
19 ?> 24 ?>
20 <div id="content"> 25 <div id="content">
@@ -113,7 +118,12 @@ _________________________________________________________ --&gt; @@ -113,7 +118,12 @@ _________________________________________________________ --&gt;
113 'id' => $model->id, 118 'id' => $model->id,
114 'filter' => $filterHelper->buildLink($brand), 119 'filter' => $filterHelper->buildLink($brand),
115 ] 120 ]
116 - ) 121 + ),
  122 + [
  123 + 'class' => $filterHelper->has(
  124 + $brand->lang->alias->value
  125 + ) ? 'radio-but checked' : 'radio-but',
  126 + ]
117 ); 127 );
118 } 128 }
119 ?> 129 ?>
@@ -144,7 +154,12 @@ _________________________________________________________ --&gt; @@ -144,7 +154,12 @@ _________________________________________________________ --&gt;
144 'id' => $model->id, 154 'id' => $model->id,
145 'filter' => $filterHelper->buildLink($option), 155 'filter' => $filterHelper->buildLink($option),
146 ] 156 ]
147 - ) 157 + ),
  158 + [
  159 + 'class' => $filterHelper->has(
  160 + $option->lang->alias->value
  161 + ) ? 'radio-but checked' : 'radio-but',
  162 + ]
148 ); 163 );
149 } 164 }
150 ?> 165 ?>
@@ -175,7 +190,12 @@ _________________________________________________________ --&gt; @@ -175,7 +190,12 @@ _________________________________________________________ --&gt;
175 'id' => $model->id, 190 'id' => $model->id,
176 'filter' => $filterHelper->buildLink($option), 191 'filter' => $filterHelper->buildLink($option),
177 ] 192 ]
178 - ) 193 + ),
  194 + [
  195 + 'class' => $filterHelper->has(
  196 + $option->lang->alias->value
  197 + ) ? 'radio-but checked' : 'radio-but',
  198 + ]
179 ); 199 );
180 } 200 }
181 ?> 201 ?>
@@ -206,7 +226,12 @@ _________________________________________________________ --&gt; @@ -206,7 +226,12 @@ _________________________________________________________ --&gt;
206 'id' => $model->id, 226 'id' => $model->id,
207 'filter' => $filterHelper->buildLink($option), 227 'filter' => $filterHelper->buildLink($option),
208 ] 228 ]
209 - ) 229 + ),
  230 + [
  231 + 'class' => $filterHelper->has(
  232 + $option->lang->alias->value
  233 + ) ? 'radio-but checked' : 'radio-but',
  234 + ]
210 ); 235 );
211 } 236 }
212 ?> 237 ?>
@@ -237,7 +262,12 @@ _________________________________________________________ --&gt; @@ -237,7 +262,12 @@ _________________________________________________________ --&gt;
237 'id' => $model->id, 262 'id' => $model->id,
238 'filter' => $filterHelper->buildLink($option), 263 'filter' => $filterHelper->buildLink($option),
239 ] 264 ]
240 - ) 265 + ),
  266 + [
  267 + 'class' => $filterHelper->has(
  268 + $option->lang->alias->value
  269 + ) ? 'radio-but checked' : 'radio-but',
  270 + ]
241 ); 271 );
242 } 272 }
243 ?> 273 ?>
@@ -261,474 +291,43 @@ _________________________________________________________ --&gt; @@ -261,474 +291,43 @@ _________________________________________________________ --&gt;
261 _________________________________________________________ --> 291 _________________________________________________________ -->
262 292
263 <div class="col-sm-9"> 293 <div class="col-sm-9">
264 -  
265 - <div class="row products">  
266 -  
267 - <div class="col-md-4 col-sm-6">  
268 - <div class="product">  
269 - <div class="image">  
270 - <a href="shop-product.html">  
271 - <img src="/img/product1.jpg" alt="" class="img-responsive image1">  
272 - </a>  
273 - </div>  
274 - <!-- /.image -->  
275 - <div class="text">  
276 - <h3><a href="shop-product.html">Fur coat with very but very very long name</a></h3>  
277 - <p class="price">$143.00</p>  
278 - <p class="buttons">  
279 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
280 - </p>  
281 - </div>  
282 - <!-- /.text -->  
283 - </div>  
284 - <!-- /.product -->  
285 - </div>  
286 -  
287 - <div class="col-md-4 col-sm-6">  
288 - <div class="product">  
289 - <div class="image">  
290 - <a href="shop-product.html">  
291 - <img src="/img/product2.jpg" alt="" class="img-responsive image1">  
292 - </a>  
293 - </div>  
294 - <!-- /.image -->  
295 - <div class="text">  
296 - <h3><a href="shop-product.html">White Blouse Armani</a></h3>  
297 - <p class="price">  
298 - <del>$280</del>  
299 - $143.00  
300 - </p>  
301 - <p class="buttons">  
302 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
303 - </p>  
304 - </div>  
305 - <!-- /.text -->  
306 -  
307 - <div class="ribbon sale">  
308 - <div class="theribbon">Скидки</div>  
309 - <div class="ribbon-background"></div>  
310 - </div>  
311 - <!-- /.ribbon -->  
312 -  
313 - <div class="ribbon new">  
314 - <div class="theribbon">Новое</div>  
315 - <div class="ribbon-background"></div>  
316 - </div>  
317 - <!-- /.ribbon -->  
318 - </div>  
319 - <!-- /.product -->  
320 - </div>  
321 -  
322 - <div class="col-md-4 col-sm-6">  
323 - <div class="product">  
324 - <div class="image">  
325 - <a href="shop-product.html">  
326 - <img src="/img/product3.jpg" alt="" class="img-responsive image1">  
327 - </a>  
328 - </div>  
329 - <!-- /.image -->  
330 - <div class="text">  
331 - <h3><a href="shop-product.html">Black Blouse Versace</a></h3>  
332 - <p class="price">$143.00</p>  
333 - <p class="buttons">  
334 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
335 - </p>  
336 -  
337 - </div>  
338 - <!-- /.text -->  
339 - </div>  
340 - <!-- /.product -->  
341 - </div>  
342 -  
343 - <div class="col-md-4 col-sm-6">  
344 - <div class="product">  
345 - <div class="image">  
346 - <a href="shop-product.html">  
347 - <img src="/img/product3.jpg" alt="" class="img-responsive image1">  
348 - </a>  
349 - </div>  
350 - <!-- /.image -->  
351 - <div class="text">  
352 - <h3><a href="shop-product.html">Black Blouse Versace</a></h3>  
353 - <p class="price">$143.00</p>  
354 - <p class="buttons">  
355 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
356 - </p>  
357 -  
358 - </div>  
359 - <!-- /.text -->  
360 - </div>  
361 - <!-- /.product -->  
362 - </div>  
363 -  
364 - <div class="col-md-4 col-sm-6">  
365 - <div class="product">  
366 - <div class="image">  
367 - <a href="shop-product.html">  
368 - <img src="/img/product2.jpg" alt="" class="img-responsive image1">  
369 - </a>  
370 - </div>  
371 - <!-- /.image -->  
372 - <div class="text">  
373 - <h3><a href="shop-product.html">White Blouse Versace</a></h3>  
374 - <p class="price">$143.00</p>  
375 - <p class="buttons">  
376 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
377 - </p>  
378 -  
379 - </div>  
380 -  
381 - <!-- /.text -->  
382 -  
383 - <div class="ribbon new">  
384 - <div class="theribbon">Новое</div>  
385 - <div class="ribbon-background"></div>  
386 - </div>  
387 - <!-- /.ribbon -->  
388 - </div>  
389 - <!-- /.product -->  
390 - </div>  
391 -  
392 - <div class="col-md-4 col-sm-6">  
393 - <div class="product">  
394 - <div class="image">  
395 - <a href="shop-product.html">  
396 - <img src="/img/product1.jpg" alt="" class="img-responsive image1">  
397 - </a>  
398 - </div>  
399 - <!-- /.image -->  
400 - <div class="text">  
401 - <h3><a href="shop-product.html">Fur coat</a></h3>  
402 - <p class="price">$143.00</p>  
403 - <p class="buttons">  
404 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
405 - </p>  
406 -  
407 - </div>  
408 - <!-- /.text -->  
409 - </div>  
410 - <!-- /.product -->  
411 - </div>  
412 -  
413 - <div class="col-md-4 col-sm-6">  
414 - <div class="product">  
415 - <div class="image">  
416 - <a href="shop-product.html">  
417 - <img src="/img/product1.jpg" alt="" class="img-responsive image1">  
418 - </a>  
419 - </div>  
420 - <!-- /.image -->  
421 - <div class="text">  
422 - <h3><a href="shop-product.html">Fur coat with very but very very long name</a></h3>  
423 - <p class="price">$143.00</p>  
424 - <p class="buttons">  
425 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
426 - </p>  
427 - </div>  
428 - <!-- /.text -->  
429 - </div>  
430 - <!-- /.product -->  
431 - </div>  
432 -  
433 - <div class="col-md-4 col-sm-6">  
434 - <div class="product">  
435 - <div class="image">  
436 - <a href="shop-product.html">  
437 - <img src="/img/product2.jpg" alt="" class="img-responsive image1">  
438 - </a>  
439 - </div>  
440 - <!-- /.image -->  
441 - <div class="text">  
442 - <h3><a href="shop-product.html">White Blouse Armani</a></h3>  
443 - <p class="price">  
444 - <del>$280</del>  
445 - $143.00  
446 - </p>  
447 - <p class="buttons">  
448 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
449 - </p>  
450 - </div>  
451 - <!-- /.text -->  
452 -  
453 - <div class="ribbon sale">  
454 - <div class="theribbon">Скидки</div>  
455 - <div class="ribbon-background"></div>  
456 - </div>  
457 - <!-- /.ribbon -->  
458 -  
459 - <div class="ribbon new">  
460 - <div class="theribbon">Новое</div>  
461 - <div class="ribbon-background"></div>  
462 - </div>  
463 - <!-- /.ribbon -->  
464 - </div>  
465 - <!-- /.product -->  
466 - </div>  
467 -  
468 - <div class="col-md-4 col-sm-6">  
469 - <div class="product">  
470 - <div class="image">  
471 - <a href="shop-product.html">  
472 - <img src="/img/product3.jpg" alt="" class="img-responsive image1">  
473 - </a>  
474 - </div>  
475 - <!-- /.image -->  
476 - <div class="text">  
477 - <h3><a href="shop-product.html">Black Blouse Versace</a></h3>  
478 - <p class="price">$143.00</p>  
479 - <p class="buttons">  
480 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
481 - </p>  
482 -  
483 - </div>  
484 - <!-- /.text -->  
485 - </div>  
486 - <!-- /.product -->  
487 - </div>  
488 -  
489 - <div class="col-md-4 col-sm-6">  
490 - <div class="product">  
491 - <div class="image">  
492 - <a href="shop-product.html">  
493 - <img src="/img/product3.jpg" alt="" class="img-responsive image1">  
494 - </a>  
495 - </div>  
496 - <!-- /.image -->  
497 - <div class="text">  
498 - <h3><a href="shop-product.html">Black Blouse Versace</a></h3>  
499 - <p class="price">$143.00</p>  
500 - <p class="buttons">  
501 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
502 - </p>  
503 -  
504 - </div>  
505 - <!-- /.text -->  
506 - </div>  
507 - <!-- /.product -->  
508 - </div>  
509 -  
510 - <div class="col-md-4 col-sm-6">  
511 - <div class="product">  
512 - <div class="image">  
513 - <a href="shop-product.html">  
514 - <img src="/img/product2.jpg" alt="" class="img-responsive image1">  
515 - </a>  
516 - </div>  
517 - <!-- /.image -->  
518 - <div class="text">  
519 - <h3><a href="shop-product.html">White Blouse Versace</a></h3>  
520 - <p class="price">$143.00</p>  
521 - <p class="buttons">  
522 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
523 - </p>  
524 -  
525 - </div>  
526 -  
527 - <!-- /.text -->  
528 -  
529 - <div class="ribbon new">  
530 - <div class="theribbon">Новое</div>  
531 - <div class="ribbon-background"></div>  
532 - </div>  
533 - <!-- /.ribbon -->  
534 - </div>  
535 - <!-- /.product -->  
536 - </div>  
537 -  
538 - <div class="col-md-4 col-sm-6">  
539 - <div class="product">  
540 - <div class="image">  
541 - <a href="shop-product.html">  
542 - <img src="/img/product1.jpg" alt="" class="img-responsive image1">  
543 - </a>  
544 - </div>  
545 - <!-- /.image -->  
546 - <div class="text">  
547 - <h3><a href="shop-product.html">Fur coat</a></h3>  
548 - <p class="price">$143.00</p>  
549 - <p class="buttons">  
550 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
551 - </p>  
552 -  
553 - </div>  
554 - <!-- /.text -->  
555 - </div>  
556 - <!-- /.product -->  
557 - </div>  
558 -  
559 - <div class="col-md-4 col-sm-6">  
560 - <div class="product">  
561 - <div class="image">  
562 - <a href="shop-product.html">  
563 - <img src="/img/product1.jpg" alt="" class="img-responsive image1">  
564 - </a>  
565 - </div>  
566 - <!-- /.image -->  
567 - <div class="text">  
568 - <h3><a href="shop-product.html">Fur coat with very but very very long name</a></h3>  
569 - <p class="price">$143.00</p>  
570 - <p class="buttons">  
571 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
572 - </p>  
573 - </div>  
574 - <!-- /.text -->  
575 - </div>  
576 - <!-- /.product -->  
577 - </div>  
578 -  
579 - <div class="col-md-4 col-sm-6">  
580 - <div class="product">  
581 - <div class="image">  
582 - <a href="shop-product.html">  
583 - <img src="/img/product2.jpg" alt="" class="img-responsive image1">  
584 - </a>  
585 - </div>  
586 - <!-- /.image -->  
587 - <div class="text">  
588 - <h3><a href="shop-product.html">White Blouse Armani</a></h3>  
589 - <p class="price">  
590 - <del>$280</del>  
591 - $143.00  
592 - </p>  
593 - <p class="buttons">  
594 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
595 - </p>  
596 - </div>  
597 - <!-- /.text -->  
598 -  
599 - <div class="ribbon sale">  
600 - <div class="theribbon">Скидки</div>  
601 - <div class="ribbon-background"></div>  
602 - </div>  
603 - <!-- /.ribbon -->  
604 -  
605 - <div class="ribbon new">  
606 - <div class="theribbon">Новое</div>  
607 - <div class="ribbon-background"></div>  
608 - </div>  
609 - <!-- /.ribbon -->  
610 - </div>  
611 - <!-- /.product -->  
612 - </div>  
613 -  
614 - <div class="col-md-4 col-sm-6">  
615 - <div class="product">  
616 - <div class="image">  
617 - <a href="shop-product.html">  
618 - <img src="/img/product3.jpg" alt="" class="img-responsive image1">  
619 - </a>  
620 - </div>  
621 - <!-- /.image -->  
622 - <div class="text">  
623 - <h3><a href="shop-product.html">Black Blouse Versace</a></h3>  
624 - <p class="price">$143.00</p>  
625 - <p class="buttons">  
626 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
627 - </p>  
628 -  
629 - </div>  
630 - <!-- /.text -->  
631 - </div>  
632 - <!-- /.product -->  
633 - </div>  
634 -  
635 - <div class="col-md-4 col-sm-6">  
636 - <div class="product">  
637 - <div class="image">  
638 - <a href="shop-product.html">  
639 - <img src="/img/product3.jpg" alt="" class="img-responsive image1">  
640 - </a>  
641 - </div>  
642 - <!-- /.image -->  
643 - <div class="text">  
644 - <h3><a href="shop-product.html">Black Blouse Versace</a></h3>  
645 - <p class="price">$143.00</p>  
646 - <p class="buttons">  
647 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
648 - </p>  
649 -  
650 - </div>  
651 - <!-- /.text -->  
652 - </div>  
653 - <!-- /.product -->  
654 - </div>  
655 -  
656 - <div class="col-md-4 col-sm-6">  
657 - <div class="product">  
658 - <div class="image">  
659 - <a href="shop-product.html">  
660 - <img src="/img/product2.jpg" alt="" class="img-responsive image1">  
661 - </a>  
662 - </div>  
663 - <!-- /.image -->  
664 - <div class="text">  
665 - <h3><a href="shop-product.html">White Blouse Versace</a></h3>  
666 - <p class="price">$143.00</p>  
667 - <p class="buttons">  
668 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
669 - </p>  
670 -  
671 - </div>  
672 -  
673 - <!-- /.text -->  
674 -  
675 - <div class="ribbon new">  
676 - <div class="theribbon">Новое</div>  
677 - <div class="ribbon-background"></div>  
678 - </div>  
679 - <!-- /.ribbon -->  
680 - </div>  
681 - <!-- /.product -->  
682 - </div>  
683 -  
684 - <div class="col-md-4 col-sm-6">  
685 - <div class="product">  
686 - <div class="image">  
687 - <a href="shop-product.html">  
688 - <img src="/img/product1.jpg" alt="" class="img-responsive image1">  
689 - </a>  
690 - </div>  
691 - <!-- /.image -->  
692 - <div class="text">  
693 - <h3><a href="shop-product.html">Fur coat</a></h3>  
694 - <p class="price">$143.00</p>  
695 - <p class="buttons">  
696 - <a href="shop-basket.html" class="btn btn-template-main"><i class="fa fa-shopping-cart"></i>В корзину</a>  
697 - </p>  
698 -  
699 - </div>  
700 - <!-- /.text -->  
701 - </div>  
702 - <!-- /.product -->  
703 - </div>  
704 - <!-- /.col-md-4 -->  
705 - </div>  
706 - <!-- /.products -->  
707 -  
708 - <div class="pages">  
709 - <!--  
710 - <p class="loadMore">  
711 - <a href="#" class="btn btn-template-main"><i class="fa fa-chevron-down"></i> Load more</a>  
712 - </p>  
713 - -->  
714 - <ul class="pagination">  
715 - <li><a href="#">&laquo;</a>  
716 - </li>  
717 - <li class="active"><a href="#">1</a>  
718 - </li>  
719 - <li><a href="#">2</a>  
720 - </li>  
721 - <li><a href="#">3</a>  
722 - </li>  
723 - <li><a href="#">4</a>  
724 - </li>  
725 - <li><a href="#">5</a>  
726 - </li>  
727 - <li><a href="#">&raquo;</a>  
728 - </li>  
729 - </ul>  
730 - </div>  
731 - 294 +
  295 + <?php
  296 + echo ListView::widget(
  297 + [
  298 + 'options' => [
  299 + 'class' => 'row products',
  300 + ],
  301 + 'itemOptions' => [
  302 + 'tag' => false,
  303 + ],
  304 + 'layout' => '{items}',
  305 + 'dataProvider' => $dataProvider,
  306 + 'itemView' => function ($model) use ($view) {
  307 + /**
  308 + * @var Product $model
  309 + */
  310 + return $view->render(
  311 + '_product_item',
  312 + [
  313 + 'product' => $model,
  314 + ]
  315 + );
  316 + },
  317 + ]
  318 + );
  319 + echo Html::tag(
  320 + 'div',
  321 + LinkPager::widget(
  322 + [
  323 + 'pagination' => $dataProvider->pagination,
  324 + ]
  325 + ),
  326 + [
  327 + 'class' => 'pages',
  328 + ]
  329 + );
  330 + ?>
732 331
733 </div> 332 </div>
734 <!-- /.col-md-9 --> 333 <!-- /.col-md-9 -->
frontend/views/layouts/main.php
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 */ 7 */
8 use artbox\core\components\SeoComponent; 8 use artbox\core\components\SeoComponent;
9 use artbox\core\models\Feedback; 9 use artbox\core\models\Feedback;
  10 + use artbox\core\models\Image;
10 use artbox\core\models\Page; 11 use artbox\core\models\Page;
11 use artbox\core\models\User; 12 use artbox\core\models\User;
12 use common\models\LoginForm; 13 use common\models\LoginForm;
@@ -14,7 +15,6 @@ @@ -14,7 +15,6 @@
14 use common\models\SearchForm; 15 use common\models\SearchForm;
15 use common\models\Settings; 16 use common\models\Settings;
16 use frontend\assets\AppAsset; 17 use frontend\assets\AppAsset;
17 - use noam148\imagemanager\models\ImageManager;  
18 use yii\base\Model; 18 use yii\base\Model;
19 use yii\bootstrap\ActiveForm; 19 use yii\bootstrap\ActiveForm;
20 use yii\bootstrap\Html; 20 use yii\bootstrap\Html;
@@ -61,9 +61,9 @@ @@ -61,9 +61,9 @@
61 ->all(); 61 ->all();
62 $logo = null; 62 $logo = null;
63 if ($settings->logo) { 63 if ($settings->logo) {
64 - $logo_img = ImageManager::findOne($settings->logo); 64 + $logo_img = Image::findOne($settings->logo);
65 if ($logo_img) { 65 if ($logo_img) {
66 - $logo = $logo_img->getImagePathPrivate() ?? $logo; 66 + $logo = $logo_img->getUrl() ?? $logo;
67 } 67 }
68 } 68 }
69 69
frontend/views/product/view.php 0 → 100755
  1 +<?php
  2 + use artbox\catalog\models\OptionGroup;
  3 + use artbox\catalog\models\Product;
  4 + use artbox\catalog\models\Variant;
  5 + use artbox\core\components\SeoComponent;
  6 + use artbox\core\helpers\ImageHelper;
  7 + use yii\bootstrap\Html;
  8 + use yii\helpers\ArrayHelper;
  9 + use yii\web\View;
  10 +
  11 + /**
  12 + * @var View $this
  13 + * @var Product $model
  14 + * @var Variant $variant
  15 + * @var SeoComponent $seo
  16 + * @var array $groups
  17 + * @var Product[] $similar
  18 + */
  19 + $seo = \Yii::$app->get('seo');
  20 + if (!empty( $model->category )) {
  21 + if (!empty( $model->category->parent )) {
  22 + $this->params[ 'breadcrumbs' ][] = [
  23 + 'label' => $model->category->parent->lang->title,
  24 + 'url' => [
  25 + '/category/view',
  26 + 'id' => $model->category->parent->id,
  27 + ],
  28 + ];
  29 + }
  30 + $this->params[ 'breadcrumbs' ][] = [
  31 + 'label' => $model->category->lang->title,
  32 + 'url' => [
  33 + '/category/view',
  34 + 'id' => $model->category->id,
  35 + ],
  36 + ];
  37 + }
  38 + $this->params[ 'breadcrumbs' ][] = $seo->title;
  39 +?>
  40 +<div id="content">
  41 + <div class="container">
  42 + <div class="row">
  43 + <div class="col-md-12">
  44 +
  45 + <div class="row" id="productMain">
  46 + <div class="col-sm-6">
  47 + <div id="mainImage">
  48 + <?php
  49 + if (!empty( $model->images )) {
  50 + echo ImageHelper::set($model->images[ 0 ]->getPath())
  51 + ->fillResize(555, 555)
  52 + ->renderImage(
  53 + [
  54 + 'class' => 'img-responsive',
  55 + 'alt' => $model->lang->title,
  56 + 'title' => $model->lang->title,
  57 + ]
  58 + );
  59 + } else {
  60 + echo ImageHelper::set('@frontend/web/img/no-image.png')
  61 + ->fillResize(555, 555)
  62 + ->renderImage(
  63 + [
  64 + 'class' => 'img-responsive',
  65 + 'alt' => $model->lang->title,
  66 + 'title' => $model->lang->title,
  67 + ]
  68 + );
  69 + }
  70 + ?>
  71 + </div>
  72 +
  73 + <?php
  74 + if ($model->is(2)) {
  75 + ?>
  76 + <div class="ribbon sale">
  77 + <div class="theribbon">SALE</div>
  78 + <div class="ribbon-background"></div>
  79 + </div>
  80 + <!-- /.ribbon -->
  81 + <?php
  82 + }
  83 + if ($model->is(1)) {
  84 + ?>
  85 + <div class="ribbon new">
  86 + <div class="theribbon">NEW</div>
  87 + <div class="ribbon-background"></div>
  88 + </div>
  89 + <!-- /.ribbon -->
  90 + <?php
  91 + }
  92 + ?>
  93 +
  94 + <div class="row" id="thumbs">
  95 + <?php
  96 + if (!empty( $model->images )) {
  97 + foreach ($model->images as $image) {
  98 + echo Html::tag(
  99 + 'div',
  100 + Html::a(
  101 + ImageHelper::set($image->getPath())
  102 + ->fillResize(70, 60)
  103 + ->renderImage(
  104 + [
  105 + 'class' => 'img-responsive',
  106 + 'alt' => $model->lang->title,
  107 + 'title' => $model->lang->title,
  108 + ]
  109 + ),
  110 + ImageHelper::set($image->getPath())
  111 + ->fillResize(555, 555)
  112 + ->render(),
  113 + [
  114 + 'class' => 'thumb',
  115 + ]
  116 + ),
  117 + [
  118 + 'class' => 'col-xs-2',
  119 + ]
  120 + );
  121 + }
  122 + } else {
  123 + echo Html::tag(
  124 + 'div',
  125 + Html::a(
  126 + ImageHelper::set('@frontend/web/img/no-image.png')
  127 + ->fillResize(70, 60)
  128 + ->renderImage(
  129 + [
  130 + 'class' => 'img-responsive',
  131 + 'alt' => $model->lang->title,
  132 + 'title' => $model->lang->title,
  133 + ]
  134 + ),
  135 + ImageHelper::set('@frontend/web/img/no-image.png')
  136 + ->fillResize(555, 555)
  137 + ->render(),
  138 + [
  139 + 'class' => 'thumb',
  140 + ]
  141 + ),
  142 + [
  143 + 'class' => 'col-xs-2',
  144 + ]
  145 + );
  146 + }
  147 + ?>
  148 + </div>
  149 + <?php
  150 + if (!empty( $model->video )) {
  151 + ?>
  152 + <div class="product-video">
  153 + <div class="h3">
  154 + <?php echo \Yii::t('app', 'Видеообзор продукта'); ?>
  155 + </div>
  156 + <div class="video-box">
  157 + <?php echo $model->video; ?>
  158 + </div>
  159 + </div>
  160 + <?php
  161 + }
  162 + ?>
  163 + </div>
  164 + <div class="col-sm-6">
  165 + <div class="box">
  166 + <h1><?php echo $model->lang->title; ?></h1>
  167 + <p class="no-margin"><?php echo $variant->sku; ?></p>
  168 + <p class="price">
  169 + <span class="price-title">Цена:</span><?php echo $variant->price ? : 0; ?> грн&ensp;
  170 + <button class="btn btn-success">
  171 + <i class="fa fa-shopping-cart"></i> Добавить в корзину
  172 + </button>
  173 + <button class="btn btn-default pull-right" data-toggle="tooltip" data-placement="top" title="Добавить в избранное">
  174 + <i class="fa fa-heart-o"></i>
  175 + </button>
  176 + </p>
  177 + <hr>
  178 +
  179 + <button class="btn btn-template-main">
  180 + <i class="fa fa-phone"></i> Купить в один клик
  181 + </button>
  182 + &emsp;<button class="btn btn-template-main">
  183 + <i class="fa fa-tags"></i> Купить в кредит
  184 + </button>
  185 + </div>
  186 + <div class="box" id="details">
  187 + <h2><?php echo \Yii::t('app', 'Описание товара'); ?></h2>
  188 + <?php echo $model->lang->description ? : \Yii::t('app', 'Нет описания'); ?>
  189 + </div>
  190 +
  191 + <div class="box" id="details">
  192 + <h2><?php echo \Yii::t('app', 'Характеристики'); ?></h2>
  193 + <table class="table">
  194 + <tbody>
  195 + <?php
  196 + foreach ($groups as $group) {
  197 + foreach ($group as $optionGroup) {
  198 + /**
  199 + * @var OptionGroup $optionGroup
  200 + */
  201 + echo Html::tag(
  202 + 'tr',
  203 + Html::tag(
  204 + 'td',
  205 + $optionGroup->lang->title,
  206 + [ 'class' => 'td-title' ]
  207 + ) . Html::tag(
  208 + 'td',
  209 + implode(
  210 + ', ',
  211 + ArrayHelper::getColumn(
  212 + $optionGroup->currentOptions,
  213 + 'lang.value'
  214 + )
  215 + )
  216 + )
  217 + );
  218 + }
  219 + }
  220 + ?>
  221 + </tbody>
  222 + </table>
  223 + </div>
  224 + </div>
  225 +
  226 + </div>
  227 +
  228 + <?php
  229 + if (!empty( $similar )) {
  230 + ?>
  231 + <div class="heading text-center">
  232 + <h2><?php echo \Yii::t('app', 'Похожие товары'); ?></h2>
  233 + </div>
  234 +
  235 + <div class="product-carousel">
  236 + <div class="homepage owl-carousel">
  237 + <?php
  238 + $newItemsArrays = array_chunk($similar, 4);
  239 + foreach ($newItemsArrays as $newItemsArray) {
  240 + ?>
  241 + <div class="products">
  242 + <?php
  243 + foreach ($newItemsArray as $product) {
  244 + echo $this->render(
  245 + '@frontend/views/site/_slider_product',
  246 + [
  247 + 'product' => $product,
  248 + ]
  249 + );
  250 + }
  251 + ?>
  252 + </div>
  253 + <?php
  254 + }
  255 + ?>
  256 + </div>
  257 + </div>
  258 + <?php
  259 + }
  260 + ?>
  261 + </div>
  262 + <!-- /.col-md-9 -->
  263 + </div>
  264 + <!-- /.row -->
  265 + </div>
  266 + <!-- /.container -->
  267 +</div>
  268 +<!-- /#content -->
frontend/views/site/_slider_product.php
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 } 22 }
23 echo Html::a( 23 echo Html::a(
24 Html::img( 24 Html::img(
25 - $image ? $imageManager->getImagePath($image) : '/no-image.png', 25 + $image ? $imageManager->getImagePath($image) : '/img/no-image.png',
26 [ 26 [
27 'class' => 'img-responsive-image1', 27 'class' => 'img-responsive-image1',
28 ] 28 ]
frontend/web/css/style.css
@@ -2827,6 +2827,7 @@ p.no-margin { @@ -2827,6 +2827,7 @@ p.no-margin {
2827 -webkit-transition: all 0.2s ease-out; 2827 -webkit-transition: all 0.2s ease-out;
2828 -moz-transition: all 0.2s ease-out; 2828 -moz-transition: all 0.2s ease-out;
2829 transition: all 0.2s ease-out; 2829 transition: all 0.2s ease-out;
  2830 + max-width: 100%;
2830 } 2831 }
2831 2832
2832 .product-video { 2833 .product-video {
@@ -4493,3 +4494,34 @@ a.list-group-item.active &gt; .badge, @@ -4493,3 +4494,34 @@ a.list-group-item.active &gt; .badge,
4493 left: 15px; 4494 left: 15px;
4494 right: 15px; 4495 right: 15px;
4495 } 4496 }
  4497 +
  4498 +.radio-but{
  4499 + padding: 5px 0 5px 38px;
  4500 + position: relative;
  4501 + margin: 5px 0;
  4502 +}
  4503 +.radio-but a:before{
  4504 + content:'';
  4505 + position:absolute;
  4506 + left:0;
  4507 + top:0;
  4508 + width: 28px;
  4509 + height:28px;
  4510 + background: rgb(215, 220, 222);
  4511 + border-radius: 5px;
  4512 +}
  4513 +.radio-but.checked a:before{
  4514 + background: rgb(26, 188, 156);
  4515 +}
  4516 +.radio-but.checked a:after{
  4517 + content: '';
  4518 + position: absolute;
  4519 + left: 0;
  4520 + top: 0;
  4521 + width: 28px;
  4522 + height: 28px;
  4523 + background-image: url(../img/check.png);
  4524 + background-size: 70%;
  4525 + background-position: center;
  4526 + background-repeat: no-repeat;
  4527 +}
4496 \ No newline at end of file 4528 \ No newline at end of file
frontend/web/img/check.png 0 → 100644

14.9 KB