Commit 38828295b07deef496f4d4c74e74a890d4fcb6ca

Authored by Karnovsky A
1 parent 1bdd1646

-

backend/views/brand/index.php
... ... @@ -26,6 +26,13 @@ $this->params['breadcrumbs'][] = $this->title;
26 26  
27 27 'name',
28 28 'alias',
  29 + [
  30 + 'attribute' => 'title',
  31 + 'format' => 'html',
  32 + 'value' => function($data) {
  33 + return Html::img($data->imageUrl, ['width'=>'100']);
  34 + },
  35 + ],
29 36  
30 37 ['class' => 'yii\grid\ActionColumn'],
31 38 ],
... ...
common/config/main.php
... ... @@ -90,6 +90,20 @@ return [
90 90 'master' => null
91 91 ],
92 92 ],
  93 + 'product_basket' => [
  94 + 'resize' => [
  95 + 'width' => 100,
  96 + 'height' => 200,
  97 + 'master' => null
  98 + ],
  99 + ],
  100 + 'iam' => [
  101 + 'resize' => [
  102 + 'width' => 120,
  103 + 'height' => 240,
  104 + 'master' => null
  105 + ],
  106 + ],
93 107 'slider' => [
94 108 'resize' => [
95 109 'width' => 720,
... ... @@ -104,6 +118,18 @@ return [
104 118 'master' => null
105 119 ],
106 120 ],
  121 + 'brand_item' => [
  122 + 'resize' => [
  123 + 'width' => 150,
  124 + 'height' => 150,
  125 + 'master' => null
  126 + ],
  127 + 'crop' => [
  128 + 'width' => 150,
  129 + 'height' => 150,
  130 + 'master' => null
  131 + ],
  132 + ],
107 133 'mainmenu' => [
108 134 'resize' => [
109 135 'width' => 160,
... ...
common/modules/product/CatalogUrlManager.php
... ... @@ -3,6 +3,7 @@
3 3 namespace common\modules\product;
4 4  
5 5 use common\modules\product\models\Brand;
  6 +use common\modules\product\models\BrandSearch;
6 7 use common\modules\product\models\CategorySearch;
7 8 use common\modules\product\models\ProductSearch;
8 9 use common\modules\rubrication\models\TaxOption;
... ... @@ -78,8 +79,15 @@ class CatalogUrlManager implements UrlRuleInterface {
78 79 $params = [
79 80 'product' => $product,
80 81 ];
81   - } elseif ($paths[0] == 'brand') {
82   -
  82 + } elseif ($paths[0] == 'brands') {
  83 + if (empty($paths[1]) || $paths[1] == 'index') {
  84 + $route = 'catalog/brands';
  85 + } elseif (($brand = BrandSearch::findByAlias($paths[1]))) {
  86 + $route = 'catalog/brands';
  87 + $params['brand'] = $brand;
  88 + } else {
  89 + // @todo redirect or return FALSE
  90 + }
83 91 }
84 92  
85 93 return [$route, $params];
... ... @@ -169,6 +177,21 @@ class CatalogUrlManager implements UrlRuleInterface {
169 177  
170 178 return $url;
171 179 break;
  180 +
  181 + case 'catalog/brands':
  182 + if (empty($params['brand'])) {
  183 + return 'brands';
  184 + } else {
  185 + $brand_alias = is_object($params['brand']) ? $params['brand']->alias : strtolower($params['brand']);
  186 + }
  187 + $url = 'brands/'. $brand_alias;
  188 +
  189 + if (!empty($params) && ($query = http_build_query($params)) !== '') {
  190 + $url .= '?' . $query;
  191 + }
  192 +
  193 + return $url;
  194 + break;
172 195 }
173 196 }
174 197  
... ...
common/modules/product/models/BrandSearch.php
... ... @@ -81,6 +81,8 @@ class BrandSearch extends Brand
81 81 ->andFilterWhere(['ilike', 'seo_text', $this->seo_text])
82 82 ->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]);
83 83  
  84 + $query->orderBy('brand_id', 'asc');
  85 +
