Commit 067092f74e20f7b9c2c659b23ddb385790f455ee
1 parent
db5497ee
-
Showing
6 changed files
with
14 additions
and
16 deletions
Show diff stats
common/modules/product/models/Product.php
| @@ -71,7 +71,7 @@ class Product extends \yii\db\ActiveRecord | @@ -71,7 +71,7 @@ class Product extends \yii\db\ActiveRecord | ||
| 71 | public function rules() | 71 | public function rules() |
| 72 | { | 72 | { |
| 73 | return [ | 73 | return [ |
| 74 | - [['categories'], 'required'], | 74 | +// [['categories'], 'required'], |
| 75 | [['brand_id'], 'integer'], | 75 | [['brand_id'], 'integer'], |
| 76 | [['name'], 'string', 'max' => 150], | 76 | [['name'], 'string', 'max' => 150], |
| 77 | [['alias'], 'string', 'max' => 250], | 77 | [['alias'], 'string', 'max' => 250], |
| @@ -136,7 +136,7 @@ class Product extends \yii\db\ActiveRecord | @@ -136,7 +136,7 @@ class Product extends \yii\db\ActiveRecord | ||
| 136 | */ | 136 | */ |
| 137 | public function getImages() | 137 | public function getImages() |
| 138 | { | 138 | { |
| 139 | - return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id'])->filterWhere(['is', 'product_variant_id', NULL]); | 139 | + return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id']); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /** | 142 | /** |
common/modules/product/models/ProductImageQuery.php
| @@ -20,6 +20,7 @@ class ProductImageQuery extends \yii\db\ActiveQuery | @@ -20,6 +20,7 @@ class ProductImageQuery extends \yii\db\ActiveQuery | ||
| 20 | */ | 20 | */ |
| 21 | public function all($db = null) | 21 | public function all($db = null) |
| 22 | { | 22 | { |
| 23 | + $this->where(['product_variant_id' => NULL]); | ||
| 23 | return parent::all($db); | 24 | return parent::all($db); |
| 24 | } | 25 | } |
| 25 | 26 |
common/modules/product/widgets/views/product_smart.php
| @@ -7,7 +7,8 @@ use yii\helpers\Url; | @@ -7,7 +7,8 @@ use yii\helpers\Url; | ||
| 7 | <div class="pixbox"> | 7 | <div class="pixbox"> |
| 8 | <a href="<?= Url::to([ | 8 | <a href="<?= Url::to([ |
| 9 | 'catalog/product', | 9 | 'catalog/product', |
| 10 | - 'product' => $product]) | 10 | + 'product' => $product, |
| 11 | + '#' => 'm' .$product->variant->product_variant_id]) | ||
| 11 | ?>"> | 12 | ?>"> |
| 12 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?> | 13 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?> |
| 13 | </a> | 14 | </a> |
| @@ -49,7 +50,8 @@ use yii\helpers\Url; | @@ -49,7 +50,8 @@ use yii\helpers\Url; | ||
| 49 | </div> | 50 | </div> |
| 50 | <a href="<?= Url::to([ | 51 | <a href="<?= Url::to([ |
| 51 | 'catalog/product', | 52 | 'catalog/product', |
| 52 | - 'product' => $product]) | 53 | + 'product' => $product, |
| 54 | + '#' => 'm' .$product->variant->product_variant_id]) | ||
| 53 | ?>" class="link_buy">Купить</a> | 55 | ?>" class="link_buy">Купить</a> |
| 54 | 56 | ||
| 55 | <div class="mycarousel"> | 57 | <div class="mycarousel"> |
console/controllers/ImportController.php
| @@ -137,15 +137,13 @@ class ImportController extends Controller { | @@ -137,15 +137,13 @@ class ImportController extends Controller { | ||
| 137 | $is_new_product = empty($_product->product_id); | 137 | $is_new_product = empty($_product->product_id); |
| 138 | 138 | ||
| 139 | // ==== Set category ==== | 139 | // ==== Set category ==== |
| 140 | - if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) !== null ) { | ||
| 141 | - $_product->categories = [$category->category_id]; | ||
| 142 | - } else { | 140 | + if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) === null ) { |
| 143 | // Create category | 141 | // Create category |
| 144 | $category = new Category(); | 142 | $category = new Category(); |
| 145 | $category->name = trim($catalog_name); | 143 | $category->name = trim($catalog_name); |
| 146 | $category->save(); | 144 | $category->save(); |
| 147 | - $_product->categories = [$category->category_id]; | ||
| 148 | } | 145 | } |
| 146 | + $_product->categories = [$category->category_id]; | ||
| 149 | 147 | ||
| 150 | // ===== Set brand ==== | 148 | // ===== Set brand ==== |
| 151 | if ( $brand_name ) { | 149 | if ( $brand_name ) { |
| @@ -167,8 +165,9 @@ class ImportController extends Controller { | @@ -167,8 +165,9 @@ class ImportController extends Controller { | ||
| 167 | $_product->akciya = $product_akciya; | 165 | $_product->akciya = $product_akciya; |
| 168 | $_product->is_new = $product_new; | 166 | $_product->is_new = $product_new; |
| 169 | 167 | ||
| 170 | - | ||
| 171 | - $_product->save(); | 168 | + if (!$_product->save()) { |
| 169 | + var_dump($category->category_id, $_product->categories);exit; | ||
| 170 | + } | ||
| 172 | 171 | ||
| 173 | 172 | ||
| 174 | // @todo Set image | 173 | // @todo Set image |
frontend/views/catalog/product.php
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | use yii\widgets\Breadcrumbs; | 2 | use yii\widgets\Breadcrumbs; |
| 3 | use yii\web\View; | 3 | use yii\web\View; |
| 4 | use yii\helpers\Url; | 4 | use yii\helpers\Url; |
| 5 | - | 5 | +$this->params['seo']['title'] = $product->fullname ; |
| 6 | $this->title = $product->fullname; | 6 | $this->title = $product->fullname; |
| 7 | //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; | 7 | //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; |
| 8 | //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); | 8 | //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); |
frontend/views/catalog/products.php
| @@ -15,11 +15,7 @@ foreach($category->getParents()->all() as $parent) { | @@ -15,11 +15,7 @@ foreach($category->getParents()->all() as $parent) { | ||
| 15 | } | 15 | } |
| 16 | $this->params['breadcrumbs'][] = $category->categoryName->value; | 16 | $this->params['breadcrumbs'][] = $category->categoryName->value; |
| 17 | 17 | ||
| 18 | -$this->params['seo']['seo_text'] = 'TEST SEO TEXT'; | ||
| 19 | -$this->params['seo']['h1'] = 'TEST H1'; | ||
| 20 | -$this->params['seo']['description'] = 'TEST DESCRIPTION'; | ||
| 21 | -$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD'; | ||
| 22 | -$this->params['seo']['key']= 'product_list'; | 18 | +$this->params['seo']['title'] = $category->name; |
| 23 | 19 | ||
| 24 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); | 20 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); |
| 25 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css')); | 21 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css')); |