index.php 2.62 KB
<?php
    
    use artbox\catalog\models\Product;
    use artbox\catalog\models\ProductSearch;
    use yii\bootstrap\Html;
    use yii\data\ActiveDataProvider;
    use yii\web\View;
    use yiister\gentelella\widgets\grid\GridView;
    use yiister\gentelella\widgets\Panel;
    
    /**
     * @var View               $this
     * @var ProductSearch      $searchModel
     * @var ActiveDataProvider $dataProvider
     * @var Product            $product
     */
    
    $this->title = Yii::t(
        'catalog',
        'Variants for {product_title}',
        [
            'product_title' => $product->lang->title,
        ]
    );
    $this->params[ 'breadcrumbs' ][] = [
        'label' => Yii::t('catalog', 'Products'),
        'url'   => [
            '/product/index',
        ],
    ];
    $this->params[ 'breadcrumbs' ][] = [
        'label' => $product->lang->title,
        'url'   => [
            '/product/view',
            'id' => $product->id,
        ],
    ];
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="product-index">
    
    <?php
        $xPanel = Panel::begin(
            [
                'header' => Html::encode($this->title),
            ]
        );
    ?>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    
    <p>
        <?= Html::a(
            Yii::t('catalog', 'Create Product'),
            [
                'create',
                'product_id' => $product->id,
            ],
            [ 'class' => 'btn btn-success' ]
        ) ?>
    </p>
    <?= GridView::widget(
        [
            'dataProvider' => $dataProvider,
            'filterModel'  => $searchModel,
            'columns'      => [
                [ 'class' => 'yii\grid\SerialColumn' ],
                'id',
                [
                    'attribute' => 'title',
                    'value'     => 'lang.title',
                ],
                'sku',
                [
                    'attribute' => 'product_title',
                    'value'     => 'product.lang.title',
                ],
                'price',
                'stock',
                'created_at:datetime',
                [
                    'attribute' => 'status',
                    'format'    => 'boolean',
                    'filter'    => [
                        0 => \Yii::$app->formatter->asBoolean(0),
                        1 => \Yii::$app->formatter->asBoolean(1),
                    ],
                ],
                'sort',
                [
                    'class' => 'yii\grid\ActionColumn',
                ],
            ],
        ]
    ); ?>
    
    <?php
        $xPanel::end();
    ?>
</div>