From bee914640958d4cf0a2f4b2e8769e7d2f5101ac3 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 11 Mar 2026 13:59:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/WordpressSiteService.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/common/service/WordpressSiteService.php b/app/common/service/WordpressSiteService.php index d85ede6..89a2861 100644 --- a/app/common/service/WordpressSiteService.php +++ b/app/common/service/WordpressSiteService.php @@ -1108,6 +1108,14 @@ class WordpressSiteService // 设置产品分类使用 product_cat 字段) $data['product_cat'] = [15, 16]; + // 处理品牌:翻译并获取/创建品牌ID + $brand = $car->crawl_brand ?: $car->product_name; + $brandEnglish = $this->translateIfNeeded($brand, '英文'); + $brandId = $this->get_or_create_brand_id($site, $domain, $brandEnglish); + if ($brandId) { + $data['pa_brand'] = [$brandId]; + } + // 设置主图和车辆相册(ACF字段) if (!empty($uploadedImages)) { $allImageIds = array_map(function($img) { @@ -1134,7 +1142,9 @@ class WordpressSiteService 'source_place' => '车源地', 'price' => '价格', ]; - + if (str_contains($car->mileage, '万') || str_contains($car->mileage, '万公里')) { + $car->mileage = str_replace(['万', '公里', '万公里'],'',$car->mileage)*10000; + } foreach ($fieldMap as $acfKey => $label) { if (!empty($car->$acfKey)) { $value = $car->$acfKey; @@ -1143,8 +1153,6 @@ class WordpressSiteService $value = $this->translateColorToEnglish($value); } elseif ($acfKey === 'source_place' && $this->containsChinese($value)) { $value = $this->translateIfNeeded($value, '英文'); - } elseif ($acfKey === 'Mileage' && $acfKey) { - $value = $this->translateIfNeeded($value, '英文'); } $data['acf'][$acfKey] = $value; }