Commit d59bdbcdf62ef03227012bc7e600af2c9578dc46
Merge remote-tracking branch 'origin/master'
Showing
7 changed files
with
25 additions
and
55 deletions
Show diff stats
backend/models/Orders.php
@@ -61,9 +61,9 @@ class Orders extends \yii\db\ActiveRecord | @@ -61,9 +61,9 @@ class Orders extends \yii\db\ActiveRecord | ||
61 | public function beforeDelete() { | 61 | public function beforeDelete() { |
62 | return parent::beforeDelete(); | 62 | return parent::beforeDelete(); |
63 | } | 63 | } |
64 | - | 64 | + |
65 | public function getUser() | 65 | public function getUser() |
66 | - { | 66 | + { |
67 | return $this->hasOne(Customer::className(), ['id' => 'user_id']); | 67 | return $this->hasOne(Customer::className(), ['id' => 'user_id']); |
68 | } | 68 | } |
69 | 69 |
common/modules/product/CatalogUrlManager.php
@@ -45,7 +45,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -45,7 +45,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
45 | if($product_variant instanceof ProductVariant){ | 45 | if($product_variant instanceof ProductVariant){ |
46 | 46 | ||
47 | $link = 'product'.'/'. $product_variant->product->alias; | 47 | $link = 'product'.'/'. $product_variant->product->alias; |
48 | - header("Status: 301"); | 48 | + header("HTTP/1.1 301 Moved Permanently"); |
49 | header("Location: http://www.linija-svitla.ua/".$link); | 49 | header("Location: http://www.linija-svitla.ua/".$link); |
50 | die(); | 50 | die(); |
51 | } | 51 | } |
@@ -59,7 +59,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -59,7 +59,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
59 | if($product_variant instanceof ProductVariant){ | 59 | if($product_variant instanceof ProductVariant){ |
60 | 60 | ||
61 | $link = 'product'.'/'. $product_variant->product->alias; | 61 | $link = 'product'.'/'. $product_variant->product->alias; |
62 | - header("Status: 301"); | 62 | + header("HTTP/1.1 301 Moved Permanently"); |
63 | header("Location: http://www.linija-svitla.ua/".$link); | 63 | header("Location: http://www.linija-svitla.ua/".$link); |
64 | die(); | 64 | die(); |
65 | } | 65 | } |
@@ -72,7 +72,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -72,7 +72,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
72 | if($product_variant instanceof ProductVariant){ | 72 | if($product_variant instanceof ProductVariant){ |
73 | 73 | ||
74 | $link = 'product'.'/'. $product_variant->product->alias; | 74 | $link = 'product'.'/'. $product_variant->product->alias; |
75 | - header("Status: 301"); | 75 | + header("HTTP/1.1 301 Moved Permanently"); |
76 | header("Location: http://www.linija-svitla.ua/".$link); | 76 | header("Location: http://www.linija-svitla.ua/".$link); |
77 | die(); | 77 | die(); |
78 | } | 78 | } |
@@ -81,7 +81,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -81,7 +81,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
81 | 81 | ||
82 | if($product_variant instanceof ProductVariant){ | 82 | if($product_variant instanceof ProductVariant){ |
83 | $link = 'product'.'/'. $product_variant->product->alias; | 83 | $link = 'product'.'/'. $product_variant->product->alias; |
84 | - header("Status: 301"); | 84 | + header("HTTP/1.1 301 Moved Permanently"); |
85 | header("Location: http://www.linija-svitla.ua/".$link); | 85 | header("Location: http://www.linija-svitla.ua/".$link); |
86 | die(); | 86 | die(); |
87 | } | 87 | } |
@@ -91,7 +91,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -91,7 +91,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
91 | 91 | ||
92 | if($product_variant instanceof ProductVariant){ | 92 | if($product_variant instanceof ProductVariant){ |
93 | $link = 'product'.'/'. $product_variant->product->alias; | 93 | $link = 'product'.'/'. $product_variant->product->alias; |
94 | - header("Status: 301"); | 94 | + header("HTTP/1.1 301 Moved Permanently"); |
95 | header("Location: http://www.linija-svitla.ua/".$link); | 95 | header("Location: http://www.linija-svitla.ua/".$link); |
96 | die(); | 96 | die(); |
97 | } | 97 | } |
@@ -101,7 +101,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -101,7 +101,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
101 | 101 | ||
102 | if($product_variant instanceof ProductVariant){ | 102 | if($product_variant instanceof ProductVariant){ |
103 | $link = 'product'.'/'. $product_variant->product->alias; | 103 | $link = 'product'.'/'. $product_variant->product->alias; |
104 | - header("Status: 301"); | 104 | + header("HTTP/1.1 301 Moved Permanently"); |
105 | header("Location: http://www.linija-svitla.ua/".$link); | 105 | header("Location: http://www.linija-svitla.ua/".$link); |
106 | die(); | 106 | die(); |
107 | } | 107 | } |
@@ -114,7 +114,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -114,7 +114,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
114 | if($product_variant instanceof ProductVariant){ | 114 | if($product_variant instanceof ProductVariant){ |
115 | 115 | ||
116 | $link = 'product'.'/'. $product_variant->product->alias; | 116 | $link = 'product'.'/'. $product_variant->product->alias; |
117 | - header("Status: 301"); | 117 | + header("HTTP/1.1 301 Moved Permanently"); |
118 | header("Location: http://www.linija-svitla.ua/".$link); | 118 | header("Location: http://www.linija-svitla.ua/".$link); |
119 | die(); | 119 | die(); |
120 | } | 120 | } |
@@ -126,7 +126,7 @@ class CatalogUrlManager implements UrlRuleInterface { | @@ -126,7 +126,7 @@ class CatalogUrlManager implements UrlRuleInterface { | ||
126 | if($product_variant instanceof ProductVariant){ | 126 | if($product_variant instanceof ProductVariant){ |
127 | 127 | ||
128 | $link = 'product'.'/'. $product_variant->product->alias; | 128 | $link = 'product'.'/'. $product_variant->product->alias; |
129 | - header("Status: 301"); | 129 | + header("HTTP/1.1 301 Moved Permanently"); |
130 | header("Location: http://www.linija-svitla.ua/".$link); | 130 | header("Location: http://www.linija-svitla.ua/".$link); |
131 | die(); | 131 | die(); |
132 | } | 132 | } |
common/modules/product/models/BrandSearch.php
@@ -89,20 +89,7 @@ class BrandSearch extends Brand | @@ -89,20 +89,7 @@ class BrandSearch extends Brand | ||
89 | return $dataProvider; | 89 | return $dataProvider; |
90 | } | 90 | } |
91 | 91 | ||
92 | - public function getBrands($category = null, $params = [], $productQuery = null) { | ||
93 | -// $queryCount = ProductHelper::productCountQuery($category, $params, ['brands']); | ||
94 | - | ||
95 | - /*if (!empty($params['prices'])) { | ||
96 | - if ($params['prices']['min'] > 0) { | ||
97 | - $queryCount->andWhere(['>=', ProductVariant::tableName() .'.price', $params['prices']['min']]); | ||
98 | - } | ||
99 | - if ($params['prices']['max'] > 0) { | ||
100 | - $queryCount->andWhere(['<=', ProductVariant::tableName() .'.price', $params['prices']['max']]); | ||
101 | - } | ||
102 | - }*/ | ||
103 | -// if (!empty($params['options'])) { | ||
104 | -// $queryCount->innerJoin(TaxOption::tableName(), TaxOption::tableName()) | ||
105 | -// } | 92 | + public function getBrands($category = null) { |
106 | 93 | ||
107 | $query = Brand::find() | 94 | $query = Brand::find() |
108 | ->select([ | 95 | ->select([ |
@@ -112,33 +99,6 @@ class BrandSearch extends Brand | @@ -112,33 +99,6 @@ class BrandSearch extends Brand | ||
112 | ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id'); | 99 | ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id'); |
113 | 100 | ||
114 | 101 | ||
115 | -// $queryCount = Product::find() | ||
116 | -// ->select(['COUNT(product.product_id)']) | ||
117 | -// ->where('product.brand_id = brand.brand_id'); | ||
118 | -// $queryCount->andWhere('(SELECT COUNT(pv.product_variant_id) FROM "product_variant" "pv" WHERE pv.stock != 0 AND pv.product_id = product.product_id) > 0'); | ||
119 | -// if (!empty($category)) { | ||
120 | -// $queryCount->andWhere('(SELECT COUNT(pc.product_id) FROM product_category pc WHERE pc.product_id = product.product_id AND pc.category_id = '. $category->category_id .') > 0'); | ||
121 | -// } | ||
122 | -// if (!empty($params['options'])) { | ||
123 | -// $queryCount->innerJoin('product_option', 'product_option.product_id = product.product_id'); | ||
124 | -// $queryCount->innerJoin('tax_option', 'tax_option.tax_option_id = product_option.option_id'); | ||
125 | -// $queryCount->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id'); | ||
126 | -// foreach ($params['options'] as $group => $options) { | ||
127 | -// $queryCount->andWhere([ | ||
128 | -// 'tax_group.alias' => $group, | ||
129 | -// 'tax_option.alias' => $options | ||
130 | -// ]); | ||
131 | -// } | ||
132 | -//// $query->addSelect("(SELECT COUNT(product_option.product_id) AS products FROM product_option INNER JOIN tax_option ON tax_option.tax_option_id = product_option.option_id INNER JOIN tax_group ON tax_group.tax_group_id = tax_option.tax_group_id WHERE tax_group.alias LIKE '$group' AND tax_option.alias IN (" . implode(',', $options) . ")) AS _items_count"); | ||
133 | -// } | ||
134 | -// $query->addSelect(['_items_count' => $queryCount]); | ||
135 | - | ||
136 | -// if ($productQuery) { | ||
137 | -// $productQuery->select(['COUNT(product.product_id)']); | ||
138 | -// $query->addSelect(['_items_count' => $productQuery]); | ||
139 | -// } | ||
140 | - | ||
141 | - | ||
142 | $query->innerJoin('product_variant', 'product_variant.product_id = '. Product::tableName() .'.product_id'); | 102 | $query->innerJoin('product_variant', 'product_variant.product_id = '. Product::tableName() .'.product_id'); |
143 | $query->where(['!=', 'product_variant.status', 1]); | 103 | $query->where(['!=', 'product_variant.status', 1]); |
144 | $query->groupBy(Product::tableName() .'.product_id'); | 104 | $query->groupBy(Product::tableName() .'.product_id'); |
frontend/config/main.php
@@ -66,7 +66,7 @@ return [ | @@ -66,7 +66,7 @@ return [ | ||
66 | 'route_map' => [ | 66 | 'route_map' => [ |
67 | 'catalog' => 'catalog/category', | 67 | 'catalog' => 'catalog/category', |
68 | 'product' => 'catalog/product', | 68 | 'product' => 'catalog/product', |
69 | - '<product:^(.+)\.htm$>' => 'catalog/product', | 69 | + '<product:^(.+)\.htm$>' => 'catalog/product', //linija sveta |
70 | 70 | ||
71 | 71 | ||
72 | ] | 72 | ] |
frontend/views/catalog/products.php
@@ -2,9 +2,11 @@ | @@ -2,9 +2,11 @@ | ||
2 | /** | 2 | /** |
3 | * @var $productProvider \yii\data\ActiveDataProvider | 3 | * @var $productProvider \yii\data\ActiveDataProvider |
4 | * @var View $this | 4 | * @var View $this |
5 | + * @var ArrayDataProvider $productProvider | ||
5 | */ | 6 | */ |
6 | use frontend\widgets\FilterWidget; | 7 | use frontend\widgets\FilterWidget; |
7 | use frontend\widgets\Seo; | 8 | use frontend\widgets\Seo; |
9 | + use yii\data\ArrayDataProvider; | ||
8 | use yii\helpers\Url; | 10 | use yii\helpers\Url; |
9 | use yii\web\View; | 11 | use yii\web\View; |
10 | use yii\widgets\ListView; | 12 | use yii\widgets\ListView; |
@@ -16,7 +18,10 @@ | @@ -16,7 +18,10 @@ | ||
16 | 'depends' => ['yii\web\JqueryAsset'] | 18 | 'depends' => ['yii\web\JqueryAsset'] |
17 | ]); | 19 | ]); |
18 | 20 | ||
19 | -$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : $category->name; | 21 | + |
22 | + | ||
23 | + | ||
24 | + $this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : $category->name; | ||
20 | 25 | ||
21 | $this->params['seo']['fields']['meta-title'] = $category->meta_title; | 26 | $this->params['seo']['fields']['meta-title'] = $category->meta_title; |
22 | $this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name; | 27 | $this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name; |
@@ -25,7 +30,12 @@ $this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_ | @@ -25,7 +30,12 @@ $this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_ | ||
25 | 30 | ||
26 | 31 | ||
27 | $this->params['seo']['description'] = $category->meta_desc; | 32 | $this->params['seo']['description'] = $category->meta_desc; |
28 | - $this->params['seo']['meta'] = $category->meta_robots; | 33 | + if(empty($productProvider->allModels)){ |
34 | + $this->params['seo']['meta'] = 'noindex,nofollow'; | ||
35 | + }else{ | ||
36 | + $this->params['seo']['meta'] = $category->meta_robots; | ||
37 | + } | ||
38 | + | ||
29 | $this->params['seo']['category_name'] = $category->name; | 39 | $this->params['seo']['category_name'] = $category->name; |
30 | 40 | ||
31 | $this->params['breadcrumbs'][] = $category->name; | 41 | $this->params['breadcrumbs'][] = $category->name; |
frontend/views/layouts/main.php
@@ -421,6 +421,7 @@ use common\models\Event; | @@ -421,6 +421,7 @@ use common\models\Event; | ||
421 | <li><?php echo Html::a('Доставка', Url::to (['text/main', 'translit' => 'dostavka-tovarov'])) ?></li> | 421 | <li><?php echo Html::a('Доставка', Url::to (['text/main', 'translit' => 'dostavka-tovarov'])) ?></li> |
422 | <li><?php echo Html::a('Дисконтная программа', Url::to (['text/main', 'translit' => 'diskontnaya-programma'])) ?></li> | 422 | <li><?php echo Html::a('Дисконтная программа', Url::to (['text/main', 'translit' => 'diskontnaya-programma'])) ?></li> |
423 | <li><?php echo Html::a('О проекте', Url::to (['text/main', 'translit' => 'o-proekte'])) ?></li> | 423 | <li><?php echo Html::a('О проекте', Url::to (['text/main', 'translit' => 'o-proekte'])) ?></li> |
424 | + <li><?php echo Html::a('Каталоги', Url::to (['text/main', 'translit' => 'katalogi'])) ?></li> | ||
424 | </ul> | 425 | </ul> |
425 | </div> | 426 | </div> |
426 | </div> | 427 | </div> |
frontend/widgets/Seo.php
@@ -182,7 +182,6 @@ class Seo extends Widget | @@ -182,7 +182,6 @@ class Seo extends Widget | ||
182 | $paginate = \Yii::$app->request->get('page', []); | 182 | $paginate = \Yii::$app->request->get('page', []); |
183 | 183 | ||
184 | 184 | ||
185 | - | ||
186 | if (!empty($meta) && empty($sort) && empty($paginate) && !isset($filter['prices']) ) { | 185 | if (!empty($meta) && empty($sort) && empty($paginate) && !isset($filter['prices']) ) { |
187 | 186 | ||
188 | $this->getView()->registerMetaTag([ | 187 | $this->getView()->registerMetaTag([ |