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

title) ?>

'btn btn-success' ]) ?>

$dataProvider, 'filterModel' => $searchModel, 'columns' => [ 'product_id', [ 'label' => Yii::t('product', 'Product Name'), 'attribute' => 'product_name', 'value' => 'lang.name', ], [ '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', 'Variant Count'), 'attribute' => 'variant_count', 'value' => function($model) { /** * @var Product $model */ return count($model->variants); }, ], [ '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 ? Yii::t('app', 'Set not is top') : Yii::t('app', 'Set is top') )), ]); }, 'is_new' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('product', ( $model->is_new ? Yii::t('app', 'Set not is new') : Yii::t('app', 'Set is new') )), ]); }, 'akciya' => function($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('product', ( $model->akciya ? Yii::t('app', 'Set not is promotion') : Yii::t('app', '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; default: return ''; } }, ], ], ]); ?>