diff --git a/models/Product.php b/models/Product.php index 0325c6f..658e608 100755 --- a/models/Product.php +++ b/models/Product.php @@ -2,6 +2,7 @@ namespace artweb\artbox\ecommerce\models; + use artweb\artbox\behaviors\SaveImgBehavior; use artweb\artbox\comment\models\CommentModel; use artweb\artbox\comment\models\interfaces\RatingCacheInterface; use artweb\artbox\ecommerce\behaviors\DefaultVariantBehavior; @@ -22,6 +23,7 @@ * @property integer $brand_id * @property integer $id * @property ProductVideo[] $videos + * @property string $size_image * @property Category $category * @property Category[] $categories * @property ProductVariant $variant @@ -122,7 +124,7 @@ 'product_id' => 'id', ], 'conditions' => [ - 'product_image.product_variant_id' => null, + 'product_image.product_variant_id' => NULL, ], 'model' => ProductImage::className(), 'config' => [ @@ -140,6 +142,15 @@ 'cacheRating' => true, 'cacheModelName' => ProductToRating::className(), ], + 'size_image' => [ + 'class' => SaveImgBehavior::className(), + 'fields' => [ + [ + 'name' => 'size_image', + 'directory' => 'products', + ], + ], + ], ]; } @@ -184,6 +195,10 @@ ], 'boolean', ], + [ + [ 'size_image' ], + 'string', + ], ]; } @@ -204,6 +219,7 @@ 'is_top' => Yii::t('product', 'Is top'), 'is_new' => Yii::t('product', 'Is new'), 'is_discount' => Yii::t('product', 'Is promo'), + 'size_image' => Yii::t('product', 'Sizes table'), ]; } diff --git a/views/manage/_form.php b/views/manage/_form.php index 5f82248..94a356c 100755 --- a/views/manage/_form.php +++ b/views/manage/_form.php @@ -1,5 +1,6 @@ + field($model, 'size_image') + ->widget( + \kartik\file\FileInput::className(), + [ + 'language' => 'ru', + 'options' => [ + 'accept' => 'image/*', + 'multiple' => false, + ], + 'pluginOptions' => [ + 'allowedFileExtensions' => [ + 'jpg', + 'gif', + 'png', + ], + 'initialPreview' => !empty( $model->getBehavior('size_image')->imageUrl ) ? ArtboxImageHelper::getImage( + $model->getBehavior('size_image')->imageUrl, + 'list' + ) : '', + 'overwriteInitial' => true, + 'showRemove' => false, + 'showUpload' => false, + 'previewFileType' => 'image', + ], + ] + ); ?> + with('lang') ->all() as $group) { -- libgit2 0.21.4