品牌
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user