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,6 +39,8 @@ use yii\widgets\ActiveForm; | ||
39 | 39 | ||
40 | <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> | 40 | <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> |
41 | 41 | ||
42 | + <?= $form->field($model, 'remote_id')->textInput(['maxlength' => 25]) ?> | ||
43 | + | ||
42 | <div class="form-group"> | 44 | <div class="form-group"> |
43 | <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | 45 | <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
44 | <?php if ($model->isNewRecord) :?> | 46 | <?php if ($model->isNewRecord) :?> |
common/modules/product/controllers/ManageController.php
@@ -210,7 +210,8 @@ class ManageController extends Controller | @@ -210,7 +210,8 @@ class ManageController extends Controller | ||
210 | $image->delete(); | 210 | $image->delete(); |
211 | } | 211 | } |
212 | 212 | ||
213 | - return $this->redirect(['index']); | 213 | + print '1'; |
214 | + exit; | ||
214 | } | 215 | } |
215 | 216 | ||
216 | public function actionImport() { | 217 | public function actionImport() { |
common/modules/product/models/Brand.php
@@ -10,6 +10,7 @@ use Yii; | @@ -10,6 +10,7 @@ use Yii; | ||
10 | * This is the model class for table "brand". | 10 | * This is the model class for table "brand". |
11 | * | 11 | * |
12 | * @property integer $brand_id | 12 | * @property integer $brand_id |
13 | + * @property string $remote_id | ||
13 | * @property integer $brand_name_id | 14 | * @property integer $brand_name_id |
14 | * @property string $alias | 15 | * @property string $alias |
15 | * @property string $image | 16 | * @property string $image |
@@ -66,6 +67,7 @@ class Brand extends \yii\db\ActiveRecord | @@ -66,6 +67,7 @@ class Brand extends \yii\db\ActiveRecord | ||
66 | [['alias', 'name'], 'string', 'max' => 250], | 67 | [['alias', 'name'], 'string', 'max' => 250], |
67 | [['image', 'meta_title'], 'string', 'max' => 255], | 68 | [['image', 'meta_title'], 'string', 'max' => 255], |
68 | [['meta_robots'], 'string', 'max' => 50], | 69 | [['meta_robots'], 'string', 'max' => 50], |
70 | + [['remote_id'], 'string', 'max' => 25], | ||
69 | [['imageUpload'], 'safe'], | 71 | [['imageUpload'], 'safe'], |
70 | [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | 72 | [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], |
71 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], | 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,6 +90,7 @@ class Brand extends \yii\db\ActiveRecord | ||
88 | 'meta_desc' => Yii::t('product', 'Meta Desc'), | 90 | 'meta_desc' => Yii::t('product', 'Meta Desc'), |
89 | 'meta_robots' => Yii::t('product', 'Meta Robots'), | 91 | 'meta_robots' => Yii::t('product', 'Meta Robots'), |
90 | 'seo_text' => Yii::t('product', 'Seo Text'), | 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,7 +264,11 @@ class Product extends \yii\db\ActiveRecord | ||
264 | $op[] = [ | 264 | $op[] = [ |
265 | 'caption' => $image->image, | 265 | 'caption' => $image->image, |
266 | 'width' => '120px', | 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,6 +34,7 @@ return [ | ||
34 | 'Name of the brand' => 'Имя бренда', | 34 | 'Name of the brand' => 'Имя бренда', |
35 | 'Brand' => 'Бренд', | 35 | 'Brand' => 'Бренд', |
36 | 'Brands' => 'Бренды', | 36 | 'Brands' => 'Бренды', |
37 | + '1C brand name' => 'Название бренда в 1С', | ||
37 | 'Select brand' => 'Выберите бренд', | 38 | 'Select brand' => 'Выберите бренд', |
38 | 'Create Brand' => 'Создать бренд', | 39 | 'Create Brand' => 'Создать бренд', |
39 | 'Category Name' => 'Имя категории', | 40 | 'Category Name' => 'Имя категории', |
console/controllers/ImportController.php
@@ -27,26 +27,30 @@ class ImportController extends Controller { | @@ -27,26 +27,30 @@ class ImportController extends Controller { | ||
27 | public function goGo() { | 27 | public function goGo() { |
28 | $new_products = $linked_products = 0; | 28 | $new_products = $linked_products = 0; |
29 | foreach(RemoteProducts::find()->all() as $product) { | 29 | foreach(RemoteProducts::find()->all() as $product) { |
30 | + $product->Brand = trim($product->Brand); | ||
30 | if (!empty($product->product->product_id)) { | 31 | if (!empty($product->product->product_id)) { |
31 | $linked_products++; | 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 | if ( | 39 | if ( |
37 | $_product->name != $product->Name || | 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 | $_product->name = $product->Name; | 44 | $_product->name = $product->Name; |
42 | $_product->categories = [$product->remoteCategory->category->category_id]; | 45 | $_product->categories = [$product->remoteCategory->category->category_id]; |
43 | if ( $product->Brand ) { | 46 | if ( $product->Brand ) { |
44 | - if ( ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null ) { | 47 | + if ( $brand !== null ) { |
45 | $_product->brand_id = $brand->brand_id; | 48 | $_product->brand_id = $brand->brand_id; |
46 | } else { | 49 | } else { |
47 | // Create brand | 50 | // Create brand |
48 | $brand = new Brand(); | 51 | $brand = new Brand(); |
49 | - $brand->name = trim($product->Brand); | 52 | + $brand->name = $product->Brand; |
53 | + $brand->remote_id = $product->Brand; | ||
50 | $brand->save(); | 54 | $brand->save(); |
51 | $_product->brand_id = $brand->brand_id; | 55 | $_product->brand_id = $brand->brand_id; |
52 | } | 56 | } |
@@ -76,7 +80,7 @@ class ImportController extends Controller { | @@ -76,7 +80,7 @@ class ImportController extends Controller { | ||
76 | $_product->categories = [$product->remoteCategory->category->category_id]; | 80 | $_product->categories = [$product->remoteCategory->category->category_id]; |
77 | 81 | ||
78 | if ( $product->Brand ) { | 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 | $_product->brand_id = $brand->brand_id; | 84 | $_product->brand_id = $brand->brand_id; |
81 | } else { | 85 | } else { |
82 | // Create brand | 86 | // Create brand |
frontend/config/main.php
@@ -47,7 +47,8 @@ return [ | @@ -47,7 +47,8 @@ return [ | ||
47 | 'sourceUrl' => '@web/images', | 47 | 'sourceUrl' => '@web/images', |
48 | 'sizes' => [ | 48 | 'sizes' => [ |
49 | 'brandlist' => [130, 70], | 49 | 'brandlist' => [130, 70], |
50 | - 'product' => [128, 128], | 50 | + 'product' => [300, 300], |
51 | + 'product_trumb' => [80, 80], | ||
51 | 'product_list' => [130, 70], | 52 | 'product_list' => [130, 70], |
52 | 'product_list2' => [130, 70], | 53 | 'product_list2' => [130, 70], |
53 | 'mainmenu' => [160, 170], | 54 | 'mainmenu' => [160, 170], |
frontend/views/catalog/product.php
@@ -34,7 +34,7 @@ $this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; | @@ -34,7 +34,7 @@ $this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; | ||
34 | <div class="main_img_slide"> | 34 | <div class="main_img_slide"> |
35 | <?php foreach($product->images as $image) :?> | 35 | <?php foreach($product->images as $image) :?> |
36 | <div class="small_img_block active"> | 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 | </div> | 38 | </div> |
39 | <?php endforeach?> | 39 | <?php endforeach?> |
40 | 40 |
frontend/views/catalog/product_item.php
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | <?php if (empty($product->image)) :?> | 10 | <?php if (empty($product->image)) :?> |
11 | <img src="/images/no_photo.png"> | 11 | <img src="/images/no_photo.png"> |
12 | <?php else :?> | 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 | <?php endif?> | 14 | <?php endif?> |
15 | </div> | 15 | </div> |
16 | <div class="title_item"><?= $product->name?></div></a> | 16 | <div class="title_item"><?= $product->name?></div></a> |
frontend/web/css/concat_all.css
@@ -735,7 +735,7 @@ hr { | @@ -735,7 +735,7 @@ hr { | ||
735 | } | 735 | } |
736 | 736 | ||
737 | .item_3_blocks_wrap .item_img_block .main_img img { | 737 | .item_3_blocks_wrap .item_img_block .main_img img { |
738 | - height: 100%; | 738 | + max-height: 100%; |
739 | } | 739 | } |
740 | 740 | ||
741 | .item_3_blocks_wrap .item_img_block .main_img .new { | 741 | .item_3_blocks_wrap .item_img_block .main_img .new { |