Commit cfc5b583b78ba6c0079dd0a1da330b1030ad73a5

Authored by Administrator
1 parent ebf6e240

14.09.16

common/modules/product/models/Product.php
... ... @@ -238,10 +238,24 @@ class Product extends \yii\db\ActiveRecord
238 238 'Кошельки' => 'Кошелек',
239 239 'Гермочехлы' => 'Гермочехол',
240 240 ];
  241 + return empty($this->brand) ? $this->name : $this->brand->name .' '. $this->name;
  242 + }
  243 +
  244 + public function getFullNameWithCategory()
  245 + {
  246 + $words = [
  247 + 'Рюкзаки' => 'Рюкзак',
  248 + 'Несессеры' => 'Несессер',
  249 + 'Сумки' => 'Сумка',
  250 + 'Чехлы' => 'Чехол',
  251 + 'Кошельки' => 'Кошелек',
  252 + 'Гермочехлы' => 'Гермочехол',
  253 + ];
241 254 $name = empty($this->brand) ? $this->name : $this->brand->name .' '. $this->name;
242 255 return empty($this->category->categoryName->value) ? $name : (isset($words[$this->category->categoryName->value])? $words[$this->category->categoryName->value]: '') .' '. $name;
243 256 }
244 257  
  258 +
245 259 public function getCategories() {
246 260 return $this->hasMany(Category::className(), ['category_id' => 'category_id'])->viaTable('product_category', ['product_id' => 'product_id']);
247 261 // return $this->getRelations('product_categories');
... ...
frontend/views/catalog/product.php
... ... @@ -15,7 +15,7 @@ use frontend\assets\FlipclockAsset;
15 15 FlipclockAsset::register($this);
16 16 $this->params[ 'seo' ][ 'key' ] = $category->categoryName->value;
17 17 $this->params[ 'seo' ][ 'fields' ][ 'name' ] = $product->fullname;
18   - $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullname;
  18 + $this->params[ 'seo' ][ 'h1' ] = !empty( Seo::widget([ 'row' => 'h1' ]) ) ? Seo::widget([ 'row' => 'h1' ]) : $product->fullnamewithcategory;
19 19  
20 20 //$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
21 21 //$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
... ...
frontend/views/catalog/product_item.php
... ... @@ -64,7 +64,7 @@
64 64 'product' => $product,
65 65 '#' => 'm' . $product->enabledVariants[ 0 ]->product_variant_id,
66 66 ]) ?>"
67   - class="name"><?= $product->fullname ?>
  67 + class="name"><?= $product->fullnamewithcategory ?>
68 68 </a></div>
69 69  
70 70 <?php
... ...