Commit dc50f6077980db77ed5ff727cfc20ab319db85a0
1 parent
cf07505d
Some fixes
Showing
10 changed files
with
29 additions
and
13 deletions
Show diff stats
backend/views/brand/_form.php
... | ... | @@ -39,6 +39,8 @@ use yii\widgets\ActiveForm; |
39 | 39 | |
40 | 40 | <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> |
41 | 41 | |
42 | + <?= $form->field($model, 'remote_id')->textInput(['maxlength' => 25]) ?> | |
43 | + | |
42 | 44 | <div class="form-group"> |
43 | 45 | <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
44 | 46 | <?php if ($model->isNewRecord) :?> | ... | ... |
common/modules/product/controllers/ManageController.php
common/modules/product/models/Brand.php
... | ... | @@ -10,6 +10,7 @@ use Yii; |
10 | 10 | * This is the model class for table "brand". |
11 | 11 | * |
12 | 12 | * @property integer $brand_id |
13 | + * @property string $remote_id | |
13 | 14 | * @property integer $brand_name_id |
14 | 15 | * @property string $alias |
15 | 16 | * @property string $image |
... | ... | @@ -66,6 +67,7 @@ class Brand extends \yii\db\ActiveRecord |
66 | 67 | [['alias', 'name'], 'string', 'max' => 250], |
67 | 68 | [['image', 'meta_title'], 'string', 'max' => 255], |
68 | 69 | [['meta_robots'], 'string', 'max' => 50], |
70 | + [['remote_id'], 'string', 'max' => 25], | |
69 | 71 | [['imageUpload'], 'safe'], |
70 | 72 | [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], |
71 | 73 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], |
... | ... | @@ -88,6 +90,7 @@ class Brand extends \yii\db\ActiveRecord |
88 | 90 | 'meta_desc' => Yii::t('product', 'Meta Desc'), |
89 | 91 | 'meta_robots' => Yii::t('product', 'Meta Robots'), |
90 | 92 | 'seo_text' => Yii::t('product', 'Seo Text'), |
93 | + 'remote_id' => Yii::t('product', '1C brand name'), | |
91 | 94 | ]; |
92 | 95 | } |
93 | 96 | ... | ... |
common/modules/product/models/Product.php
... | ... | @@ -264,7 +264,11 @@ class Product extends \yii\db\ActiveRecord |
264 | 264 | $op[] = [ |
265 | 265 | 'caption' => $image->image, |
266 | 266 | 'width' => '120px', |
267 | - 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]) | |
267 | + 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]), | |
268 | + 'key' => $image->product_image_id, | |
269 | + 'extra' => [ | |
270 | + 'id' => $image->product_image_id, | |
271 | + ], | |
268 | 272 | ]; |
269 | 273 | } |
270 | 274 | } | ... | ... |
common/translation/ru/product.php
... | ... | @@ -34,6 +34,7 @@ return [ |
34 | 34 | 'Name of the brand' => 'ะะผั ะฑัะตะฝะดะฐ', |
35 | 35 | 'Brand' => 'ะัะตะฝะด', |
36 | 36 | 'Brands' => 'ะัะตะฝะดั', |
37 | + '1C brand name' => 'ะะฐะทะฒะฐะฝะธะต ะฑัะตะฝะดะฐ ะฒ 1ะก', | |
37 | 38 | 'Select brand' => 'ะัะฑะตัะธัะต ะฑัะตะฝะด', |
38 | 39 | 'Create Brand' => 'ะกะพะทะดะฐัั ะฑัะตะฝะด', |
39 | 40 | 'Category Name' => 'ะะผั ะบะฐัะตะณะพัะธะธ', | ... | ... |
console/controllers/ImportController.php
... | ... | @@ -27,26 +27,30 @@ class ImportController extends Controller { |
27 | 27 | public function goGo() { |
28 | 28 | $new_products = $linked_products = 0; |
29 | 29 | foreach(RemoteProducts::find()->all() as $product) { |
30 | + $product->Brand = trim($product->Brand); | |
30 | 31 | if (!empty($product->product->product_id)) { |
31 | 32 | $linked_products++; |
32 | 33 | |
33 | - $_productVariant = ProductVariant::findOne($product->product->product_id); | |
34 | - $_product = Product::findOne($_productVariant->product_id); | |
34 | + $_productVariant = ProductVariant::findOne($product->product->product_variant_id); | |
35 | + $_product = Product::findOne($product->product->product_id); | |
36 | + | |
37 | + $brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one(); | |
35 | 38 | |
36 | 39 | if ( |
37 | 40 | $_product->name != $product->Name || |
38 | - $_product->categories != [$product->remoteCategory->category->category_id] || | |
39 | - ($product->Brand && ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null && $_product->brand_id != $brand->brand_id) | |
41 | + $_product->categories[0]->category_id != [$product->remoteCategory->category->category_id] || | |
42 | + ($product->Brand && $brand !== null && $_product->brand_id != $brand->brand_id) | |
40 | 43 | ) { |
41 | 44 | $_product->name = $product->Name; |
42 | 45 | $_product->categories = [$product->remoteCategory->category->category_id]; |
43 | 46 | if ( $product->Brand ) { |
44 | - if ( ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null ) { | |
47 | + if ( $brand !== null ) { | |
45 | 48 | $_product->brand_id = $brand->brand_id; |
46 | 49 | } else { |
47 | 50 | // Create brand |
48 | 51 | $brand = new Brand(); |
49 | - $brand->name = trim($product->Brand); | |
52 | + $brand->name = $product->Brand; | |
53 | + $brand->remote_id = $product->Brand; | |
50 | 54 | $brand->save(); |
51 | 55 | $_product->brand_id = $brand->brand_id; |
52 | 56 | } |
... | ... | @@ -76,7 +80,7 @@ class ImportController extends Controller { |
76 | 80 | $_product->categories = [$product->remoteCategory->category->category_id]; |
77 | 81 | |
78 | 82 | if ( $product->Brand ) { |
79 | - if ( ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null ) { | |
83 | + if ( ($brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one()) !== null ) { | |
80 | 84 | $_product->brand_id = $brand->brand_id; |
81 | 85 | } else { |
82 | 86 | // Create brand | ... | ... |
frontend/config/main.php
... | ... | @@ -47,7 +47,8 @@ return [ |
47 | 47 | 'sourceUrl' => '@web/images', |
48 | 48 | 'sizes' => [ |
49 | 49 | 'brandlist' => [130, 70], |
50 | - 'product' => [128, 128], | |
50 | + 'product' => [300, 300], | |
51 | + 'product_trumb' => [80, 80], | |
51 | 52 | 'product_list' => [130, 70], |
52 | 53 | 'product_list2' => [130, 70], |
53 | 54 | 'mainmenu' => [160, 170], | ... | ... |
frontend/views/catalog/product.php
... | ... | @@ -34,7 +34,7 @@ $this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; |
34 | 34 | <div class="main_img_slide"> |
35 | 35 | <?php foreach($product->images as $image) :?> |
36 | 36 | <div class="small_img_block active"> |
37 | - <img src="/images/<?= $image->image?>" alt="<?= $image->alt ? $image->alt : $product->name?>"> | |
37 | + <?= Yii::$app->imageCache->thumb($image->imageUrl, 'product_trumb')?> | |
38 | 38 | </div> |
39 | 39 | <?php endforeach?> |
40 | 40 | ... | ... |
frontend/views/catalog/product_item.php
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | <?php if (empty($product->image)) :?> |
11 | 11 | <img src="/images/no_photo.png"> |
12 | 12 | <?php else :?> |
13 | - <img src="/images/<?= $product->image->image?>" alt="<?= $product->image->alt ? $product->image->alt : $product->name?>"> | |
13 | + <?= Yii::$app->imageCache->thumb($product->image->imageUrl, 'product_list')?> | |
14 | 14 | <?php endif?> |
15 | 15 | </div> |
16 | 16 | <div class="title_item"><?= $product->name?></div></a> | ... | ... |
frontend/web/css/concat_all.css