84 86 return $dataProvider;
85 87 }
86 88  
... ... @@ -121,4 +123,16 @@ class BrandSearch extends Brand
121 123  
122 124 return $dataProvider;
123 125 }
  126 +
  127 + public static function findByAlias($alias) {
  128 + /** @var CategoryQuery $query */
  129 + $query = Brand::find()
  130 + ->with('brandName')
  131 + ->andFilterWhere(['alias' => $alias]);
  132 + if (($model = $query->one()) !== null) {
  133 + return $model;
  134 + } else {
  135 + throw new NotFoundHttpException('The requested page does not exist.');
  136 + }
  137 + }
124 138 }
... ...
common/modules/product/models/Category.php
... ... @@ -176,12 +176,12 @@ class Category extends \yii\db\ActiveRecord
176 176 }
177 177  
178 178 public function getImageFile() {
179   - return empty($this->image) ? null : Yii::getAlias('@imagesDir/categories/'. $this->image);
  179 + return empty($this->image) ? '/images/no_photo.png' : Yii::getAlias('@imagesDir/categories/'. $this->image);
180 180 }
181 181  
182 182 public function getImageUrl()
183 183 {
184   - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/categories/' . $this->image);
  184 + return empty($this->image) ? '/images/no_photo.png' : Yii::getAlias('@imagesUrl/categories/' . $this->image);
185 185 }
186 186  
187 187 public function beforeSave($insert)
... ...
common/modules/product/models/CategorySearch.php
... ... @@ -82,7 +82,7 @@ class CategorySearch extends Category
82 82  
83 83 $query->andFilterWhere(['like', 'alias', $this->alias]);
84 84  
85   - $query->orderBy(['path' => SORT_ASC, 'depth' => SORT_ASC]);
  85 + $query->orderBy(['path' => SORT_ASC, 'depth' => SORT_ASC, 'category_id' => SORT_ASC]);
