我正在尝试获取特定类别的所有产品(产品包含并且属于Catrgories)。我的条件是Category.name ='whatever'和Product.live = 1
我可以这样做:
$cats = $this->Category->find('all', array(
'conditions' => array(
'Category.name' => $categoryName
),
'contain' => 'Product.live = 1'
));
但我也希望按Product.sort_order对结果进行排序,所以我尝试了:
$cats = $this->Category->find('all', array(
'conditions' => array(
'Category.name' => $categoryName
),
'order' => array('Product.sort_order'),
'contain' => 'Product.live = 1'
));
但这不起作用。什么是正确的方法?