Commit ea8fd6e65dd2dbe95ecf11810ea1af9d1c4c9243

Authored by Alexey Boroda
1 parent 36409192

-Product attributes

common/modules/product/views/manage/_form.php
@@ -26,10 +26,6 @@ @@ -26,10 +26,6 @@
26 26
27 <?= $form->field($model, 'akciya')->checkbox(['label' => 'Акционный']) ?> 27 <?= $form->field($model, 'akciya')->checkbox(['label' => 'Акционный']) ?>
28 28
29 - <?= $form->field($model, 'size')->textInput() ?>  
30 -  
31 - <?= $form->field($model, 'material')->textInput() ?>  
32 -  
33 <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?> 29 <?= $form->field($model, 'description')->widget(\mihaildev\ckeditor\CKEditor::className(),['editorOptions' => [ 'preset' => 'full', 'inline' => false, ], ]); ?>
34 30
35 <?= $form->field($model, 'categories')->widget(Select2::className(), [ 31 <?= $form->field($model, 'categories')->widget(Select2::className(), [
common/modules/rubrication/models/TaxGroup.php
@@ -111,7 +111,7 @@ @@ -111,7 +111,7 @@
111 'is_filter' => 'Use in filter', 111 'is_filter' => 'Use in filter',
112 'sort' => 'Sort', 112 'sort' => 'Sort',
113 'display' => 'Display', 113 'display' => 'Display',
114 - 'is_menu' => 'Отображать в меню', 114 + 'is_menu' => 'Отображать в карточке товара',
115 ]; 115 ];
116 } 116 }
117 117
frontend/controllers/CatalogController.php
@@ -185,24 +185,33 @@ class CatalogController extends \yii\web\Controller @@ -185,24 +185,33 @@ class CatalogController extends \yii\web\Controller
185 */ 185 */
186 public function actionProduct($product, $variant) 186 public function actionProduct($product, $variant)
187 { 187 {
188 -  
189 - 188 +
  189 +
190 $product = Product::find() 190 $product = Product::find()
191 ->joinWith([ 191 ->joinWith([
192 'variants' => function($query) { 192 'variants' => function($query) {
193 $query->indexBy('sku'); 193 $query->indexBy('sku');
194 - } 194 + },
  195 + 'options.group'
195 ], true, 'INNER JOIN') 196 ], true, 'INNER JOIN')
196 ->where([ 197 ->where([
197 'product.alias' => $product, 198 'product.alias' => $product,
198 'product_variant.sku' => $variant, 199 'product_variant.sku' => $variant,
199 ])->with('category.parent')->one(); 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 $variant = $product->variants[$variant]; 208 $variant = $product->variants[$variant];
201 $variants = $product->variants; 209 $variants = $product->variants;
202 return $this->render('view', [ 210 return $this->render('view', [
203 'variants' => $variants, 211 'variants' => $variants,
204 'product' => $product, 212 'product' => $product,
205 'variant' => $variant, 213 'variant' => $variant,
  214 + 'attributes' => $attributes,
206 ]); 215 ]);
207 } 216 }
208 217
frontend/views/catalog/view.php
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 * @var ProductVariant $variant 4 * @var ProductVariant $variant
5 * @var View $this 5 * @var View $this
6 * @var ProductVariant[] $variants 6 * @var ProductVariant[] $variants
  7 + * @var array $attributes
7 */ 8 */
8 use common\components\artboximage\ArtboxImageHelper; 9 use common\components\artboximage\ArtboxImageHelper;
9 use common\modules\product\models\Product; 10 use common\modules\product\models\Product;
@@ -58,8 +59,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -58,8 +59,9 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
58 59
59 <ul> 60 <ul>
60 <li><span>Артикул:</span> <?php echo $variant->sku; ?></li> 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 </ul> 65 </ul>
64 </div> 66 </div>
65 <div style="clear:both;"></div> 67 <div style="clear:both;"></div>