Commit 55b984adf20f5cef540fc265d0e2bc46dc2dbb89
1 parent
d0a3671d
---
Showing
8 changed files
with
22 additions
and
8 deletions
Show diff stats
common/components/artboximage/ArtboxImage.php
... | ... | @@ -52,7 +52,8 @@ class ArtboxImage extends Component { |
52 | 52 | 'initialPreview' => $model->{$modelField} ? Html::img($model->{$modelField}) : '', |
53 | 53 | 'overwriteInitial' => !$multiple, |
54 | 54 | 'showRemove' => true, |
55 | - 'showUpload' => false, | |
55 | + 'showUpload' => true, | |
56 | + 'showCaption' => false, | |
56 | 57 | 'uploadUrl' => $this->uploadUrl, |
57 | 58 | 'uploadExtraData' => [ |
58 | 59 | 'fileField' => $modelField, |
... | ... | @@ -60,7 +61,9 @@ class ArtboxImage extends Component { |
60 | 61 | ], |
61 | 62 | ], |
62 | 63 | 'pluginEvents' => [ |
63 | - "change" => "function() { console.log('change'); }", | |
64 | + "change" => "function() { | |
65 | + alert('_change'); | |
66 | + }", | |
64 | 67 | "open" => "function() { console.log('open'); }", |
65 | 68 | "save" => "function() { console.log('save'); }", |
66 | 69 | "upload" => "function() { console.log('upload'); }", | ... | ... |
common/modules/product/models/Brand.php
... | ... | @@ -43,6 +43,13 @@ class Brand extends \yii\db\ActiveRecord |
43 | 43 | 'slugKeyName' => 'alias', |
44 | 44 | 'translit' => true |
45 | 45 | ], |
46 | + 'image' => [ | |
47 | + 'class' => UploadBehavior::className(), | |
48 | + 'attribute' => 'file', | |
49 | + 'scenarios' => ['insert', 'update'], | |
50 | + 'path' => '@webroot/upload/docs/{category.id}', | |
51 | + 'url' => '@web/upload/docs/{category.id}', | |
52 | + ], | |
46 | 53 | ], |
47 | 54 | ]; |
48 | 55 | } | ... | ... |
common/modules/product/models/Product.php
... | ... | @@ -71,7 +71,7 @@ class Product extends \yii\db\ActiveRecord |
71 | 71 | [['name'], 'string', 'max' => 150], |
72 | 72 | [['alias'], 'string', 'max' => 250], |
73 | 73 | [['categories', 'variants', 'options', 'imagesUpload'], 'safe'], |
74 | - [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], | |
74 | +// [['imagesUpload'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg, gif', 'maxFiles' => 50], | |
75 | 75 | [['description', 'video'], 'safe'], |
76 | 76 | [['is_top', 'is_new'], 'boolean'], |
77 | 77 | // [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], | ... | ... |
console/controllers/ImportController.php
... | ... | @@ -28,17 +28,22 @@ class ImportController extends Controller { |
28 | 28 | $new_products = $linked_products = 0; |
29 | 29 | foreach(RemoteProducts::find()->all() as $product) { |
30 | 30 | $product->Brand = trim($product->Brand); |
31 | - if (!empty($product->product->product_id)) { | |
31 | + if (empty($product->remoteCategory) || empty($product->remoteCategory->category)) { | |
32 | + continue; | |
33 | + } | |
34 | + if (!empty($product->product->product_id)) | |
35 | + { | |
32 | 36 | $linked_products++; |
33 | 37 | |
34 | 38 | $_productVariant = ProductVariant::findOne($product->product->product_variant_id); |
39 | + | |
35 | 40 | $_product = Product::findOne($product->product->product_id); |
36 | 41 | |
37 | 42 | $brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one(); |
38 | 43 | |
39 | 44 | if ( |
40 | 45 | $_product->name != $product->Name || |
41 | - $_product->categories[0]->category_id != [$product->remoteCategory->category->category_id] || | |
46 | + $_product->categories[0]->category_id != $product->remoteCategory->category->category_id || | |
42 | 47 | ($product->Brand && $brand !== null && $_product->brand_id != $brand->brand_id) |
43 | 48 | ) { |
44 | 49 | $_product->name = $product->Name; |
... | ... | @@ -71,7 +76,8 @@ class ImportController extends Controller { |
71 | 76 | } |
72 | 77 | $_productVariant->save(); |
73 | 78 | } |
74 | - } elseif (!empty($product->remoteCategory) && !empty($product->remoteCategory->category) && !empty($product->remoteCategory->category->category_id)) { | |
79 | + } | |
80 | + elseif (!empty($product->remoteCategory->category->category_id)) { | |
75 | 81 | $new_products++; |
76 | 82 | |
77 | 83 | $_product = new Product(); |
... | ... | @@ -90,7 +96,6 @@ class ImportController extends Controller { |
90 | 96 | $_product->brand_id = $brand->brand_id; |
91 | 97 | } |
92 | 98 | } |
93 | - | |
94 | 99 | $_productVariant->price = floatval($product->Price); |
95 | 100 | $_productVariant->price_old = floatval($product->Price_old); |
96 | 101 | $_productVariant->sku = empty($product->Article) ? uniqid('gds_') : $product->Article; |
... | ... | @@ -102,7 +107,6 @@ class ImportController extends Controller { |
102 | 107 | print $this->stdout("Saved error for the {$_product->name} {$_product->product_id}?\n"); |
103 | 108 | return Controller::EXIT_CODE_ERROR; |
104 | 109 | } |
105 | - | |
106 | 110 | $_productVariant->product_id = $_product->product_id; |
107 | 111 | if (!$_productVariant->save()) { |
108 | 112 | print $this->stdout("Saved error for variant of the {$_product->name} {$_product->product_id}?\n"); | ... | ... |
280 Bytes
8.28 KB
1.32 KB
1.33 KB