public function actionTypeDelete($id) { if (Yii::app()->getRequest()->getIsPostRequest()) { $model = ProductLinkType::model()->findByPk($id); if ($model) { $model->delete(); } } else { throw new CHttpException(400, Yii::t('StoreModule.store', 'Unknown request. Don\'t repeat it please!')); } }
<?php /* @var $searchModel ProductSearch */ /* @var $product Product */ $linkTypes = ProductLinkType::getFormattedList(); ?> <div class="row"> <div class="col-sm-12"> <h3><?php echo Yii::t('StoreModule.store', 'Products related with "{name}"', ['{name}' => $product->name]); ?> </h3> <?php $linked = new ProductLink('search'); $linked->setAttributes(Yii::app()->getRequest()->getParam('ProductLink')); $linked->product_id = $product->id; $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'linked-product-grid', 'type' => 'condensed', 'dataProvider' => $linked->search(), 'filter' => $linked, 'actionsButtons' => false, 'bulkActions' => [false], 'ajaxUrl' => ['/store/productBackend/update', 'id' => $product->id], 'columns' => [['type' => 'raw', 'value' => function ($data) { return CHtml::link(CHtml::image($data->linkedProduct->getImageUrl(40, 40), "", ["class" => "img-thumbnail"]), ["/store/productBackend/update", "id" => $data->linkedProduct->id]); }], ['header' => Yii::t('StoreModule.store', 'Name'), 'type' => 'raw', 'value' => function ($data) { return CHtml::link($data->linkedProduct->name, ["/store/productBackend/update", "id" => $data->linkedProduct->id]); }], ['header' => Yii::t('StoreModule.store', 'SKU'), 'type' => 'raw', 'value' => function ($data) { return CHtml::link($data->linkedProduct->sku, ["/store/productBackend/update", "id" => $data->linkedProduct->id]); }], ['header' => Yii::t('StoreModule.store', 'Price'), 'type' => 'raw', 'value' => function ($data) { return $data->linkedProduct->price; }], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'type_id', 'url' => $this->createUrl('/store/linkBackend/inline'), 'source' => $linkTypes, 'options' => []], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'template' => '{delete}', 'buttons' => ['delete' => ['url' => function ($data) { return Yii::app()->createUrl('/store/linkBackend/delete', ['id' => $data->id]); }]]]]]); ?> </div>
<?php /* @var $searchModel ProductSearch */ /* @var $product Product */ $linkTypes = CHtml::listData(ProductLinkType::model()->findAll(['order' => 'title ASC']), 'id', 'title'); ?> <div class="row"> <div class="col-sm-12"> <h3><?php echo Yii::t('StoreModule.store', 'Products related with "{name}"', ['{name}' => $product->name]); ?> </h3> <?php $linked = new ProductLink('search'); $linked->setAttributes(Yii::app()->getRequest()->getParam('ProductLink')); $linked->product_id = $product->id; $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'linked-product-grid', 'type' => 'condensed', 'dataProvider' => $linked->search(), 'filter' => $linked, 'actionsButtons' => false, 'bulkActions' => [false], 'ajaxUrl' => ['/store/productBackend/update', 'id' => $product->id], 'columns' => [['type' => 'raw', 'value' => function ($data) { return CHtml::link(CHtml::image($data->linkedProduct->getImageUrl(40, 40), $data->linkedProduct->name, ["class" => "img-thumbnail"]), ["/store/productBackend/update", "id" => $data->linkedProduct->id]); }], ['header' => Yii::t('StoreModule.store', 'Name'), 'type' => 'raw', 'value' => function ($data) { return CHtml::link($data->linkedProduct->name, ["/store/productBackend/update", "id" => $data->linkedProduct->id]); }], ['header' => Yii::t('StoreModule.store', 'SKU'), 'type' => 'raw', 'value' => function ($data) { return CHtml::link($data->linkedProduct->sku, ["/store/productBackend/update", "id" => $data->linkedProduct->id]); }], ['header' => Yii::t('StoreModule.store', 'Price'), 'type' => 'raw', 'value' => function ($data) { return $data->linkedProduct->price; }], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'type_id', 'url' => $this->createUrl('/store/linkBackend/inline'), 'source' => $linkTypes, 'value' => function ($data) { return $data->type->title; }], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'template' => '{delete}', 'buttons' => ['delete' => ['url' => function ($data) { return Yii::app()->createUrl('/store/linkBackend/delete', ['id' => $data->id]); }]]]]]);