I have a problem with my Cakephp(2.6) find-query and deep association.
My Relations:
Item hasMany Variant
Variant hasAndBelongsToMany Color
I am trying to find all Items that have at least one variant with the color = blue.
$options['contain'] = array(
'Variant' =>array(
'Color' => array(
'conditions' => array(
'Color.name =' => 'blue'
))));
$this->Item->find('all',$options);
The above query returns items having no variant.
How do I tell Cake to only return those Items having Variants that have at least the color blue?
You cannot do it like this, you must find variants having the color you want. Try this