/** * @param StoreCategory $category * @param CDbCriteria $mergeWith * @return array|mixed|null */ public function getForCategory(StoreCategory $category, CDbCriteria $mergeWith) { $criteria = new CDbCriteria(['order' => 't.sort ASC', 'join' => 'LEFT JOIN {{store_product}} AS products ON products.producer_id = t.id', 'distinct' => true]); $criteria->addInCondition('products.category_id', [$category->id]); $criteria->mergeWith($mergeWith); return Producer::model()->findAll($criteria); }
public function actionView($slug) { $producer = Producer::model()->getBySlug($slug); if (!$producer) { throw new CHttpException(404, Yii::t('StoreModule.store', 'Page not found!')); } $this->render('view', ['brand' => $producer, 'products' => $this->productRepository->getByBrandProvider($producer)]); }
public function loadModel($id) { $model = Producer::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('StoreModule.producer', 'Запрошенная страница не найдена.')); } return $model; }
public function loadModel($id) { $model = Producer::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('StoreModule.store', 'Page not found!')); } return $model; }
/** * @throws CException */ public function run() { $criteria = new CDbCriteria(['limit' => $this->limit, 'order' => $this->order, 'scopes' => ['published']]); if (null === $this->category) { $producers = Producer::model()->findAll($criteria); } else { $producers = $this->producerRepository->getForCategory($this->category, $criteria); } $this->render($this->view, ['producers' => $producers]); }
<div class="col-sm-3"> <br/> <?php echo $form->checkBoxGroup($model, 'is_special'); ?> </div> </div> <div class="row"> <div class="col-sm-4"> <?php echo $form->dropDownListGroup($model, 'category_id', ['widgetOptions' => ['data' => StoreCategoryHelper::formattedList(), 'htmlOptions' => ['empty' => '---', 'encode' => false]]]); ?> </div> <div class="col-sm-3"> <?php echo $form->dropDownListGroup($model, 'producer_id', ['widgetOptions' => ['data' => Producer::model()->getFormattedList(), 'htmlOptions' => ['empty' => '---']]]); ?> </div> </div> <div class="row"> <div class="col-sm-7"> <?php echo $form->textFieldGroup($model, 'name'); ?> </div> </div> <div class="row"> <div class="col-sm-7"> <?php echo $form->slugFieldGroup($model, 'slug', ['sourceAttribute' => 'name']); ?>
public function run() { $criteria = new CDbCriteria(); $criteria->select = 'inkind'; $criteria->distinct = true; $t['unselectValue'] = NULL; $this->inkind = Inkind::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->inkind); $i++) { $t[$this->inkind[$i]->inkind] = $this->inkind[$i]->inkind; } $t['unselectValue'] = ''; $this->inkind = $t; $t = []; // var_dump($this->inkind); $criteria = new CDbCriteria(); $criteria->select = 'kindparent'; $criteria->distinct = true; $t['unselectValue'] = NULL; $this->kindparent = Kindparent::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->kindparent); $i++) { $t[$this->kindparent[$i]->kindparent] = $this->kindparent[$i]->kindparent; } $this->kindparent = $t; $t = []; // var_dump($this->kindparent); $criteria = new CDbCriteria(); $criteria->select = 'producer'; $criteria->distinct = true; //$t['uncheckValue']=NULL; $this->producer = Producer::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->producer); $i++) { $t[$this->producer[$i]->producer] = $this->producer[$i]->producer; } $this->producer = $t; $t = []; $form = new ProductSelectForm(); $form->clearErrors(); if (isset($_POST['ProductSelectForm'])) { $form->attributes = $_POST['ProductSelectForm']; } // if (isset($_POST['ProductSelectForm'])) { // $form->kindparent=$_POST['ProductSelectForm']['kindparent']; // $form->inkind=$_POST['ProductSelectForm']['inkind']; // $form->producer=$_POST['ProductSelectForm']['producer'];} //$form->min=$_POST['ProductSelectForm']['min']; //$form->max=$_POST['ProductSelectForm']['max']; // var_dump($_POST['ProductSelectForm']); // } //var_dump($_POST); // var_dump($form->validate()); // if (isset($_POST['ProductSelectForm'])&&(!$form->validate())) { // unset($_POST['SiteSearchForm']); // $form->clearErrors(); // $form->addError('ProductSelectForm','Задайте условия поиска'); // $z=$form->getErrors(); // var_dump($z); // } // } // var_dump($_GET); $this->render('productSelect', array('form' => $form, 'inkind' => $this->inkind, 'kindparent' => $this->kindparent, 'producer' => $this->producer)); $form->clearErrors(); }
public function getFormattedList() { return CHtml::listData(Producer::model()->findAll(), 'id', 'name_short'); }
public function run() { $this->render($this->view, ['producers' => Producer::model()->published()->cache($this->cacheTime)->findAll()]); }
<div class="col-sm-12"> <?php echo $form->checkboxGroup($model, 'shop_cpa'); ?> </div> </div> </div> </div> <div class='row'> <div class="col-sm-3"> <?php echo CHtml::hiddenField('Export[brands]'); ?> <?php echo $form->dropDownListGroup($model, 'brands', ['widgetOptions' => ['data' => Producer::model()->getFormattedList(), 'htmlOptions' => ['multiple' => true, 'size' => 10]]]); ?> </div> <div class="col-sm-4"> <?php echo CHtml::activeLabel($model, Yii::t('YandexMarketModule.default', 'Categories')); ?> <?php $this->widget('store.widgets.CategoryTreeWidget', ['selectedCategories' => $model->categories, 'id' => 'category-tree']); ?> <?php echo CHtml::hiddenField('Export[categories]'); ?> </div> </div>
/** * @throws CException */ public function run() { $this->render($this->view, ['producers' => Producer::model()->published()->findAll(['limit' => $this->limit])]); }
/** * @throws CException */ public function run() { $criteria = new CDbCriteria(['limit' => $this->limit, 'order' => $this->order, 'scopes' => ['published']]); $this->render($this->view, ['brands' => $this->category ? $this->producerRepository->getForCategory($this->category, $criteria) : Producer::model()->findAll($criteria), 'title' => $this->title]); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Producer the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Producer::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * @throws CException */ public function run() { $this->render($this->view, ['brands' => Producer::model()->getAll($this->limit, $this->order)]); }
<?php echo $form->labelEx($model, 'width'); ?> <?php echo $form->textField($model, 'width', array('placeholder' => 'in inches')); ?> <?php echo $form->error($model, 'width'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'producer_id'); ?> <?php echo $form->dropDownList($model, 'producer_id', GxHtml::listDataEx(Producer::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'producer_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'price'); ?> <?php echo $form->textField($model, 'price', array('placeholder' => 'in Rs.')); ?> <?php echo $form->error($model, 'price'); ?>
<?php echo Yii::t('StoreModule.store', 'Products'); ?> <small><?php echo Yii::t('StoreModule.store', 'administration'); ?> </small> </h1> </div> <?php $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'product-grid', 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'position', 'sortableAction' => '/store/productBackend/sortable', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'actionsButtons' => ['add' => CHtml::link(Yii::t('StoreModule.store', 'Add'), ['/store/productBackend/create'], ['class' => 'btn btn-sm btn-success pull-right']), 'copy' => CHtml::link(Yii::t('StoreModule.store', 'Copy'), '#', ['id' => 'copy-products', 'class' => 'btn btn-sm btn-default pull-right', 'style' => 'margin-right: 4px;'])], 'columns' => [['type' => 'raw', 'value' => function ($data) { return CHtml::image(StoreImage::product($data, 40, 40), $data->name, ["width" => 40, "height" => 40, "class" => "img-thumbnail"]); }], ['name' => 'name', 'type' => 'raw', 'value' => function ($data) { return CHtml::link(\yupe\helpers\YText::wordLimiter($data->name, 5), ["/store/productBackend/update", "id" => $data->id]); }], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'sku', 'editable' => ['emptytext' => '---', 'url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'sku', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'producer_id', 'url' => $this->createUrl('/store/productBackend/inline'), 'source' => CMap::mergeArray(['' => '---'], Producer::model()->getFormattedList()), 'editable' => ['emptytext' => '---']], ['name' => 'category_id', 'value' => function ($data) { $categoryList = '<span class="label label-primary">' . (isset($data->category) ? $data->category->name : '---') . '</span>'; foreach ($data->categories as $category) { $categoryList .= '<br>' . $category->name; } return $categoryList; }, 'type' => 'raw', 'filter' => CHtml::activeDropDownList($model, 'category_id', StoreCategoryHelper::formattedList(), ['encode' => false, 'empty' => '', 'class' => 'form-control']), 'htmlOptions' => ['width' => '220px']], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'price', 'value' => function (Product $data) { return round($data->getBasePrice(), 2); }, 'editable' => ['url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'price', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'discount_price', 'header' => Yii::t('StoreModule.store', 'New price'), 'value' => function (Product $data) { return round($data->getDiscountPrice(), 2); }, 'editable' => ['emptytext' => '---', 'url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'discount_price', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'in_stock', 'header' => Yii::t('StoreModule.store', 'Availability'), 'url' => $this->createUrl('/store/productBackend/inline'), 'source' => $model->getInStockList(), 'options' => [Product::STATUS_IN_STOCK => ['class' => 'label-success'], Product::STATUS_NOT_IN_STOCK => ['class' => 'label-danger']]], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'quantity', 'value' => function (Product $data) { return $data->quantity; }, 'header' => Yii::t('StoreModule.store', 'Rest'), 'editable' => ['url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'price', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'status', 'url' => $this->createUrl('/store/productBackend/inline'), 'source' => $model->getStatusList(), 'options' => [Product::STATUS_ACTIVE => ['class' => 'label-success'], Product::STATUS_NOT_ACTIVE => ['class' => 'label-info'], Product::STATUS_ZERO => ['class' => 'label-default']]], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'buttons' => ['front_view' => ['visible' => function ($row, $data) { return $data->status == Product::STATUS_ACTIVE; }]]]]]); ?>
<div class="row"> <?php echo $form->label($model, 'width'); ?> <?php echo $form->textField($model, 'width'); ?> </div> <div class="row"> <?php echo $form->label($model, 'producer_id'); ?> <?php echo $form->dropDownList($model, 'producer_id', GxHtml::listDataEx(Producer::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'price'); ?> <?php echo $form->textField($model, 'price'); ?> </div> <div class="row"> <?php echo $form->label($model, 'status');