New.php 1.63 KB
<?php

namespace Product;

use LibModels\Web\Product\SearchData;
use WebPlugin\HelperSearch;
use Product\SearchModel;
use Api\Yohobuy;
use Configs\WebCacheConfig;
use WebPlugin\Cache;
use Index\HomeModel;

/**
 * sale首页模板数据模型
 *
 */
class NewModel 
{
    /**
     * 搜索新品到着首页数据
     * @param $customCondition array(
     *      'new' => (string)Y (只展示新品)
     * )
     * @param $customOptions array(
     *      'reviewNum'  => int (底部浏览记录显示个数)
     *      'controller' => string (说明当前控制器名)
     *      'action' => string (说明当前方法名)
     * )   排序条件
     * @return array()  (处理后的list首页数据)
     */
    public static function getNewSearchData($customCondition, $customOptions) 
    {
        $urlList = array();
        $searchCondition = SearchModel::searchCondition($customCondition, $customOptions);

        // 组合搜索商品url
        $urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
        // 组合搜索分类url
        $sortCondition = array();
        if (isset($searchCondition['condition']['misort']) && !empty($searchCondition['condition']['misort'])) {
            $sortCondition['needSmallSort'] = 1;
        }
        $urlList['sort'] = SearchData::getClassesUrl($sortCondition);
        // 组合搜索最新上架url
        $urlList['recent'] = SearchData::getRecentShelveUrl();

        $data = Yohobuy::getMulti($urlList);

        // 组织模板数据
        $result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']);

        return $result;
    }
    
}