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 | 61 | public function beforeDelete() { |
| 62 | 62 | return parent::beforeDelete(); |
| 63 | 63 | } |
| 64 | - | |
| 64 | + | |
| 65 | 65 | public function getUser() |
| 66 | - { | |
| 66 | + { | |
| 67 | 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 | 45 | if($product_variant instanceof ProductVariant){ |
| 46 | 46 | |
| 47 | 47 | $link = 'product'.'/'. $product_variant->product->alias; |
| 48 | - header("Status: 301"); | |
| 48 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 49 | 49 | header("Location: http://www.linija-svitla.ua/".$link); |
| 50 | 50 | die(); |
| 51 | 51 | } |
| ... | ... | @@ -59,7 +59,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 59 | 59 | if($product_variant instanceof ProductVariant){ |
| 60 | 60 | |
| 61 | 61 | $link = 'product'.'/'. $product_variant->product->alias; |
| 62 | - header("Status: 301"); | |
| 62 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 63 | 63 | header("Location: http://www.linija-svitla.ua/".$link); |
| 64 | 64 | die(); |
| 65 | 65 | } |
| ... | ... | @@ -72,7 +72,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 72 | 72 | if($product_variant instanceof ProductVariant){ |
| 73 | 73 | |
| 74 | 74 | $link = 'product'.'/'. $product_variant->product->alias; |
| 75 | - header("Status: 301"); | |
| 75 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 76 | 76 | header("Location: http://www.linija-svitla.ua/".$link); |
| 77 | 77 | die(); |
| 78 | 78 | } |
| ... | ... | @@ -81,7 +81,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 81 | 81 | |
| 82 | 82 | if($product_variant instanceof ProductVariant){ |
| 83 | 83 | $link = 'product'.'/'. $product_variant->product->alias; |
| 84 | - header("Status: 301"); | |
| 84 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 85 | 85 | header("Location: http://www.linija-svitla.ua/".$link); |
| 86 | 86 | die(); |
| 87 | 87 | } |
| ... | ... | @@ -91,7 +91,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 91 | 91 | |
| 92 | 92 | if($product_variant instanceof ProductVariant){ |
| 93 | 93 | $link = 'product'.'/'. $product_variant->product->alias; |
| 94 | - header("Status: 301"); | |
| 94 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 95 | 95 | header("Location: http://www.linija-svitla.ua/".$link); |
| 96 | 96 | die(); |
| 97 | 97 | } |
| ... | ... | @@ -101,7 +101,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 101 | 101 | |
| 102 | 102 | if($product_variant instanceof ProductVariant){ |
| 103 | 103 | $link = 'product'.'/'. $product_variant->product->alias; |
| 104 | - header("Status: 301"); | |
| 104 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 105 | 105 | header("Location: http://www.linija-svitla.ua/".$link); |
| 106 | 106 | die(); |
| 107 | 107 | } |
| ... | ... | @@ -114,7 +114,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 114 | 114 | if($product_variant instanceof ProductVariant){ |
| 115 | 115 | |
| 116 | 116 | $link = 'product'.'/'. $product_variant->product->alias; |
| 117 | - header("Status: 301"); | |
| 117 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 118 | 118 | header("Location: http://www.linija-svitla.ua/".$link); |
| 119 | 119 | die(); |
| 120 | 120 | } |
| ... | ... | @@ -126,7 +126,7 @@ class CatalogUrlManager implements UrlRuleInterface { |
| 126 | 126 | if($product_variant instanceof ProductVariant){ |
| 127 | 127 | |
| 128 | 128 | $link = 'product'.'/'. $product_variant->product->alias; |
| 129 | - header("Status: 301"); | |
| 129 | + header("HTTP/1.1 301 Moved Permanently"); | |
| 130 | 130 | header("Location: http://www.linija-svitla.ua/".$link); |
| 131 | 131 | die(); |
| 132 | 132 | } | ... | ... |
common/modules/product/models/BrandSearch.php
| ... | ... | @@ -89,20 +89,7 @@ class BrandSearch extends Brand |
| 89 | 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 | 94 | $query = Brand::find() |
| 108 | 95 | ->select([ |
| ... | ... | @@ -112,33 +99,6 @@ class BrandSearch extends Brand |
| 112 | 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 | 102 | $query->innerJoin('product_variant', 'product_variant.product_id = '. Product::tableName() .'.product_id'); |
| 143 | 103 | $query->where(['!=', 'product_variant.status', 1]); |
| 144 | 104 | $query->groupBy(Product::tableName() .'.product_id'); | ... | ... |
frontend/config/main.php
frontend/views/catalog/products.php
| ... | ... | @@ -2,9 +2,11 @@ |
| 2 | 2 | /** |
| 3 | 3 | * @var $productProvider \yii\data\ActiveDataProvider |
| 4 | 4 | * @var View $this |
| 5 | + * @var ArrayDataProvider $productProvider | |
| 5 | 6 | */ |
| 6 | 7 | use frontend\widgets\FilterWidget; |
| 7 | 8 | use frontend\widgets\Seo; |
| 9 | + use yii\data\ArrayDataProvider; | |
| 8 | 10 | use yii\helpers\Url; |
| 9 | 11 | use yii\web\View; |
| 10 | 12 | use yii\widgets\ListView; |
| ... | ... | @@ -16,7 +18,10 @@ |
| 16 | 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 | 26 | $this->params['seo']['fields']['meta-title'] = $category->meta_title; |
| 22 | 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 | 30 | |
| 26 | 31 | |
| 27 | 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 | 39 | $this->params['seo']['category_name'] = $category->name; |
| 30 | 40 | |
| 31 | 41 | $this->params['breadcrumbs'][] = $category->name; | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -421,6 +421,7 @@ use common\models\Event; |
| 421 | 421 | <li><?php echo Html::a('Доставка', Url::to (['text/main', 'translit' => 'dostavka-tovarov'])) ?></li> |
| 422 | 422 | <li><?php echo Html::a('Дисконтная программа', Url::to (['text/main', 'translit' => 'diskontnaya-programma'])) ?></li> |
| 423 | 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 | 425 | </ul> |
| 425 | 426 | </div> |
| 426 | 427 | </div> | ... | ... |
frontend/widgets/Seo.php