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,11 +97,7 @@ class BrandController extends Controller | ||
97 | public function actionUpdate($id) | 97 | public function actionUpdate($id) |
98 | { | 98 | { |
99 | $model = $this->findModel($id); | 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 | if ($model->load(Yii::$app->request->post()) && $model->save()) { | 102 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
107 | return $this->redirect(['view', 'id' => $model->brand_id]); | 103 | return $this->redirect(['view', 'id' => $model->brand_id]); |
backend/views/brand/_form.php
@@ -18,7 +18,9 @@ use yii\widgets\ActiveForm; | @@ -18,7 +18,9 @@ use yii\widgets\ActiveForm; | ||
18 | 18 | ||
19 | <?= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?> | 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 | <?= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?> | 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,6 +4,8 @@ namespace common\modules\product\models; | ||
4 | 4 | ||
5 | use common\behaviors\Slug; | 5 | use common\behaviors\Slug; |
6 | use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; | 6 | use common\modules\rubrication\behaviors\ArtboxSynonymBehavior; |
7 | +use mongosoft\file\UploadBehavior; | ||
8 | +use mongosoft\file\UploadImageBehavior; | ||
7 | use Yii; | 9 | use Yii; |
8 | 10 | ||
9 | /** | 11 | /** |
@@ -25,7 +27,6 @@ use Yii; | @@ -25,7 +27,6 @@ use Yii; | ||
25 | */ | 27 | */ |
26 | class Brand extends \yii\db\ActiveRecord | 28 | class Brand extends \yii\db\ActiveRecord |
27 | { | 29 | { |
28 | - public $imageUpload; | ||
29 | 30 | ||
30 | public function behaviors() | 31 | public function behaviors() |
31 | { | 32 | { |
@@ -43,6 +44,18 @@ class Brand extends \yii\db\ActiveRecord | @@ -43,6 +44,18 @@ class Brand extends \yii\db\ActiveRecord | ||
43 | 'slugKeyName' => 'alias', | 44 | 'slugKeyName' => 'alias', |
44 | 'translit' => true | 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,8 +80,7 @@ class Brand extends \yii\db\ActiveRecord | ||
67 | [['alias', 'name'], 'string', 'max' => 250], | 80 | [['alias', 'name'], 'string', 'max' => 250], |
68 | [['image', 'meta_title'], 'string', 'max' => 255], | 81 | [['image', 'meta_title'], 'string', 'max' => 255], |
69 | [['meta_robots'], 'string', 'max' => 50], | 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 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], | 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,6 +15,7 @@ class lastProducts extends Widget { | ||
15 | public function run() { | 15 | public function run() { |
16 | return $this->render('products_block', [ | 16 | return $this->render('products_block', [ |
17 | 'title' => \Yii::t('product', 'Вы недавно просматривали'), | 17 | 'title' => \Yii::t('product', 'Вы недавно просматривали'), |
18 | + 'class' => 'last-products', | ||
18 | 'products' => ProductHelper::getLastProducts(true), | 19 | 'products' => ProductHelper::getLastProducts(true), |
19 | ]); | 20 | ]); |
20 | } | 21 | } |
common/modules/product/widgets/specialProducts.php
@@ -40,6 +40,7 @@ class specialProducts extends Widget { | @@ -40,6 +40,7 @@ class specialProducts extends Widget { | ||
40 | 40 | ||
41 | return $this->render('products_block', [ | 41 | return $this->render('products_block', [ |
42 | 'title' => $this->title, | 42 | 'title' => $this->title, |
43 | + 'class' => $this->type, | ||
43 | 'products' => $products, | 44 | 'products' => $products, |
44 | ]); | 45 | ]); |
45 | } | 46 | } |
common/modules/product/widgets/views/products_block.php
frontend/views/catalog/product.php
@@ -3,16 +3,16 @@ use yii\widgets\Breadcrumbs; | @@ -3,16 +3,16 @@ use yii\widgets\Breadcrumbs; | ||
3 | use yii\web\View; | 3 | use yii\web\View; |
4 | use yii\helpers\Url; | 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 | //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]); | 9 | //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]); |
10 | 10 | ||
11 | foreach($product->category->getParents()->all() as $parent) { | 11 | foreach($product->category->getParents()->all() as $parent) { |
12 | $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; | 12 | $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; |
13 | } | 13 | } |
14 | $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; | 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 | $this->registerJs (' | 17 | $this->registerJs (' |
18 | 18 | ||
@@ -83,7 +83,7 @@ $this->registerJs (" | @@ -83,7 +83,7 @@ $this->registerJs (" | ||
83 | ['label' => 'Каталог', 'url' => ['catalog/all']], | 83 | ['label' => 'Каталог', 'url' => ['catalog/all']], |
84 | // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]], | 84 | // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]], |
85 | ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]], | 85 | ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]], |
86 | - $product->name, | 86 | + $product->fullname, |
87 | ], | 87 | ], |
88 | ]) ?> | 88 | ]) ?> |
89 | <div class="both"></div> | 89 | <div class="both"></div> |
@@ -93,7 +93,7 @@ $this->registerJs (" | @@ -93,7 +93,7 @@ $this->registerJs (" | ||
93 | <?php endif; ?> | 93 | <?php endif; ?> |
94 | <div class="loyout"> | 94 | <div class="loyout"> |
95 | <div class="productLeftBar"> | 95 | <div class="productLeftBar"> |
96 | - <h1><?= $product->name ?></h1> | 96 | + <h1><?= $product->fullname ?></h1> |
97 | <div class="begin">Цветовые решения</div> | 97 | <div class="begin">Цветовые решения</div> |
98 | <ul class="product_mod"> | 98 | <ul class="product_mod"> |
99 | <?php foreach ($product->variants as $variant): ?> | 99 | <?php foreach ($product->variants as $variant): ?> |
@@ -104,7 +104,7 @@ $this->registerJs (" | @@ -104,7 +104,7 @@ $this->registerJs (" | ||
104 | data-color="<?= $variant->name ?>" | 104 | data-color="<?= $variant->name ?>" |
105 | data-image="<?= $variant->imageUrl ?>" | 105 | data-image="<?= $variant->imageUrl ?>" |
106 | data-imageoriginal="<?= $variant->imageUrl ?>" | 106 | data-imageoriginal="<?= $variant->imageUrl ?>" |
107 | - title="<?= $product->name ?>"> | 107 | + title="<?= $product->fullname ?>"> |
108 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?> | 108 | <?= \common\components\artboximage\ArtboxImageHelper::getImage($variant->imageUrl, 'product_variant')?> |
109 | 109 | ||
110 | </a> | 110 | </a> |
frontend/views/catalog/product_item.php
@@ -25,7 +25,7 @@ use yii\helpers\Url; | @@ -25,7 +25,7 @@ use yii\helpers\Url; | ||
25 | <a href="<?= Url::to([ | 25 | <a href="<?= Url::to([ |
26 | 'catalog/product', | 26 | 'catalog/product', |
27 | 'product' => $product]) | 27 | 'product' => $product]) |
28 | - ?>" class="name"><?= $product->name ?> | 28 | + ?>" class="name"><?= $product->fullname ?> |
29 | </a> | 29 | </a> |
30 | 30 | ||
31 | <?php | 31 | <?php |