diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index 34acca66..94af352a 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -129,7 +129,7 @@ class SpuRepository extends BaseRepository * @author Qinii * @day 12/18/20 */ - public function getApiSearch($where, $page, $limit, $userInfo = null) + public function getApiSearch($where, $page, $limit, $userInfo = null,$is_sku=false) { if (isset($where['keyword']) && !empty($where['keyword'])) { if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) { @@ -154,7 +154,13 @@ class SpuRepository extends BaseRepository ]); $productMake = app()->make(ProductRepository::class); $count = $query->fetchSql(false)->count(); - $list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select(); + $list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select() + ->each(function ($item) use ($is_sku,$productMake,$userInfo) { + if($is_sku==true){ + $sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo); + $item['sku']=$sku; + } + }); $append = ['stop_time','svip_price','show_svip_info','is_svip_price']; if ($productMake->getUserIsPromoter($userInfo)) $append[] = 'max_extension'; diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 7610742c..b1d8592e 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -149,14 +149,13 @@ class CloudWarehouse extends BaseController if (empty($merchantIds)) { return app('json')->success(['count' => 0, 'list' => []]); } - $where['entry_mer_id'] = 0; $where['keyword'] = $params['keyword']; $where['mer_ids'] = $merchantIds; $where['product_type'] = $params['product_type']; $where['is_gift_bag'] = 0; $where['order'] = $params['order'] ?: 'sort'; - $products = $this->spuRepository->getApiSearch($where, $page, $limit, false); + $products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true); return app('json')->success($products); } }