Commit 060b480672b0f189c7bb1ddb2af0a9426c3c14f8
1 parent
d7e712be
-
Showing
8 changed files
with
30 additions
and
18 deletions
Show diff stats
backend/controllers/BrandController.php
... | ... | @@ -97,11 +97,7 @@ class BrandController extends Controller |
97 | 97 | public function actionUpdate($id) |
98 | 98 | { |
99 | 99 | $model = $this->findModel($id); |
100 | - | |
101 | - var_dump($_POST); | |
102 | - print "\n+++++++++++++++++++++++++++++++++++++\n"; | |
103 | - var_dump($_FILES); | |
104 | - exit; | |
100 | + $model->setScenario('update'); | |
105 | 101 | |
106 | 102 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
107 | 103 | return $this->redirect(['view', 'id' => $model->brand_id]); | ... | ... |
backend/views/brand/_form.php
... | ... | @@ -18,7 +18,9 @@ use yii\widgets\ActiveForm; |
18 | 18 | |
19 | 19 | <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> |
20 | 20 | |
21 | - <?= \common\components\artboximage\ArtboxImageHelper::fileinputWidget($model, 'imageUrl');?> | |
21 | + <?php /*= \common\components\artboximage\ArtboxImageHelper::fileinputWidget($model, 'imageUrl');*/?> | |
22 | + | |
23 | + <?= $form->field($model, 'image')->fileInput(['accept' => 'image/*']) ?> | |
22 | 24 | |
23 | 25 | <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> |
24 | 26 | ... | ... |
common/modules/product/models/Brand.php
... | ... | @@ -4,6 +4,8 @@ namespace common\modules\product\models; |
4 | 4 | |
5 | 5 | use common\behaviors\Slug; |
6 | 6 | use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; |
7 | +use mongosoft\file\UploadBehavior; | |
8 | +use mongosoft\file\UploadImageBehavior; | |
7 | 9 | use Yii; |
8 | 10 | |
9 | 11 | /** |
... | ... | @@ -25,7 +27,6 @@ use Yii; |
25 | 27 | */ |
26 | 28 | class Brand extends \yii\db\ActiveRecord |
27 | 29 | { |
28 | - public $imageUpload; | |
29 | 30 | |
30 | 31 | public function behaviors() |
31 | 32 | { |
... | ... | @@ -43,6 +44,18 @@ class Brand extends \yii\db\ActiveRecord |
43 | 44 | 'slugKeyName' => 'alias', |
44 | 45 | 'translit' => true |
45 | 46 | ], |
47 | + 'uploader' => [ | |
48 | + 'class' => UploadImageBehavior::className(), | |
49 | + 'attribute' => 'image', | |
50 | + 'scenarios' => ['insert', 'update'], | |
51 | +// 'placeholder' => '@app/modules/user/assets/images/userpic.jpg', | |
52 | + 'path' => '@storage/{alias}', | |
53 | + 'url' => '/storage/{alias}', | |
54 | +// 'thumbs' => [ | |
55 | +// 'thumb' => ['width' => 400, 'quality' => 90], | |
56 | +// 'preview' => ['width' => 200, 'height' => 200], | |
57 | +// ], | |
58 | + ], | |
46 | 59 | ], |
47 | 60 | ]; |
48 | 61 | } |
... | ... | @@ -67,8 +80,7 @@ class Brand extends \yii\db\ActiveRecord |
67 | 80 | [['alias', 'name'], 'string', 'max' => 250], |
68 | 81 | [['image', 'meta_title'], 'string', 'max' => 255], |
69 | 82 | [['meta_robots'], 'string', 'max' => 50], |
70 | - [['imageUpload'], 'safe'], | |
71 | - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | |
83 | + ['image', 'file', 'extensions' => 'jpg, gif, png', 'on' => ['insert', 'update']], | |
72 | 84 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], |
73 | 85 | ]; |
74 | 86 | } | ... | ... |
common/modules/product/widgets/lastProducts.php
... | ... | @@ -15,6 +15,7 @@ class lastProducts extends Widget { |
15 | 15 | public function run() { |
16 | 16 | return $this->render('products_block', [ |
17 | 17 | 'title' => \Yii::t('product', 'Вы недавно просматривали'), |
18 | + 'class' => 'last-products', | |
18 | 19 | 'products' => ProductHelper::getLastProducts(true), |
19 | 20 | ]); |
20 | 21 | } | ... | ... |
common/modules/product/widgets/specialProducts.php
common/modules/product/widgets/views/products_block.php
frontend/views/catalog/product.php
... | ... | @@ -3,16 +3,16 @@ use yii\widgets\Breadcrumbs; |
3 | 3 | use yii\web\View; |
4 | 4 | use yii\helpers\Url; |
5 | 5 | |
6 | -$this->title = $product->name; | |
7 | -//$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->name; | |
8 | -//$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->name)]); | |
6 | +$this->title = $product->fullname; | |
7 | +//$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; | |
8 | +//$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); | |
9 | 9 | //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]); |
10 | 10 | |
11 | 11 | foreach($product->category->getParents()->all() as $parent) { |
12 | 12 | $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; |
13 | 13 | } |
14 | 14 | $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; |
15 | -$this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; | |
15 | +$this->params['breadcrumbs'][] = $product->fullname .' #'. $product->variant->sku; | |
16 | 16 | |
17 | 17 | $this->registerJs (' |
18 | 18 | |
... | ... | @@ -83,7 +83,7 @@ $this->registerJs (" |
83 | 83 | ['label' => 'Каталог', 'url' => ['catalog/all']], |
84 | 84 | // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]], |
85 | 85 | ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]], |
86 | - $product->name, | |
86 | + $product->fullname, | |
87 | 87 | ], |
88 | 88 | ]) ?> |
89 | 89 | <div class="both"></div> |
... | ... | @@ -93,7 +93,7 @@ $this->registerJs (" |
93 | 93 | <?php endif; ?> |
94 | 94 | <div class="loyout"> |
95 | 95 | <div class="productLeftBar"> |
96 | - <h1><?= $product->name ?></h1> | |
96 | + <h1><?= $product->fullname ?></h1> | |
97 | 97 | <div class="begin">Цветовые решения</div> |
98 | 98 | <ul class="product_mod"> |
99 | 99 | <?php foreach ($product->variants as $variant): ?> |
... | ... | @@ -104,7 +104,7 @@ $this->registerJs (" |
104 | 104 | data-color="<?= $variant->name ?>" |
105 | 105 | data-image="<?= $variant->imageUrl ?>" |
106 | 106 | data-imageoriginal="<?= $variant->imageUrl ?>" |
107 | - title="<?= $product->name ?>"> | |
107 | + title="<?= $product->fullname ?>"> | |
108 | 108 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?> |
109 | 109 | |
110 | 110 | </a> | ... | ... |
frontend/views/catalog/product_item.php