86 86  
87 87 return $dataProvider;
88 88 }
... ...
common/modules/product/models/Product.php
... ... @@ -221,7 +221,7 @@ class Product extends \yii\db\ActiveRecord
221 221 if (!is_array($_variant)) {
222 222 return;
223 223 }
224   - if (!empty($_variant['product_variant_id'])) {
  224 + if (!empty($_variant['product_variant_id'])) {
225 225 unset($todel[$_variant['product_variant_id']]);
226 226 $model = ProductVariant::findOne($_variant['product_variant_id']);
227 227 } else {
... ...
common/modules/product/models/ProductSearch.php
... ... @@ -15,6 +15,7 @@ class ProductSearch extends Product
15 15 {
16 16 public $brand_name;
17 17 public $category_name;
  18 + public $variant_sku;
18 19  
19 20 /**
20 21 * @inheritdoc
... ... @@ -22,9 +23,9 @@ class ProductSearch extends Product
22 23 public function rules()
23 24 {
24 25 return [
25   - [['name', 'brand_name', 'category_name'], 'safe'],
  26 + [['name', 'brand_name', 'category_name', 'variant_sku'], 'safe'],
26 27 [['tax_brand_id', 'product_id'], 'integer'],
27   - [['is_top', 'is_new'], 'boolean'],
  28 + [['is_top', 'is_new', 'akciya'], 'boolean'],
28 29 ];
29 30 }
30 31  
... ... @@ -65,12 +66,18 @@ class ProductSearch extends Product
65 66 $dataProvider->setSort([
66 67 'attributes' => [
67 68 'name',
68   - 'brand_name',
69   - 'category_name'
  69 + 'brand_name' => [
  70 + 'asc' => ['brand_name.value' => SORT_ASC],
  71 + 'desc' => ['brand_name.value' => SORT_DESC],
  72 + 'default' => SORT_DESC,
  73 + 'label' => 'Brand name',
  74 + ],
  75 + 'category_name',
  76 + 'variant_sku',
70 77 ]
71 78 ]);
72 79  
73   - $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames']);
  80 + $query->joinWith(['brand', 'brand.brandNames', 'categories', 'categories.categoryNames', 'variant']);
74 81  
75 82 if (isset($this->is_top)) {
76 83 $query->andFilterWhere([
... ... @@ -95,7 +102,9 @@ class ProductSearch extends Product
95 102 $query->andFilterWhere(['ilike', 'name', $this->name]);
96 103 $query->andFilterWhere(['ilike', 'brand_name.value', $this->brand_name]);
97 104 $query->andFilterWhere(['ilike', 'category_name.value', $this->category_name]);
  105 + $query->andFilterWhere(['ilike', 'product_variant.sku', $this->variant_sku]);
98 106  
  107 + $query->groupBy(['product.product_id']);
99 108 $query->orderBy('product.product_id', 'DESC');
100 109  
101 110 return $dataProvider;
... ...
common/modules/product/models/ProductVariant.php
... ... @@ -132,6 +132,10 @@ class ProductVariant extends \yii\db\ActiveRecord
132 132 return !empty($this->image) ? $this->image->imageUrl : '/images/no_photo.png';
133 133 }
134 134  
  135 + public function getFullname() {
  136 + return empty($this->product) ? null : ($this->product->name . (empty($this->name) ? '' : ' '. $this->name));
  137 + }
  138 +
135 139 /**
136 140 * @return \yii\db\ActiveQuery
137 141 */
... ...
common/modules/product/models/ProductVariantSearch.php
... ... @@ -12,14 +12,21 @@ use yii\web\NotFoundHttpException;
12 12 */
13 13 class ProductVariantSearch extends ProductVariant
14 14 {
  15 + public $brand_name;
  16 + public $category_name;
  17 + public $tax_group_id;
  18 + public $is_top;
  19 + public $is_new;
  20 + public $akciya;
15 21 /**
16 22 * @inheritdoc
17 23 */
18 24 public function rules()
19 25 {
20 26 return [
21   - [['name', 'sku', 'price', 'price_old', 'stock'], 'safe'],
  27 + [['name', 'fullname', 'sku', 'price', 'price_old', 'stock', 'fullname', 'brand_name', 'category_name'], 'safe'],
22 28 [['product_variant_id', 'product_id'], 'integer'],
  29 + [['is_top', 'is_new', 'akciya'], 'boolean'],
23 30 ];
24 31 }
25 32  
... ... @@ -57,14 +64,54 @@ class ProductVariantSearch extends ProductVariant
57 64 return $dataProvider;
58 65 }
59 66  
  67 + $dataProvider->setSort([
  68 + 'attributes' => [
  69 + 'name',
  70 + 'brand_name' => [
  71 + 'asc' => ['brand_name.value' => SORT_ASC],
  72 + 'desc' => ['brand_name.value' => SORT_DESC],
  73 + 'default' => SORT_DESC,
  74 + 'label' => 'Brand name',
  75 + ],
  76 + 'category_name',
  77 + 'sku',
  78 + ]
  79 + ]);
  80 +
  81 + $query->joinWith(['product', 'product.brand.brandNames', 'product.categories', 'product.categories.categoryNames']);
  82 +
  83 + if (isset($this->is_top)) {
  84 + $query->andFilterWhere([
  85 + 'product.is_top' => (bool)$this->is_top,
  86 + ]);
  87 + }
  88 + if (isset($this->is_new)) {
  89 + $query->andFilterWhere([
  90 + 'product.is_new' => (bool)$this->is_new,
  91 + ]);
  92 + }
  93 + if (isset($this->akciya)) {
  94 + $query->andFilterWhere([
  95 + 'product.akciya' => (bool)$this->akciya,
  96 + ]);
  97 + }
  98 +
60 99 // grid filtering conditions
61 100 $query->andFilterWhere([
  101 + 'product.product_id' => $this->product_id,
62 102 'product_variant_id' => $this->product_variant_id,
63   - 'product_id' => $this->product_id,
64 103 ]);
65 104  
66   - $query->andFilterWhere(['like', 'name', $this->name])
67   - ->andFilterWhere(['like', 'sku', $this->sku]);
  105 + if (!empty($this->fullname)) {
  106 + $query->orFilterWhere(['like', 'name', $this->fullname]);
  107 + $query->orFilterWhere(['ilike', 'product.name', $this->fullname]);
  108 + }
  109 + $query->andFilterWhere(['ilike', 'product.brand_name.value', $this->brand_name]);
  110 + $query->andFilterWhere(['ilike', 'product.category_name.value', $this->category_name]);
  111 + $query->andFilterWhere(['ilike', 'sku', $this->sku]);
  112 +
  113 + $query->groupBy(['product_variant_id']);
  114 + $query->orderBy('product.product_id', 'DESC');
68 115  
69 116 return $dataProvider;
70 117 }
... ...
common/modules/product/views/manage/index.php
... ... @@ -34,6 +34,11 @@ $this->params['breadcrumbs'][] = $this->title;
34 34 'attribute' => 'category_name',
35 35 'value' => 'category.name',
36 36 ],
  37 + [
  38 + 'label' => Yii::t('product', 'SKU'),
  39 + 'attribute' => 'variant_sku',
  40 + 'value' => 'variant.sku',
  41 + ],
37 42 'variant.price',
38 43 'variant.stock_caption',
39 44  
... ...
common/modules/rubrication/models/TaxGroup.php
... ... @@ -15,7 +15,7 @@ use Yii;
15 15 * @property string $module
16 16 * @property boolean $hierarchical
17 17 * @property string $settings
18   - * @property boolean is_filter
  18 + * @property boolean $is_filter
19 19 *
20 20 * @property TaxGroupToGroup[] $taxGroupToGroups
21 21 * @property TaxGroupToGroup[] $taxGroupToGroups0
... ... @@ -62,7 +62,7 @@ class TaxGroup extends \yii\db\ActiveRecord
62 62 return [
63 63 [['name', 'module'], 'required'],
64 64 [['description', 'settings'], 'string'],
65   - [['hierarchical'], 'boolean'],
  65 + [['hierarchical', 'is_filter'], 'boolean'],
66 66 [['alias', 'module'], 'string', 'max' => 50],
67 67 [['name'], 'string', 'max' => 255],
68 68 [['group_to_category'], 'safe']
... ...
common/modules/rubrication/views/tax-group/index.php
... ... @@ -25,6 +25,7 @@ $this->params['breadcrumbs'][] = $this->title;
25 25 'description:ntext',
26 26 'module',
27 27 'hierarchical:boolean',
  28 + 'is_filter:boolean',
28 29 // 'settings:ntext',
29 30  
30 31 [
... ...
common/modules/rubrication/views/tax-group/view.php
... ... @@ -35,6 +35,7 @@ $this->params['breadcrumbs'][] = $this->title;
35 35 'description:ntext',
36 36 'module',
37 37 'hierarchical:boolean',
  38 + 'is_filter:boolean',
38 39 'settings:ntext',
39 40 ],
40 41 ]) ?>
... ...
common/translation/ru/product.php
... ... @@ -11,5 +11,6 @@ return [
11 11 'Promo products' => 'Акционные товары',
12 12 'New products' => 'Новинки',
13 13 'Top products' => 'Популярные',
14   - '' => '',
  14 + 'Brands' => 'Бренды',
  15 + 'Brand' => 'Бренд',
15 16 ];
16 17 \ No newline at end of file
... ...
frontend/config/main.php
... ... @@ -71,7 +71,7 @@ return [
71 71 'route_map' => [
72 72 'catalog' => 'catalog/category',
73 73 'product' => 'catalog/product',
74   - 'brand' => 'catalog/brand',
  74 + 'brands' => 'catalog/brands',
75 75 ]
76 76 ],
77 77 // 'catalog' => 'catalog/all',
... ...
frontend/controllers/CatalogController.php
... ... @@ -191,7 +191,16 @@ class CatalogController extends \yii\web\Controller
191 191  
192 192 public function actionBrands()
193 193 {
194   - return 'actionBrands';
  194 + $dataProvider = new ActiveDataProvider([
  195 + 'query' => Brand::find()->joinWith('brandName')->orderBy('brand_name.value'),
  196 + 'pagination' => [
  197 + 'pageSize' => -1,
  198 + ]
  199 + ]);
  200 +
  201 + return $this->render('brands', [
  202 + 'dataProvider' => $dataProvider,
  203 + ]);
195 204 }
196 205  
197 206 public function actionBrand($alias)
... ...
frontend/views/basket/ajax_items.php
... ... @@ -7,7 +7,9 @@ use yii\helpers\Html;
7 7 <div class="basket_item">
8 8 <?php echo $form->field($item,'['.$i.']id')->hiddenInput()->label(false); ?>
9 9 <div style="display: table-cell;vertical-align: middle;"><a href="#" data-id="<?=$item->id?>" class="delete_button" style="margin-right:20px;"></a></div>
10   - <div style="width:100px;height:100px;display: table-cell;vertical-align: middle; border:1px solid #d2d2d2;text-align:center;margin-left:10px;margin-right:10px;"><img src="<?=Yii::$app->request->baseUrl.'/upload/products/ico/'.$item->image->image?>" style="margin:0;" width="100"></div>
  10 + <div style="width:100px;height:100px;display: table-cell;vertical-align: middle; border:1px solid #d2d2d2;text-align:center;margin-left:10px;margin-right:10px;">
  11 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($item->imageUrl, 'product_basket')?>
  12 + </div>
