I have Categories associated to many Products but a Product can only have one category.
In my Category view, I have a list of all products assign to that particular category and outputted into a table. I'm trying to paginate this table, since it can easily grow in size.
My CategoriesController, View action:
public function admin_view($id=null) {
if (!$id) {$this->redirect('/admin/categories');}
$category = $this->Category->find('first', array(
'conditions' => array(
'Category.id' => $id
),
'contain' => array('Product')
));
if(!$category) {
$this->redirect('/admin/categories');
} else {
$this->set('category', $category);
}
- Category Model:
public $hasMany = array('Product'); - Product Model:
public $belongsTo = 'Category';
This outputs the data with a Category array with all the Category data and a Products array with all the Products associated with this particular Category:

Question: How can I paginate the Products list that I have as a table in my Categories Admin_View view?