From cfc5b583b78ba6c0079dd0a1da330b1030ad73a5 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 6 Oct 2016 12:22:55 +0300 Subject: [PATCH] 14.09.16 --- common/modules/product/models/Product.php | 14 ++++++++++++++ frontend/views/catalog/product.php | 2 +- frontend/views/catalog/product_item.php | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index a3e29d9..d07d724 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -238,10 +238,24 @@ class Product extends \yii\db\ActiveRecord 'Кошельки' => 'Кошелек', 'Гермочехлы' => 'Гермочехол', ]; + return empty($this->brand) ? $this->name : $this->brand->name .' '. $this->name; + } + + public function getFullNameWithCategory() + { + $words = [ + 'Рюкзаки' => 'Рюкзак', + 'Несессеры' => 'Несессер', + 'Сумки' => 'Сумка', + 'Чехлы' => 'Чехол', + 'Кошельки' => 'Кошелек', + 'Гермочехлы' => 'Гермочехол', + ]; $name = empty($this->brand) ? $this->name : $this->brand->name .' '. $this->name; return empty($this->category->categoryName->value) ? $name : (isset($words[$this->category->categoryName->value])? $words[$this->category->categoryName->value]: '') .' '. $name; } + public function getCategories() { return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']); // return $this->getRelations('product_categories'); diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php index b2a53bb..15d4008 100755 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php @@ -15,7 +15,7 @@ use frontend\assets\FlipclockAsset; FlipclockAsset::register($this); $this->params[ 'seo' ][ 'key' ] = $category->categoryName->value; $this->params[ 'seo' ][ 'fields' ][ 'name' ] = $product->fullname; - $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullname; + $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullnamewithcategory; //$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua"; //$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua"; diff --git a/frontend/views/catalog/product_item.php b/frontend/views/catalog/product_item.php index 0fea24c..b846b3e 100755 --- a/frontend/views/catalog/product_item.php +++ b/frontend/views/catalog/product_item.php @@ -64,7 +64,7 @@ 'product' => $product, '#' => 'm' . $product->enabledVariants[ 0 ]->product_variant_id, ]) ?>" - class="name">fullname ?> + class="name">fullnamewithcategory ?>