diff --git a/backend/models/Orders.php b/backend/models/Orders.php index 982e623..9bfd0bf 100755 --- a/backend/models/Orders.php +++ b/backend/models/Orders.php @@ -61,9 +61,9 @@ class Orders extends \yii\db\ActiveRecord public function beforeDelete() { return parent::beforeDelete(); } - + public function getUser() - { + { return $this->hasOne(Customer::className(), ['id' => 'user_id']); } diff --git a/common/modules/product/CatalogUrlManager.php b/common/modules/product/CatalogUrlManager.php index 5733d35..2332d8c 100755 --- a/common/modules/product/CatalogUrlManager.php +++ b/common/modules/product/CatalogUrlManager.php @@ -45,7 +45,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -59,7 +59,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -72,7 +72,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -81,7 +81,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -91,7 +91,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -101,7 +101,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -114,7 +114,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } @@ -126,7 +126,7 @@ class CatalogUrlManager implements UrlRuleInterface { if($product_variant instanceof ProductVariant){ $link = 'product'.'/'. $product_variant->product->alias; - header("Status: 301"); + header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.linija-svitla.ua/".$link); die(); } diff --git a/common/modules/product/models/BrandSearch.php b/common/modules/product/models/BrandSearch.php index ac3c348..2e800e0 100755 --- a/common/modules/product/models/BrandSearch.php +++ b/common/modules/product/models/BrandSearch.php @@ -89,20 +89,7 @@ class BrandSearch extends Brand return $dataProvider; } - public function getBrands($category = null, $params = [], $productQuery = null) { -// $queryCount = ProductHelper::productCountQuery($category, $params, ['brands']); - - /*if (!empty($params['prices'])) { - if ($params['prices']['min'] > 0) { - $queryCount->andWhere(['>=', ProductVariant::tableName() .'.price', $params['prices']['min']]); - } - if ($params['prices']['max'] > 0) { - $queryCount->andWhere(['<=', ProductVariant::tableName() .'.price', $params['prices']['max']]); - } - }*/ -// if (!empty($params['options'])) { -// $queryCount->innerJoin(TaxOption::tableName(), TaxOption::tableName()) -// } + public function getBrands($category = null) { $query = Brand::find() ->select([ @@ -112,33 +99,6 @@ class BrandSearch extends Brand ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.product_id='. Product::tableName() .'.product_id'); -// $queryCount = Product::find() -// ->select(['COUNT(product.product_id)']) -// ->where('product.brand_id = brand.brand_id'); -// $queryCount->andWhere('(SELECT COUNT(pv.product_variant_id) FROM "product_variant" "pv" WHERE pv.stock != 0 AND pv.product_id = product.product_id) > 0'); -// if (!empty($category)) { -// $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'); -// } -// if (!empty($params['options'])) { -// $queryCount->innerJoin('product_option', 'product_option.product_id = product.product_id'); -// $queryCount->innerJoin('tax_option', 'tax_option.tax_option_id = product_option.option_id'); -// $queryCount->innerJoin('tax_group', 'tax_group.tax_group_id = tax_option.tax_group_id'); -// foreach ($params['options'] as $group => $options) { -// $queryCount->andWhere([ -// 'tax_group.alias' => $group, -// 'tax_option.alias' => $options -// ]); -// } -//// $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"); -// } -// $query->addSelect(['_items_count' => $queryCount]); - -// if ($productQuery) { -// $productQuery->select(['COUNT(product.product_id)']); -// $query->addSelect(['_items_count' => $productQuery]); -// } - - $query->innerJoin('product_variant', 'product_variant.product_id = '. Product::tableName() .'.product_id'); $query->where(['!=', 'product_variant.status', 1]); $query->groupBy(Product::tableName() .'.product_id'); diff --git a/frontend/config/main.php b/frontend/config/main.php index ac8e91d..d7ddf9c 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -66,7 +66,7 @@ return [ 'route_map' => [ 'catalog' => 'catalog/category', 'product' => 'catalog/product', - '' => 'catalog/product', + '' => 'catalog/product', //linija sveta ] diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php index 91de487..edd5d54 100755 --- a/frontend/views/catalog/products.php +++ b/frontend/views/catalog/products.php @@ -2,9 +2,11 @@ /** * @var $productProvider \yii\data\ActiveDataProvider * @var View $this + * @var ArrayDataProvider $productProvider */ use frontend\widgets\FilterWidget; use frontend\widgets\Seo; + use yii\data\ArrayDataProvider; use yii\helpers\Url; use yii\web\View; use yii\widgets\ListView; @@ -16,7 +18,10 @@ 'depends' => ['yii\web\JqueryAsset'] ]); -$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : $category->name; + + + + $this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : $category->name; $this->params['seo']['fields']['meta-title'] = $category->meta_title; $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_ $this->params['seo']['description'] = $category->meta_desc; - $this->params['seo']['meta'] = $category->meta_robots; + if(empty($productProvider->allModels)){ + $this->params['seo']['meta'] = 'noindex,nofollow'; + }else{ + $this->params['seo']['meta'] = $category->meta_robots; + } + $this->params['seo']['category_name'] = $category->name; $this->params['breadcrumbs'][] = $category->name; diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 2fbbafa..8f82815 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -421,6 +421,7 @@ use common\models\Event;
  • 'dostavka-tovarov'])) ?>
  • 'diskontnaya-programma'])) ?>
  • 'o-proekte'])) ?>
  • +
  • 'katalogi'])) ?>
  • diff --git a/frontend/widgets/Seo.php b/frontend/widgets/Seo.php index 664292b..71557ef 100755 --- a/frontend/widgets/Seo.php +++ b/frontend/widgets/Seo.php @@ -182,7 +182,6 @@ class Seo extends Widget $paginate = \Yii::$app->request->get('page', []); - if (!empty($meta) && empty($sort) && empty($paginate) && !isset($filter['prices']) ) { $this->getView()->registerMetaTag([ -- libgit2 0.21.4