Hi everyone, I am new to yii, I have to say I am very happy with this framework.
I have a question tho:
I have a many to many relation defined between these tables as follows
table product
table category
tabel product_category
'categories' => array(self::MANY_MANY, 'Category', 'product_category(product_id, category_id)'),
within category there is a field: parent_id.
which is related to id in category
'children' => array(self::HAS_MANY, 'Category', 'parent_id'),
'parent' => array(self::BELONGS_TO, 'Category', 'parent_id'),
I want my dataprovider, if a category_id is given, to select all products that are connected to given category.
which works fine with a CActiveDataProvider defined as follows:
$dataProvider=new DataProvider('Product', array(
'criteria' => array(
'with' => 'categories',
'together' => true,
'condition' => $condition,
'params' => $params,
),
'pagination'=>array(
'pageSize'=>20,
),
Now I want my dataprovider also to select all products connected to categories with a parent_id that corresponds with the given category_id. I suspect this can be done by referencing the ‘parent’ and ‘children’ relations defined in the category model. Unfortunately I don’t know if and / or how this can be done.
Any help on this would be appreciated,
thanks in advance, Dick Brouwers