Hi all,
when a person clicks on a category display him all products under category in a gridview
view preson
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'admin-grid',
'dataProvider'=>$model->SelectedCategoryProducts,
'filter'=>$model,
'columns'=>array(
'Name',
'Model',
'Brand',
'Price',
array(
'class'=>'CButtonColumn',
),
),
)); ?>[code]
[/code]
controller person
public function actionProductcategory($id)
{
$model=new Product;
$this->render('productcategory',array('model'=>$model,));
}
model in products
public function SelectedCategoryProducts($id)
{
$sql="select name,model,price,brand from fc_product
WHERE category=".$id;
$connection=Yii::app()->db;
$command=$connection->createCommand($sql);
$cat_product=$command->queryAll();
return new CSqlDataProvider($sql, array(
'sort' => array(
'attributes' => array(
'Name', 'Model', 'Brand','Price',
),
),
'pagination' => false));
}
CException
Property "Product.SelectedCategoryProducts" is not defined.
PLEASE HELP! am losing may mind on this … not able to display gridview