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']];