Files
shoplix/tmp/merge-nylon-brush-wheel.ps1
T
2026-11-30 21:43:02 +08:00

60 lines
3.8 KiB
PowerShell

# 合并尼龙刷轮的三个套件型号,并删除重复产品记录。
$login = @{ username = 'admin'; password = 'Shoplix@2026' } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/auth/login' -ContentType 'application/json' -Body $login -SessionVariable adminSession | Out-Null
$productContent = @'
<h2>Nylon Brush Wheel Kit Overview</h2>
<p>This nylon brush wheel kit is available with three adapter and fixing kit options: HY-047, HY-048 and HY-049. It is designed for garden maintenance, brush cutter accessory sourcing and replacement-part distribution.</p>
<h2>Available Kit Options</h2>
<ul><li><strong>HY-047:</strong> Nylon brush wheel with 8-piece adapter kit.</li><li><strong>HY-048:</strong> Nylon brush wheel with 4-piece fixing kit.</li><li><strong>HY-049:</strong> Nylon brush wheel with Stihl-style 4-piece kit.</li></ul>
<h2>Ordering Information</h2>
<p>Please confirm the required kit option, machine compatibility, mounting dimensions, quantity, packaging and branding requirements before ordering. OEM and wholesale inquiries are welcome.</p>
'@
$saveBody = @{
productCode = 'PRD0089E12MHRYF4'
siteCode = 'SIT0000000000001'
primaryCategoryCode = 'PCT0089DGXVJZDVK'
productName = 'Nylon Brush Wheel Kit'
slug = 'nylon-brush-wheel-kit'
model = 'HY-047 / HY-048 / HY-049'
summary = 'Nylon brush wheel supplied with three adapter and fixing kit options for garden maintenance and brush cutter accessory sourcing.'
productContent = $productContent
contentTemplateCode = ''
templatePosition = 'AFTER'
coverMediaCode = 'MED0089DZO2RZW1S'
images = @(
@{ mediaCode = 'MED0089DZO2RZW1S'; sortNo = 0 },
@{ mediaCode = 'MED0089DZO5MDQ80'; sortNo = 1 },
@{ mediaCode = 'MED0089DZO8EW54W'; sortNo = 2 }
)
featured = $false
inquiryEnabled = $true
sortNo = 47
status = 'PUBLISHED'
attributes = @(
@{ attributeCode = 'PAT0083ZKZ1VM3UO'; attributeName = 'Model'; value = 'HY-047 / HY-048 / HY-049'; unit = ''; sortNo = 1 },
@{ attributeCode = 'PAT0089C84SCSJY8'; attributeName = 'Product Type'; value = 'Nylon Brush Wheel Kit'; unit = ''; sortNo = 2 },
@{ attributeCode = 'PAT0089C84W1RNCW'; attributeName = 'Color'; value = 'Orange'; unit = ''; sortNo = 3 },
@{ attributeCode = 'PAT0083ZKZ1XHJ40'; attributeName = 'Material'; value = 'Nylon / Metal'; unit = ''; sortNo = 4 },
@{ attributeCode = $null; attributeName = 'Kit Options'; value = '8-Piece Adapter Kit; 4-Piece Fixing Kit; Stihl-Style 4-Piece Kit'; unit = ''; sortNo = 5 }
)
specifications = @(
@{ groupName = 'Kit Options'; name = 'HY-047'; value = '8-Piece Adapter Kit'; unit = ''; sortNo = 1 },
@{ groupName = 'Kit Options'; name = 'HY-048'; value = '4-Piece Fixing Kit'; unit = ''; sortNo = 2 },
@{ groupName = 'Kit Options'; name = 'HY-049'; value = 'Stihl-Style 4-Piece Kit'; unit = ''; sortNo = 3 },
@{ groupName = 'Material'; name = 'Primary Material'; value = 'Nylon / Metal'; unit = ''; sortNo = 4 },
@{ groupName = 'Appearance'; name = 'Color'; value = 'Orange'; unit = ''; sortNo = 5 }
)
} | ConvertTo-Json -Depth 10
$saved = Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/products/save' -ContentType 'application/json' -Body $saveBody -WebSession $adminSession
if ($saved.productCode -ne 'PRD0089E12MHRYF4') {
throw '合并后的产品保存失败,未删除原产品。'
}
foreach ($productCode in @('PRD0089E13JUANLS', 'PRD0089E14JAZ9C0')) {
$deleteBody = @{ siteCode = 'SIT0000000000001'; productCode = $productCode } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri 'http://localhost:8081/api/admin/v1/products/delete' -ContentType 'application/json' -Body $deleteBody -WebSession $adminSession | Out-Null
}
Write-Output $saved.productCode