title = Yii::t('product', 'Products'); $this->params[ 'breadcrumbs' ][] = $this->title; ?>

title) ?>

'btn btn-success' ]) ?>

$dataProvider, 'filterModel' => $searchModel, 'columns' => [ 'product_id', [ 'label' => Yii::t('product', 'Brand'), 'attribute' => 'brand_id', 'value' => 'brand.lang.name', 'filter' => Select2::widget([ 'model' => $searchModel, 'attribute' => 'brand_id', 'data' => Brand::find()->joinWith('lang')->select(['brand_lang.name', 'brand.brand_id'])->asArray()->indexBy('brand_id')->column(), 'language' => 'ru', 'options' => [ 'placeholder' => Yii::t('product', 'Select brand'), 'multiple' => false, ], 'pluginOptions' => [ 'allowClear' => true, ], ]), ], [ 'label' => Yii::t('product', 'Category'), 'attribute' => 'category_id', 'value' => function($model) { /** * @var Product $model */ $categories = []; foreach($model->getCategories()->with('lang')->all() as $category) { /** * @var Category $category */ $categories[] = $category->lang->name; } return implode(", ", $categories); }, 'filter' => Select2::widget([ 'model' => $searchModel, 'attribute' => 'category_id', 'data' => ArtboxTreeHelper::treeMap(ProductHelper::getCategories(), 'category_id', 'lang.name'), 'language' => 'ru', 'options' => [ 'placeholder' => Yii::t('product', 'Select category'), 'multiple' => false, ], 'pluginOptions' => [ 'allowClear' => true, ], ]), ], // [ // 'label' => Yii::t('product', 'SKU'), // 'attribute' => 'variant_sku', // 'value' => 'variant.sku', // ], // 'variant.price', // 'variant.price_old', // [ // 'label' => Yii::t('product', 'Stock'), // 'attribute' => 'variant_stock', // 'value' => 'variant.stock_caption', // ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{items} {view} |{is_top} {is_new} {akciya} | {update} {delete}', 'buttons' => [ 'is_top' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('product', ( $model->is_top ? 'Set not is top' : 'Set is top' )), ]); }, 'is_new' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('product', ( $model->is_new ? 'Set not is new' : 'Set is new' )), ]); }, 'akciya' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('product', ( $model->akciya ? 'Set not is promotion' : 'Set is promotion' )), ]); }, 'items' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('product', 'Variants'), ]); }, ], 'urlCreator' => function($action, $model, $key, $index) { switch($action) { case 'items': return \yii\helpers\Url::to([ '/product/variant', 'product_id' => $model->product_id, ]); break; case 'is_top': return \yii\helpers\Url::to([ 'manage/is_top', 'id' => $model->product_id, ]); break; case 'is_new': return \yii\helpers\Url::to([ 'manage/is_new', 'id' => $model->product_id, ]); break; case 'akciya': return \yii\helpers\Url::to([ 'manage/akciya', 'id' => $model->product_id, ]); break; case 'view': return \yii\helpers\Url::to([ 'manage/view', 'id' => $model->product_id, ]); break; case 'update': return \yii\helpers\Url::to([ 'manage/update', 'id' => $model->product_id, ]); break; case 'delete': return \yii\helpers\Url::to([ 'manage/delete', 'id' => $model->product_id, ]); break; } }, ], ], ]); ?>