提交 4bb5b730 编写于 作者: T Terry

产品收藏,各个入口的调整

上级 731a9cb6
...@@ -122,10 +122,10 @@ class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface ...@@ -122,10 +122,10 @@ class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
$activeStatus = Yii::$service->product->review->activeStatus(); $activeStatus = Yii::$service->product->review->activeStatus();
$refuseStatus = Yii::$service->product->review->refuseStatus(); $refuseStatus = Yii::$service->product->review->refuseStatus();
$noActiveStatus = Yii::$service->product->review->noActiveStatus(); $noActiveStatus = Yii::$service->product->review->noActiveStatus();
$reviewPrimaryKey = Yii::$service->product->review->getPrimaryKey();
$table_th_bar = [ $table_th_bar = [
[ [
'orderField' => '_id', 'orderField' => $reviewPrimaryKey,
'label' => Yii::$service->page->translate->__('Id'), 'label' => Yii::$service->page->translate->__('Id'),
'width' => '50', 'width' => '50',
'align' => 'left', 'align' => 'left',
......
...@@ -52,6 +52,7 @@ class Index ...@@ -52,6 +52,7 @@ class Index
$pageToolBar = $this->getProductPage($count); $pageToolBar = $this->getProductPage($count);
$product_arr = $this->getProductInfo($coll); $product_arr = $this->getProductInfo($coll);
$this->breadcrumbs(Yii::$service->page->translate->__('Customer Product Favorite')); $this->breadcrumbs(Yii::$service->page->translate->__('Customer Product Favorite'));
return [ return [
'coll' => $product_arr, 'coll' => $product_arr,
'pageToolBar' => $pageToolBar, 'pageToolBar' => $pageToolBar,
...@@ -73,20 +74,24 @@ class Index ...@@ -73,20 +74,24 @@ class Index
{ {
$product_ids = []; $product_ids = [];
$favorites = []; $favorites = [];
$favoritePrimaryKey = Yii::$service->product->favorite->getPrimaryKey();
foreach ($coll as $one) { foreach ($coll as $one) {
$p_id = (string)$one['product_id']; $p_id = (string)$one['product_id'];
$product_ids[] = $one['product_id']; $product_ids[] = $one['product_id'];
$favorites[$p_id] = [ $favorites[$p_id] = [
'updated_at' => $one['updated_at'], 'updated_at' => $one['updated_at'],
'favorite_id' => (string) $one['_id'], 'favorite_id' => (string) $one[$favoritePrimaryKey],
]; ];
} }
$productPrimaryKey = Yii::$service->product->getPrimaryKey();
// 得到产品的信息 // 得到产品的信息
$product_filter = [ $product_filter = [
'where' => [ 'where' => [
['in', '_id', $product_ids], ['in', $productPrimaryKey, $product_ids],
], ],
'select' => [ 'select' => [
$productPrimaryKey,
'name', 'image', 'name', 'image',
'price', 'special_price', 'price', 'special_price',
'special_from', 'special_to', 'special_from', 'special_to',
...@@ -94,17 +99,18 @@ class Index ...@@ -94,17 +99,18 @@ class Index
], ],
'asArray' => true, 'asArray' => true,
]; ];
$data = Yii::$service->product->coll($product_filter); $data = Yii::$service->product->coll($product_filter);
$product_arr = []; $product_arr = [];
if (is_array($data['coll']) && !empty($data['coll'])) { if (is_array($data['coll']) && !empty($data['coll'])) {
foreach ($data['coll'] as $one) { foreach ($data['coll'] as $one) {
$p_id = (string) $one['_id']; $p_id = (string) $one[$productPrimaryKey];
$one['updated_at'] = $favorites[$p_id]['updated_at']; $one['updated_at'] = $favorites[$p_id]['updated_at'];
$one['favorite_id'] = $favorites[$p_id]['favorite_id']; $one['favorite_id'] = $favorites[$p_id]['favorite_id'];
$product_arr[] = $one; $product_arr[] = $one;
} }
} }
return \fec\helpers\CFunc::array_sort($product_arr, 'updated_at', 'desc'); return \fec\helpers\CFunc::array_sort($product_arr, 'updated_at', 'desc');
} }
......
...@@ -18,7 +18,7 @@ use Yii; ...@@ -18,7 +18,7 @@ use Yii;
class Index class Index
{ {
public $pageNum; public $pageNum;
public $numPerPage = 20; public $numPerPage = 10;
public $_page = 'p'; public $_page = 'p';
public function initFavoriteParam() public function initFavoriteParam()
...@@ -51,6 +51,7 @@ class Index ...@@ -51,6 +51,7 @@ class Index
$count = $data['count']; $count = $data['count'];
$pageToolBar = $this->getProductPage($count); $pageToolBar = $this->getProductPage($count);
$product_arr = $this->getProductInfo($coll); $product_arr = $this->getProductInfo($coll);
$this->breadcrumbs(Yii::$service->page->translate->__('Customer Product Favorite'));
return [ return [
'coll' => $product_arr, 'coll' => $product_arr,
...@@ -58,25 +59,39 @@ class Index ...@@ -58,25 +59,39 @@ class Index
]; ];
} }
// 面包屑导航
protected function breadcrumbs($name)
{
if (Yii::$app->controller->module->params['customer_product_favorite_breadcrumbs']) {
Yii::$service->page->breadcrumbs->addItems(['name' => $name]);
} else {
Yii::$service->page->breadcrumbs->active = false;
}
}
// 得到产品的一些信息,来显示Favorite 的产品列表。 // 得到产品的一些信息,来显示Favorite 的产品列表。
public function getProductInfo($coll) public function getProductInfo($coll)
{ {
$product_ids = []; $product_ids = [];
$favorites = []; $favorites = [];
$favoritePrimaryKey = Yii::$service->product->favorite->getPrimaryKey();
foreach ($coll as $one) { foreach ($coll as $one) {
$p_id = (string)$one['product_id']; $p_id = (string)$one['product_id'];
$product_ids[] = $one['product_id']; $product_ids[] = $one['product_id'];
$favorites[$p_id] = [ $favorites[$p_id] = [
'updated_at' => $one['updated_at'], 'updated_at' => $one['updated_at'],
'favorite_id' => (string) $one['_id'], 'favorite_id' => (string) $one[$favoritePrimaryKey],
]; ];
} }
$productPrimaryKey = Yii::$service->product->getPrimaryKey();
// 得到产品的信息 // 得到产品的信息
$product_filter = [ $product_filter = [
'where' => [ 'where' => [
['in', '_id', $product_ids], ['in', $productPrimaryKey, $product_ids],
], ],
'select' => [ 'select' => [
$productPrimaryKey,
'name', 'image', 'name', 'image',
'price', 'special_price', 'price', 'special_price',
'special_from', 'special_to', 'special_from', 'special_to',
...@@ -84,17 +99,18 @@ class Index ...@@ -84,17 +99,18 @@ class Index
], ],
'asArray' => true, 'asArray' => true,
]; ];
$data = Yii::$service->product->coll($product_filter); $data = Yii::$service->product->coll($product_filter);
$product_arr = []; $product_arr = [];
if (is_array($data['coll']) && !empty($data['coll'])) { if (is_array($data['coll']) && !empty($data['coll'])) {
foreach ($data['coll'] as $one) { foreach ($data['coll'] as $one) {
$p_id = (string) $one['_id']; $p_id = (string) $one[$productPrimaryKey];
$one['updated_at'] = $favorites[$p_id]['updated_at']; $one['updated_at'] = $favorites[$p_id]['updated_at'];
$one['favorite_id'] = $favorites[$p_id]['favorite_id']; $one['favorite_id'] = $favorites[$p_id]['favorite_id'];
$product_arr[] = $one; $product_arr[] = $one;
} }
} }
return \fec\helpers\CFunc::array_sort($product_arr, 'updated_at', 'desc'); return \fec\helpers\CFunc::array_sort($product_arr, 'updated_at', 'desc');
} }
...@@ -112,7 +128,7 @@ class Index ...@@ -112,7 +128,7 @@ class Index
return ''; return '';
} }
$config = [ $config = [
'class' => 'fecshop\app\apphtml5\widgets\Page', 'class' => 'fecshop\app\appfront\widgets\Page',
'view' => 'widgets/page.php', 'view' => 'widgets/page.php',
'pageNum' => $this->pageNum, 'pageNum' => $this->pageNum,
'numPerPage' => $this->numPerPage, 'numPerPage' => $this->numPerPage,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册