Thursday, August 9, 2012

Model associations

Hi people, it´s me again!

I am using a habtm relationship in my application, it works 100% fine... But the Product menu is created dinamically with it´s Categories... so i have Product model and the Category model with habtm relationship between them.

In AppController i have to set at beforeFilter the variable "products_categories", as i dont need the products of each category right now i use $this->set('products_categories",$this->Product->CatProduct->find('all')); and it works fine... BUT, latter when i need to read the product category with it´s products, i would use $this->CatProduct->read('*',$id); right? BUT it´s returning ONLY the category, not the products relateds, but if i comment the line $this->Product->CatProduct->find('all') it works fine, and returns me the category and all related products.

What i am doing wrong? Isnt there anyway to get only the categories them get one category with it´s relateds?

Thanks!

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: