显示文件: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(),
];
}