From 55b984adf20f5cef540fc265d0e2bc46dc2dbb89 Mon Sep 17 00:00:00 2001 From: Karnovsky A Date: Mon, 23 May 2016 10:57:47 +0300 Subject: [PATCH] --- --- common/components/artboximage/ArtboxImage.php | 7 +++++-- common/modules/product/models/Brand.php | 7 +++++++ common/modules/product/models/Product.php | 2 +- console/controllers/ImportController.php | 14 +++++++++----- frontend/web/images/lightbox/close.png | Bin 0 -> 280 bytes frontend/web/images/lightbox/loading.gif | Bin 0 -> 8476 bytes frontend/web/images/lightbox/next.png | Bin 0 -> 1350 bytes frontend/web/images/lightbox/prev.png | Bin 0 -> 1360 bytes 8 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 frontend/web/images/lightbox/close.png create mode 100644 frontend/web/images/lightbox/loading.gif create mode 100644 frontend/web/images/lightbox/next.png create mode 100644 frontend/web/images/lightbox/prev.png diff --git a/common/components/artboximage/ArtboxImage.php b/common/components/artboximage/ArtboxImage.php index 07ce19d..386105d 100644 --- a/common/components/artboximage/ArtboxImage.php +++ b/common/components/artboximage/ArtboxImage.php @@ -52,7 +52,8 @@ class ArtboxImage extends Component { 'initialPreview' => $model->{$modelField} ? Html::img($model->{$modelField}) : '', 'overwriteInitial' => !$multiple, 'showRemove' => true, - 'showUpload' => false, + 'showUpload' => true, + 'showCaption' => false, 'uploadUrl' => $this->uploadUrl, 'uploadExtraData' => [ 'fileField' => $modelField, @@ -60,7 +61,9 @@ class ArtboxImage extends Component { ], ], 'pluginEvents' => [ - "change" => "function() { console.log('change'); }", + "change" => "function() { + alert('_change'); + }", "open" => "function() { console.log('open'); }", "save" => "function() { console.log('save'); }", "upload" => "function() { console.log('upload'); }", diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index 7c5882c..5786e16 100755 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -43,6 +43,13 @@ class Brand extends \yii\db\ActiveRecord 'slugKeyName' => 'alias', 'translit' => true ], + 'image' => [ + 'class' => UploadBehavior::className(), + 'attribute' => 'file', + 'scenarios' => ['insert', 'update'], + 'path' => '@webroot/upload/docs/{category.id}', + 'url' => '@web/upload/docs/{category.id}', + ], ], ]; } diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index 007ab5b..cf6d9d0 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 [['name'], 'string', 'max' => 150], [['alias'], 'string', 'max' => 250], [['categories', 'variants', 'options', 'imagesUpload'], 'safe'], - [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], +// [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], [['description', 'video'], 'safe'], [['is_top', 'is_new'], 'boolean'], // [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], diff --git a/console/controllers/ImportController.php b/console/controllers/ImportController.php index f06405e..9de5e10 100644 --- a/console/controllers/ImportController.php +++ b/console/controllers/ImportController.php @@ -28,17 +28,22 @@ class ImportController extends Controller { $new_products = $linked_products = 0; foreach(RemoteProducts::find()->all() as $product) { $product->Brand = trim($product->Brand); - if (!empty($product->product->product_id)) { + if (empty($product->remoteCategory) || empty($product->remoteCategory->category)) { + continue; + } + if (!empty($product->product->product_id)) + { $linked_products++; $_productVariant = ProductVariant::findOne($product->product->product_variant_id); + $_product = Product::findOne($product->product->product_id); $brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one(); if ( $_product->name != $product->Name || - $_product->categories[0]->category_id != [$product->remoteCategory->category->category_id] || + $_product->categories[0]->category_id != $product->remoteCategory->category->category_id || ($product->Brand && $brand !== null && $_product->brand_id != $brand->brand_id) ) { $_product->name = $product->Name; @@ -71,7 +76,8 @@ class ImportController extends Controller { } $_productVariant->save(); } - } elseif (!empty($product->remoteCategory) && !empty($product->remoteCategory->category) && !empty($product->remoteCategory->category->category_id)) { + } + elseif (!empty($product->remoteCategory->category->category_id)) { $new_products++; $_product = new Product(); @@ -90,7 +96,6 @@ class ImportController extends Controller { $_product->brand_id = $brand->brand_id; } } - $_productVariant->price = floatval($product->Price); $_productVariant->price_old = floatval($product->Price_old); $_productVariant->sku = empty($product->Article) ? uniqid('gds_') : $product->Article; @@ -102,7 +107,6 @@ class ImportController extends Controller { print $this->stdout("Saved error for the {$_product->name} {$_product->product_id}?\n"); return Controller::EXIT_CODE_ERROR; } - $_productVariant->product_id = $_product->product_id; if (!$_productVariant->save()) { print $this->stdout("Saved error for variant of the {$_product->name} {$_product->product_id}?\n"); diff --git a/frontend/web/images/lightbox/close.png b/frontend/web/images/lightbox/close.png new file mode 100644 index 0000000..20baa1d Binary files /dev/null and b/frontend/web/images/lightbox/close.png differ diff --git a/frontend/web/images/lightbox/loading.gif b/frontend/web/images/lightbox/loading.gif new file mode 100644 index 0000000..5087c2a Binary files /dev/null and b/frontend/web/images/lightbox/loading.gif differ diff --git a/frontend/web/images/lightbox/next.png b/frontend/web/images/lightbox/next.png new file mode 100644 index 0000000..08365ac Binary files /dev/null and b/frontend/web/images/lightbox/next.png differ diff --git a/frontend/web/images/lightbox/prev.png b/frontend/web/images/lightbox/prev.png new file mode 100644 index 0000000..329fa98 Binary files /dev/null and b/frontend/web/images/lightbox/prev.png differ -- libgit2 0.21.4