From 067092f74e20f7b9c2c659b23ddb385790f455ee Mon Sep 17 00:00:00 2001 From: Karnovsky A Date: Thu, 26 May 2016 18:37:49 +0300 Subject: [PATCH] - --- common/modules/product/models/Product.php | 4 ++-- common/modules/product/models/ProductImageQuery.php | 1 + common/modules/product/widgets/views/product_smart.php | 6 ++++-- console/controllers/ImportController.php | 11 +++++------ frontend/views/catalog/product.php | 2 +- frontend/views/catalog/products.php | 6 +----- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 62526f3..2bb9b38 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -71,7 +71,7 @@ class Product extends \yii\db\ActiveRecord public function rules() { return [ - [['categories'], 'required'], +// [['categories'], 'required'], [['brand_id'], 'integer'], [['name'], 'string', 'max' => 150], [['alias'], 'string', 'max' => 250], @@ -136,7 +136,7 @@ class Product extends \yii\db\ActiveRecord */ public function getImages() { - return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id'])->filterWhere(['is', 'product_variant_id', NULL]); + return $this->hasMany(ProductImage::className(), ['product_id' => 'product_id']); } /** diff --git a/common/modules/product/models/ProductImageQuery.php b/common/modules/product/models/ProductImageQuery.php index 5f98a0b..d10b794 100755 --- a/common/modules/product/models/ProductImageQuery.php +++ b/common/modules/product/models/ProductImageQuery.php @@ -20,6 +20,7 @@ class ProductImageQuery extends \yii\db\ActiveQuery */ public function all($db = null) { + $this->where(['product_variant_id' => NULL]); return parent::all($db); } diff --git a/common/modules/product/widgets/views/product_smart.php b/common/modules/product/widgets/views/product_smart.php index e3f44da..7cdff6e 100755 --- a/common/modules/product/widgets/views/product_smart.php +++ b/common/modules/product/widgets/views/product_smart.php @@ -7,7 +7,8 @@ use yii\helpers\Url;
imageUrl, 'list')?> @@ -49,7 +50,8 @@ use yii\helpers\Url;
Купить
diff --git a/console/controllers/ImportController.php b/console/controllers/ImportController.php index 18428d2..3a94a59 100755 --- a/console/controllers/ImportController.php +++ b/console/controllers/ImportController.php @@ -137,15 +137,13 @@ class ImportController extends Controller { $is_new_product = empty($_product->product_id); // ==== Set category ==== - if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) !== null ) { - $_product->categories = [$category->category_id]; - } else { + if ( ($category = CategoryName::find()->filterWhere(['ilike', 'value', trim($catalog_name)])->one()) === null ) { // Create category $category = new Category(); $category->name = trim($catalog_name); $category->save(); - $_product->categories = [$category->category_id]; } + $_product->categories = [$category->category_id]; // ===== Set brand ==== if ( $brand_name ) { @@ -167,8 +165,9 @@ class ImportController extends Controller { $_product->akciya = $product_akciya; $_product->is_new = $product_new; - - $_product->save(); + if (!$_product->save()) { + var_dump($category->category_id, $_product->categories);exit; + } // @todo Set image diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php index da2ba47..cf83f60 100755 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php @@ -2,7 +2,7 @@ use yii\widgets\Breadcrumbs; use yii\web\View; use yii\helpers\Url; - +$this->params['seo']['title'] = $product->fullname ; $this->title = $product->fullname; //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php index 524b9b1..93f0dcd 100755 --- a/frontend/views/catalog/products.php +++ b/frontend/views/catalog/products.php @@ -15,11 +15,7 @@ foreach($category->getParents()->all() as $parent) { } $this->params['breadcrumbs'][] = $category->categoryName->value; -$this->params['seo']['seo_text'] = 'TEST SEO TEXT'; -$this->params['seo']['h1'] = 'TEST H1'; -$this->params['seo']['description'] = 'TEST DESCRIPTION'; -$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD'; -$this->params['seo']['key']= 'product_list'; +$this->params['seo']['title'] = $category->name; $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css')); -- libgit2 0.21.4