Commit ea8fd6e65dd2dbe95ecf11810ea1af9d1c4c9243
1 parent
36409192
-Product attributes
Showing
4 changed files
with
17 additions
and
10 deletions
Show diff stats
common/modules/product/views/manage/_form.php
... | ... | @@ -26,10 +26,6 @@ |
26 | 26 | |
27 | 27 | <?= $form->field($model, 'akciya')->checkbox(['label' => 'Акционный']) ?> |
28 | 28 | |
29 | - <?= $form->field($model, 'size')->textInput() ?> | |
30 | - | |
31 | - <?= $form->field($model, 'material')->textInput() ?> | |
32 | - | |
33 | 29 | <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> |
34 | 30 | |
35 | 31 | <?= $form->field($model, 'categories')->widget(Select2::className(), [ | ... | ... |
common/modules/rubrication/models/TaxGroup.php
frontend/controllers/CatalogController.php
... | ... | @@ -185,24 +185,33 @@ class CatalogController extends \yii\web\Controller |
185 | 185 | */ |
186 | 186 | public function actionProduct($product, $variant) |
187 | 187 | { |
188 | - | |
189 | - | |
188 | + | |
189 | + | |
190 | 190 | $product = Product::find() |
191 | 191 | ->joinWith([ |
192 | 192 | 'variants' => function($query) { |
193 | 193 | $query->indexBy('sku'); |
194 | - } | |
194 | + }, | |
195 | + 'options.group' | |
195 | 196 | ], true, 'INNER JOIN') |
196 | 197 | ->where([ |
197 | 198 | 'product.alias' => $product, |
198 | 199 | 'product_variant.sku' => $variant, |
199 | 200 | ])->with('category.parent')->one(); |
201 | + | |
202 | + $attributes = []; | |
203 | + foreach($product->options as $option) { | |
204 | + if(!$option->group->is_menu) continue; | |
205 | + $attributes[$option->group->name][] = $option->value; | |
206 | + } | |
207 | + | |
200 | 208 | $variant = $product->variants[$variant]; |
201 | 209 | $variants = $product->variants; |
202 | 210 | return $this->render('view', [ |
203 | 211 | 'variants' => $variants, |
204 | 212 | 'product' => $product, |
205 | 213 | 'variant' => $variant, |
214 | + 'attributes' => $attributes, | |
206 | 215 | ]); |
207 | 216 | } |
208 | 217 | ... | ... |
frontend/views/catalog/view.php
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | * @var ProductVariant $variant |
5 | 5 | * @var View $this |
6 | 6 | * @var ProductVariant[] $variants |
7 | + * @var array $attributes | |
7 | 8 | */ |
8 | 9 | use common\components\artboximage\ArtboxImageHelper; |
9 | 10 | use common\modules\product\models\Product; |
... | ... | @@ -58,8 +59,9 @@ $this->params['breadcrumbs'][] = $this->title; |
58 | 59 | |
59 | 60 | <ul> |
60 | 61 | <li><span>Артикул:</span> <?php echo $variant->sku; ?></li> |
61 | - <li><span>Размер:</span> <?php echo $product->size; ?></li> | |
62 | - <li><span>Состав:</span> <?php echo $product->material; ?></li> | |
62 | + <?php foreach($attributes as $group => $options) { ?> | |
63 | + <li><span><?php echo $group; ?>:</span> <?php echo implode(', ', $options); ?></li> | |
64 | + <?php } ?> | |
63 | 65 | </ul> |
64 | 66 | </div> |
65 | 67 | <div style="clear:both;"></div> | ... | ... |