Authored by 周少峰

shop tags

... ... @@ -16,12 +16,12 @@ class ListProcess
* @param $data
* @return array 处理之后的商品数据
*/
public static function getListData($data, $returnFilter = true)
public static function getListData($data, $returnFilter = true, $showTag = true, $tagNew = true, $tagSale = true)
{
$result = array();
if (isset($data['product_list'])) {
$result['new'] = self::getProductData($data['product_list']);
$result['new'] = self::getProductData($data['product_list'], $showTag, $tagNew, $tagSale);
}
if ($returnFilter && isset($data['filter'])) {
$result['filter'] = self::getFilterData($data['filter']);
... ...
... ... @@ -291,7 +291,15 @@ class SearchController extends AbstractAction
$type = $this->get('type', '');
$order = $this->get('order', 0);
$condition['order'] = Helpers::transOrder($order, $type);
//标签显示控制
$showTag = $this->get('showTag', 0);
$showTag = $showTag === 0 ? true : false;
//显示标签new
$tagNew = $this->get('newTag', 0);
$tagNew = $tagNew === 0 ? true : false;
//显示标签sale
$tagSale = $this->get('saleTag', 0);
$tagSale = $tagSale === 0 ? true : false;
// 过滤掉值为空的条件
$condition = array_filter($condition);
... ... @@ -311,7 +319,7 @@ class SearchController extends AbstractAction
// /* 精确搜索品类 */
// $data = Product\ListModel::getClassData($condition);
$data = Product\SearchModel::getSearchData($condition);
$data = Product\SearchModel::getSearchData($condition, $showTag, $tagNew, $tagSale);
} while (false);
if (empty($data['new'])) {
... ...
... ... @@ -26,7 +26,7 @@ class SearchModel
* @param array $condition 查询条件
* @return array
*/
public static function getSearchData($condition)
public static function getSearchData($condition, $showTag = true, $tagNew = true, $tagSale = true)
{
$result = array();
... ... @@ -48,7 +48,7 @@ class SearchModel
// $listData = SearchData::searchByCondition($condition);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$result = ListProcess::getListData($listData['data'], false);
$result = ListProcess::getListData($listData['data'], false, $showTag, $tagNew, $tagSale);
}
if (USE_CACHE) {
... ...