public function loadModel($id) { $model = ProductOption::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function loadProductOption($id) { $_productoption = array(); $data = ProductOption::model()->findAll('product_id=:product_id', array(':product_id' => $id)); if (!empty($data)) { foreach ($data as $productoption) { $value = ProductOptionValue::model()->findAll('product_option_id=:product_option_id', array(':product_option_id' => $productoption->id)); $_productoption[] = array($productoption, $value); } } return $_productoption; }
<?php $this->breadcrumbs = array('Product Attributes' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List ProductAttribute', 'url' => array('index')), array('label' => 'Create ProductAttribute', 'url' => array('create'))); ?> <h1>Manage Product Attributes</h1> <div> <?php echo CHtml::link('Add Product Attribute', array('ProductAttribute/create')); ?> | <?php echo CHtml::link('Manage Product Option', array('ProductOption/admin')); ?> | <?php echo CHtml::link('Manage Option Value', array('ProductOptionValue/admin')); ?> </div> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'product-attribute-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'summaryText' => '', 'pager' => array('header' => '', 'firstPageLabel' => '| <', 'lastPageLabel' => '> |', 'nextPageLabel' => '>', 'prevPageLabel' => '<'), 'columns' => array('product_attribute_id', array('name' => 'product_id', 'type' => 'html', 'value' => '$data->product->product_name', 'sortable' => TRUE, 'filter' => CHtml::listData(Product::model()->findAll(), 'product_id', 'product_name')), array('name' => 'product_option_id', 'type' => 'html', 'value' => '$data->productOption->product_option_name', 'sortable' => TRUE, 'filter' => CHtml::listData(ProductOption::model()->findAll(), 'product_option_id', 'product_option_name')), array('name' => 'option_value_id', 'type' => 'html', 'value' => '$data->productOptionValue->product_option_value_name', 'sortable' => TRUE, 'filter' => CHtml::listData(ProductOptionValue::model()->findAll(), 'product_option_value_id', 'product_option_value_name')), 'option_value_price', array('class' => 'CButtonColumn', 'template' => '{update} {delete}'))));
public function afterDelete() { // delete dependencies ProductAttribute::model()->deleteAll("product_id={$this->cacheId}"); ProductDescription::model()->deleteAll("product_id={$this->cacheId}"); ProductDiscount::model()->deleteAll("product_id={$this->cacheId}"); ProductFilter::model()->deleteAll("product_id={$this->cacheId}"); ProductImage::model()->deleteAll("product_id={$this->cacheId}"); ProductOption::model()->deleteAll("product_id={$this->cacheId}"); ProductOptionValue::model()->deleteAll("product_id={$this->cacheId}"); ProductRelated::model()->deleteAll("product_id={$this->cacheId}"); ProductRelated::model()->deleteAll("related_id={$this->cacheId}"); ProductReward::model()->deleteAll("product_id={$this->cacheId}"); ProductSpecial::model()->deleteAll("product_id={$this->cacheId}"); ProductToCategory::model()->deleteAll("product_id={$this->cacheId}"); ProductToDownload::model()->deleteAll("product_id={$this->cacheId}"); ProductToLayout::model()->deleteAll("product_id={$this->cacheId}"); ProductToStore::model()->deleteAll("product_id={$this->cacheId}"); Review::model()->deleteAll("product_id={$this->cacheId}"); UrlAlias::model()->deleteAll("query='product_id={$this->cacheId}'"); parent::afterDelete(); }
echo $form->labelEx($model, 'product_id'); ?> <?php echo $form->dropDownList($model, 'product_id', CHtml::listData(Product::model()->findAll(), 'product_id', 'product_name'), array('empty' => '--please select--')); ?> <?php echo $form->error($model, 'product_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'product_option_id'); ?> <?php echo $form->dropDownList($model, 'product_option_id', CHtml::listData(ProductOption::model()->findAll(), 'product_option_id', 'product_option_name'), array('empty' => '--please select--')); ?> <?php echo $form->error($model, 'product_option_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'option_value_id'); ?> <?php echo $form->dropDownList($model, 'option_value_id', CHtml::listData(ProductOptionValue::model()->findAll(), 'product_option_value_id', 'product_option_value_name'), array('empty' => '--please select--')); ?> <?php echo $form->error($model, 'option_value_id');
<?php $this->breadcrumbs = array('Product Option Value To Product Options' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List ProductOptionValueToProductOption', 'url' => array('index')), array('label' => 'Create ProductOptionValueToProductOption', 'url' => array('create'))); $this->title = 'Manage Product Option Value To Product Options'; ?> <!-- <h1>Manage Product Option Value To Product Options</h1> --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'product-option-value-to-product-option-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('product_option_value_to_product_option_id', array('name' => 'product_option_id', 'type' => 'html', 'value' => '$data->productOption->product_option_name', 'sortable' => TRUE, 'filter' => CHtml::listData(ProductOption::model()->findAll(), 'product_option_id', 'product_option_name')), array('name' => 'product_option_value_id', 'type' => 'html', 'value' => '$data->productOptionValue->product_option_value_name', 'sortable' => TRUE, 'filter' => CHtml::listData(ProductOptionValue::model()->findAll(), 'product_option_value_id', 'product_option_value_name')), array('class' => 'CButtonColumn', 'template' => '{update} {delete}'))));
public function validateProductOption($option) { $valid = true; $option->order_id = 0; $popt = ProductOption::model()->findByPk($option->product_option_id); if ($option->type == 'select' || $option->type == 'radio' || $option->type == 'checkbox') { if ($popt->required && (empty($option->product_option_value_id) || !is_numeric($option->product_option_value_id))) { $valid = false; } } else { $option->product_option_value_id = 0; if ($popt->required && empty($option->value)) { $valid = false; } } $valid = $valid && $option->validate(); Yii::log("OrderOptionCreateActionvaliid: " . $option->name . ' - ' . $valid . '---' . CVarDumper::dumpAsString($option->getErrors()), CLogger::LEVEL_ERROR, "order.actions.create"); return $valid; }
public function loadProductOption($id) { $data = ProductOption::model()->findAll('product_id=:product_id', array(':product_id' => $id)); foreach ($data as $productoption) { $value = ProductOptionValue::model()->findAll('product_option_id=:product_option_id', array(':product_option_id' => $productoption->id)); $valueList[] = $value; $this->_productoption[] = array($productoption, $value); } return $this->_productoption; }