fecshop 得到某个分类下的产品列表

技术分享 · Fecmall · 于 5年前 发布 · 1660 次阅读

得到分类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

共收到 2 条回复
linxiongyin#13年前 0 个赞

求助: 这个是否不能用了? 试用的时候提示product_flat表中没有category字段. 数据库中也看了, product_flat表中的确没有

Fecmall#23年前 0 个赞

这个函数是以前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);
    }
	
添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics