我正在view()
根据另一个模型对关联模型进行分页。
public function view($id = null)
{
$category = $this->Categories->get($id, [
'contain' => ['Subcategories']
]);
// paginate products
$products = $this->paginate($this->Categories->Products->findByCategoryId($category->id, ['conditions' => ['stock >' => 0, 'selling_price >' => 0]]), [
'limit' => 21
]);
$this->set('products', $products);
$this->set('category', $category);
$this->set('_serialize', ['category']);
}
我想限制数据以查找大于 0 的stock
位置。selling_price
但这不起作用。如何申请条件findById
?