diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php index 77186ff..3ac206f 100755 --- a/backend/views/brand/_form.php +++ b/backend/views/brand/_form.php @@ -39,6 +39,8 @@ use yii\widgets\ActiveForm; field($model, 'seo_text')->textarea(['rows' => 6]) ?> + field($model, 'remote_id')->textInput(['maxlength' => 25]) ?> +
isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> isNewRecord) :?> diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php index 56695a6..f7bdddb 100755 --- a/common/modules/product/controllers/ManageController.php +++ b/common/modules/product/controllers/ManageController.php @@ -210,7 +210,8 @@ class ManageController extends Controller $image->delete(); } - return $this->redirect(['index']); + print '1'; + exit; } public function actionImport() { diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index 9a1ff09..b7c6ef9 100755 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -10,6 +10,7 @@ use Yii; * This is the model class for table "brand". * * @property integer $brand_id + * @property string $remote_id * @property integer $brand_name_id * @property string $alias * @property string $image @@ -66,6 +67,7 @@ class Brand extends \yii\db\ActiveRecord [['alias', 'name'], 'string', 'max' => 250], [['image', 'meta_title'], 'string', 'max' => 255], [['meta_robots'], 'string', 'max' => 50], + [['remote_id'], 'string', 'max' => 25], [['imageUpload'], 'safe'], [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], // [['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 'meta_desc' => Yii::t('product', 'Meta Desc'), 'meta_robots' => Yii::t('product', 'Meta Robots'), 'seo_text' => Yii::t('product', 'Seo Text'), + 'remote_id' => Yii::t('product', '1C brand name'), ]; } diff --git a/common/modules/product/models/Product.php b/common/modules/product/models/Product.php index d4cf85a..b92a057 100755 --- a/common/modules/product/models/Product.php +++ b/common/modules/product/models/Product.php @@ -264,7 +264,11 @@ class Product extends \yii\db\ActiveRecord $op[] = [ 'caption' => $image->image, 'width' => '120px', - 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]) + 'url' => \yii\helpers\Url::to(['/product/manage/delimg', 'id' => $image->product_image_id]), + 'key' => $image->product_image_id, + 'extra' => [ + 'id' => $image->product_image_id, + ], ]; } } diff --git a/common/translation/ru/product.php b/common/translation/ru/product.php index e53146d..fa98be3 100644 --- a/common/translation/ru/product.php +++ b/common/translation/ru/product.php @@ -34,6 +34,7 @@ return [ 'Name of the brand' => 'Имя бренда', 'Brand' => 'Бренд', 'Brands' => 'Бренды', + '1C brand name' => 'Название бренда в 1С', 'Select brand' => 'Выберите бренд', 'Create Brand' => 'Создать бренд', 'Category Name' => 'Имя категории', diff --git a/console/controllers/ImportController.php b/console/controllers/ImportController.php index 63a28a1..f06405e 100644 --- a/console/controllers/ImportController.php +++ b/console/controllers/ImportController.php @@ -27,26 +27,30 @@ class ImportController extends Controller { public function goGo() { $new_products = $linked_products = 0; foreach(RemoteProducts::find()->all() as $product) { + $product->Brand = trim($product->Brand); if (!empty($product->product->product_id)) { $linked_products++; - $_productVariant = ProductVariant::findOne($product->product->product_id); - $_product = Product::findOne($_productVariant->product_id); + $_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 != [$product->remoteCategory->category->category_id] || - ($product->Brand && ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null && $_product->brand_id != $brand->brand_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; $_product->categories = [$product->remoteCategory->category->category_id]; if ( $product->Brand ) { - if ( ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null ) { + if ( $brand !== null ) { $_product->brand_id = $brand->brand_id; } else { // Create brand $brand = new Brand(); - $brand->name = trim($product->Brand); + $brand->name = $product->Brand; + $brand->remote_id = $product->Brand; $brand->save(); $_product->brand_id = $brand->brand_id; } @@ -76,7 +80,7 @@ class ImportController extends Controller { $_product->categories = [$product->remoteCategory->category->category_id]; if ( $product->Brand ) { - if ( ($brand = BrandName::find()->filterWhere(['like', 'value', trim($product->Brand)])->one()) !== null ) { + if ( ($brand = Brand::find()->filterWhere(['ilike', 'remote_id', trim($product->Brand)])->one()) !== null ) { $_product->brand_id = $brand->brand_id; } else { // Create brand diff --git a/frontend/config/main.php b/frontend/config/main.php index 1bb4321..07d6c85 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -47,7 +47,8 @@ return [ 'sourceUrl' => '@web/images', 'sizes' => [ 'brandlist' => [130, 70], - 'product' => [128, 128], + 'product' => [300, 300], + 'product_trumb' => [80, 80], 'product_list' => [130, 70], 'product_list2' => [130, 70], 'mainmenu' => [160, 170], diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php index 34cb651..a581e8a 100755 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php @@ -34,7 +34,7 @@ $this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku;
images as $image) :?>
- <?= $image->alt ? $image->alt : $product->name?> + imageCache->thumb($image->imageUrl, 'product_trumb')?>
diff --git a/frontend/views/catalog/product_item.php b/frontend/views/catalog/product_item.php index 5509bcc..1c6dfd4 100755 --- a/frontend/views/catalog/product_item.php +++ b/frontend/views/catalog/product_item.php @@ -10,7 +10,7 @@ image)) :?> - <?= $product->image->alt ? $product->image->alt : $product->name?> + imageCache->thumb($product->image->imageUrl, 'product_list')?>
name?>
diff --git a/frontend/web/css/concat_all.css b/frontend/web/css/concat_all.css index d1bd872..f4db65f 100755 --- a/frontend/web/css/concat_all.css +++ b/frontend/web/css/concat_all.css @@ -735,7 +735,7 @@ hr { } .item_3_blocks_wrap .item_img_block .main_img img { - height: 100%; + max-height: 100%; } .item_3_blocks_wrap .item_img_block .main_img .new { -- libgit2 0.21.4