From adccc4d1309744170c24dcde991e406127546a26 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Mon, 26 Jun 2023 11:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=BA=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/services/product/product/StoreProductServices.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crmeb/app/services/product/product/StoreProductServices.php b/crmeb/app/services/product/product/StoreProductServices.php index 0ac022ee6..44f6f180e 100644 --- a/crmeb/app/services/product/product/StoreProductServices.php +++ b/crmeb/app/services/product/product/StoreProductServices.php @@ -127,6 +127,9 @@ class StoreProductServices extends BaseServices /** @var StoreCategoryServices $categoryService */ $categoryService = app()->make(StoreCategoryServices::class); $cateList = $categoryService->getCateParentAndChildName($cateIds); + $preantCateList = $categoryService->getColumn([ + ['id', 'in', $cateIds] + ], 'cate_name', 'id'); foreach ($list as &$item) { $cateName = array_filter($cateList, function ($val) use ($item) { if (in_array($val['id'], explode(',', $item['cate_id']))) { @@ -137,6 +140,9 @@ class StoreProductServices extends BaseServices foreach ($cateName as $k => $v) { $item['cate_name'][] = $v['one'] . '/' . $v['two']; } + if (!count($item['cate_name']) && isset($preantCateList[$item['cate_id']])) { + $item['cate_name'][] = $preantCateList[$item['cate_id']]; + } $item['cate_name'] = is_array($item['cate_name']) ? implode(',', $item['cate_name']) : ''; $item['stock_attr'] = $item['stock'] > 0;//库存 $item['product_type'] = $this->productType[$item['virtual_type']];