得到分类id为55
下的所有产品
$data = Yii::$service->category->product->coll([
'category_id' => '55',
'pageNum' => 1,
'numPerPage' => 20,
]);
详细:https://github.com/fecshop/yii2_fecshop/blob/master/services/category/Product.php#L43
这个函数是以前mongodb的实现方式,mysql的实现没有加入进去
你参考一下分类页面的搜索实现,看一下方法 Yii::$service->category->product->getFrontList
/**
* 得到当前分类的产品
*/
protected function getCategoryProductColl()
{
$productPrimaryKey = Yii::$service->product->getPrimaryKey();
$select = [
$productPrimaryKey, 'sku', 'spu', 'name', 'image',
'price', 'special_price',
'special_from', 'special_to',
'url_key', 'score', 'reviw_rate_star_average', 'review_count'
];
if (is_array($this->_sort_items)) {
foreach ($this->_sort_items as $sort_item) {
$select[] = $sort_item['db_columns'];
}
}
$filter = [
'pageNum' => $this->getPageNum(),
'numPerPage' => $this->getNumPerPage(),
'orderBy' => $this->getOrderBy(),
'where' => $this->_where,
'select' => $select,
];
//var_dump($filter);exit;
return Yii::$service->category->product->getFrontList($filter);
}