为什么我的收藏 不显示收藏产品? 后台收藏有收藏数据, var_dump($coll); 数据是空的?

技术问题 · happysunzone · 于 5年前 发布 · 2030 次阅读

为什么我的收藏 不显示收藏产品? 后台收藏有收藏数据, var_dump($coll); 数据是空的?

请问哪里出现问题了呢?

还有我想添加个用户产品浏览器记录 足迹,请问有没有好的方法做?

本文由 happysunzone 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。

共收到 3 条回复
qingdao#15年前 0 个赞

显示文件:https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/theme/base/front/customer/productfavorite/index.php

提供数据的文件:https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Customer/block/productfavorite/Index.php

 public function getLastData()
    {
        $this->initFavoriteParam();
        $identity = Yii::$app->user->identity;
        $user_id = $identity->id;
        if (!$user_id) {
            Yii::$service->helper->errors->add('current user id is empty');
            return;
        }
        $filter = [
            'pageNum'    => $this->pageNum,
            'numPerPage'=> $this->numPerPage,
            'orderBy'    => ['updated_at' => SORT_DESC],
            'where'            => [
                ['user_id' => $user_id],
            ],
            'asArray' => true,
        ];
        $data = Yii::$service->product->favorite->list($filter);
        $coll = $data['coll'];
        $count = $data['count'];
        $pageToolBar = $this->getProductPage($count);
        $product_arr = $this->getProductInfo($coll);
        return [
            'coll' => $product_arr,
            'pageToolBar'    => $pageToolBar,
        ];
    }

数据是由这里 $data = Yii::$service->product->favorite->list($filter); 获取的,这个函数是service函数,也就是文件: https://github.com/fecshop/yii2_fecshop/blob/master/services/product/Favorite.php

  protected function actionList($filter)
    {
        $query = $this->_favoriteModel->find();
        $query = Yii::$service->helper->ar->getCollByFilter($query, $filter);
        return [
            'coll' => $query->all(),
            'count'=> $query->limit(null)->offset(null)->count(),
        ];
    }
lincond#24年前 0 个赞

发现一个bug 收藏的产品,是根据$user_id,从mongodb里查询出来的,需要把$user_id数据类型强制转换成int,才可以把数据查询出来。 上面是我的开发环境。

Fecmall#34年前 0 个赞

@lincond #2楼

多谢,找时间处理一下。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics