Try Tree Behavior for category->SubCategory->SubCategory ,
and "workit" all in the same model "Category" ...

Product Model
public $hasAndBelongsToMany = array('Category');

Category Model
public $hasAndBelongsToMany = array('Product');
        public $hasMany = array('SubCategory'=>
        array('className' => 'Category',
                                                                'order'      => 
'lft',
                                'foreignKey' => 'parent_id',
                                                                'dependent'    
=>  true));
        public $actsAs = array('Tree');

http://book.cakephp.org/view/90/Using-Behaviors

don't forget the Categories_Products table
example:
CREATE TABLE `categories_products` (
  `category_id` int(10) unsigned NOT NULL DEFAULT '0',
  `product_id` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`product_id`,`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


On May 14, 10:18 am, Beedge <[email protected]> wrote:
> Hey all,
>
> I have (or plan to have!) an app that will allow users to view
> products by category. Each category can have a sub category and each
> sub category can have further sub categories..
>
> eg. sports>tennis>rackets>wooden
>
> There is no limit to the dept of sub categories.. (like in Ebay)
>
> I plan to have a table for the main categories and a table for the sub
> categories
>
> so a main category can have many sub categories, no problem, BUT, a
> sub category can also have many sub categories? is it possible to set
> up such a relationship? or should I just have another table with a
> list of all the chains?
>
> I hope I am making sense, and Im willing to listen to any suggestions
> on how one would accomplish such a structure
>
> Thanks
>
> Kevin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to