Ejemplo n.º 1
0
 public function actionIndex()
 {
     $model = new ProductSearch('search');
     $model->unsetAttributes();
     $model->attributes = Yii::app()->getRequest()->getParam('ProductSearch');
     $this->render('/productBackend/_link_form', ['searchModel' => $model, 'product' => new Product()]);
 }
 /**
  * Редактирование товара.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if (Yii::app()->getRequest()->getIsPostRequest() && Yii::app()->getRequest()->getPost('Product')) {
         $attributes = Yii::app()->getRequest()->getPost('Product');
         $typeAttributes = Yii::app()->getRequest()->getPost('Attribute', []);
         $variants = Yii::app()->getRequest()->getPost('ProductVariant', []);
         $categories = Yii::app()->getRequest()->getPost('categories', []);
         if ($model->saveData($attributes, $typeAttributes, $variants, $categories)) {
             $this->updateProductImages($model);
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.store', 'Record was updated!'));
             if (!isset($_POST['submit-type'])) {
                 $this->redirect(['update', 'id' => $model->id]);
             } else {
                 $this->redirect([$_POST['submit-type']]);
             }
         } else {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('StoreModule.store', 'Failed to save product!'));
         }
     }
     $searchModel = new ProductSearch('search');
     $searchModel->unsetAttributes();
     $this->render('update', ['model' => $model, 'searchModel' => $searchModel]);
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $model = new ProductSearch('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['ProductSearch'])) {
         $model->attributes = $_GET['ProductSearch'];
     }
     $this->render('admin', array('model' => $model));
 }
Ejemplo n.º 4
0
<?php

/* @var $searchModel ProductSearch */
/* @var $product Product */
if (!isset($searchModel)) {
    $searchModel = new ProductSearch('search');
    $searchModel->unsetAttributes();
}
$linkTypes = ProductLinkType::getFormattedList();
?>

<?php 
if (isset($product)) {
    ?>
    <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.product', 'SKU'), 'type' => 'raw', 'value' => function ($data) {
        return CHtml::link($data->linkedProduct->sku, ["/store/productBackend/update", "id" => $data->linkedProduct->id]);
    }], ['header' => Yii::t('StoreModule.product', 'Price'), 'type' => 'raw', 'value' => function ($data) {