I have 3 models in a cakephp 2.1 application Label, Category, Product.
Product is associated with Category & Label through a hasOne relationship.
What is the most efficient way using containable or linkable to achieve the following data structure.
[Label]
[Category]
[Product]
Basically I want to group Products by Categories and Categories by Labels.
The only solution I could come up with involved modifying a data in the afterFind style by retriveing products
$this->Product->find('all', array(
'contain' => array(
'Category',
'Label
);
and then itterating over the result using a foreach to reformat the datastructure to achieve the required result.