11 13 <div style="display: table-cell;vertical-align: middle; font-size:15px;width:210px; font-weight:normal;padding-left:15px;">
12 14 <div><?=$item->product_name?></div>
13 15 <div style="text-transform:none; margin-top:20px; font-weight:bold;">
... ...
frontend/views/basket/index.php
... ... @@ -77,7 +77,9 @@ $(&#39;#order-delivery input[type=\&quot;radio\&quot;]&#39;).click(function(){
77 77  
78 78 <?php foreach($basket_mods as $i=>$item):?>
79 79 <div class="basket_item">
80   - <a href="<?=Url::to(['products/show','translit_rubric'=>$item->translit_rubric,'translit'=>$item->translit,'id'=>$item->product_id])?>"><img src="<?=Yii::$app->request->baseUrl.'/upload/products/ico/'.$item->image->image?>" border="0" width="90" height="120" align="left" /></a>
  80 + <a href="<?=Url::to(['products/show','translit_rubric'=>$item->translit_rubric,'translit'=>$item->translit,'id'=>$item->product_id])?>">
  81 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($item->imageUrl, 'product_basket')?>
  82 + </a>
81 83 <div class="info">
82 84 <a href="<?=Url::to(['products/show','translit_rubric'=>$item->translit_rubric,'translit'=>$item->translit,'id'=>$item->product_id])?>" class="link2"><?=$item->product_name?></a>
83 85 <p>Код: <?=$item->sku?>, цвет: <?=$item->name?></p>
... ...
frontend/views/catalog/brands.php 0 → 100644
  1 +<?php
  2 +use yii\widgets\Breadcrumbs;
  3 +use yii\grid\GridView;
  4 +
  5 +$this->params['breadcrumbs'][] = Yii::t('product', 'Brands');
  6 +
  7 +$this->params['seo']['seo_text'] = 'Brands SEO-text';
  8 +$this->params['seo']['h1'] = Yii::t('product', 'Brands');
  9 +$this->params['seo']['description'] = 'Brands DESCRIPTION';
  10 +$this->params['seo']['fields']['name'] = 'Brands NAME FROM FIELD';
  11 +$this->params['seo']['key']= 'brands';
  12 +?>
  13 +
  14 +<nav class="bread-crumbs">
  15 + <?= Breadcrumbs::widget ([
  16 + 'links' => $this->params['breadcrumbs'],
  17 +])
  18 + ?>
  19 +<div class="both"></div>
  20 +</nav>
  21 +
  22 +<div class="loyout">
  23 + <h1><?= $this->params['seo']['h1']?></h1>
  24 + <ul class="brends_list">
  25 + <?php foreach($dataProvider->models as $brand) :?>
  26 + <li>
  27 + <a href="<?= \yii\helpers\Url::to(['catalog/brands', 'brand' => $brand])?>"><?= \common\components\artboximage\ArtboxImageHelper::getImage($brand->imageUrl, 'brand_item')?></a>
  28 + <br>
  29 + <a href="<?= \yii\helpers\Url::to(['catalog/brands', 'brand' => $brand])?>" class="name"><?= $brand->name?></a>
  30 + </li>
  31 + <?php endforeach?>
  32 + </ul>
  33 + <div class="both"></div>
  34 +</div>
0 35 \ No newline at end of file
... ...
frontend/views/iam/share.php
... ... @@ -55,7 +55,9 @@ $this-&gt;registerJs(&quot;
55 55 <?foreach($item->shareList as $item_p):if(!empty($item_p->product)):?>
56 56 <div class="order">
57 57 <div><a href="<?=Url::to(['iam/share','deleteID'=>$item_p->id])?>" class="delete_button"></a></div>
58   - <div class="pixbox"><a href="<?=Url::to(['products/show','translit_rubric'=>$item_p->product->catalog->translit,'translit'=>$item_p->product->translit,'id'=>$item_p->product->id])?>"><img width="120" src="<?=Yii::$app->request->baseUrl.'/upload/products/ico/'.$item_p->product->imageAvator?>"></a></div>
  58 + <div class="pixbox"><a href="<?=Url::to(['products/show','translit_rubric'=>$item_p->product->catalog->translit,'translit'=>$item_p->product->translit,'id'=>$item_p->product->id])?>">
  59 + <?= \common\components\artboximage\ArtboxImageHelper::getImage($item_p->product->imageUrl, 'iam')?>
  60 + </div>
59 61 <div class="order_title"><a href="<?=Url::to(['products/show','translit_rubric'=>$item_p->product->catalog->translit,'translit'=>$item_p->product->translit,'id'=>$item_p->product->id])?>" class="name"><?=$item_p->product->name?></a></div>
60 62 <?if(!empty($item_p->product->cost->cost)):?><div class="order_price"><span><?=$item_p->product->cost->cost?></span> грн.</div><?endif;?>
61 63 <p class="note"></p>
... ...
frontend/views/layouts/main-menu.php
... ... @@ -7,6 +7,6 @@ use yii\helpers\Url;
7 7 <div class="fr">
8 8 <ul>
9 9 <li class="akciya"><a href="<?= Url::to (['event/index',]) ?>">Акции</a></li>
10   - <li class="brands"><a href="<?= Url::to (['brand/index']) ?>">Бренды</a></li>
  10 + <li class="brands"><a href="<?= Url::to (['catalog/brands']) ?>">Бренды</a></li>
11 11 </ul>
12 12 </div>
... ...
frontend/web/css/style.css
... ... @@ -244,11 +244,13 @@ ul.product_colors li img{border:1px solid #d2d2d2;}
244 244 }
245 245 .help-block{color:red;font-size:12px;margin-bottom:5px;}
246 246  
247   -.basket_item{padding:10px 0px;border-bottom:1px solid #b7b7b7;}
  247 +.basket_item{padding:10px 0px;border-bottom:1px solid #b7b7b7;clear: both}
248 248 .basket_item img{margin-right:20px;}
249 249 .basket_item .count{margin:20px 0px;}
250 250 .basket_item .fr{margin-top:5px;}
251 251 .basket_item .info{overflow:hidden;}
  252 +.basket_item > a{display: block;
  253 + float: left;}
252 254 a.del:visited,a.del:link{background:url('../img/del.png') left center no-repeat;padding:2px 25px;font-size:12px;font-weight:normal;color:#787878;text-decoration: underline;}
253 255 a.del:hover{color:#a52828;text-decoration: underline;}
254 256  
... ...