簡體   English   中英

Shopware 6 產品 API 不設置購買價格

[英]Shopware 6 Product API doesnt set the buying price

在 Shopware 6 中,我仍然嘗試使用 API 將產品導入系統。
我現在得到了一個產品,但它沒有價格,盡管我插入了它。
這實際上導致產品沒有價格並阻止后端加載產品,因此我必須使用導出、編輯然后導入方法手動更改價格。
在將產品對象作為請求發送到 API 之前,產品對象也會使用 json_encode 進行編碼。

我似乎無法找出我的以下代碼有什么問題:

$price = [
    "currencyId" => "b7d2554b0ce847cd82f3ac9bd1c0dfca",
    "net" => $net,
    "gross" => $gross,
    "linked" => false
];
$price = json_encode($price);
$product = [
    "id" => str_replace("-","", $productId),
    "productId" => str_replace("-","", $productId),
    "name" => $name,
    "taxId" => $taxId,
    "productNumber" => $productNumber,
    "minPurchase" => $minPurchase,
    "price" => $price,
    "purchasePrice" => $purchasePrice,
    "stock" => $stock,
    "images" => $images,
    "atributes" => $atributes,
    "categoryId" => "7997459a37f94a75a14d7cbd872a926f"
];

我不得不寫這樣的代碼:

$product = [
    "id" => str_replace("-","", $productId),
    "productId" => str_replace("-","", $productId),
    "parentId" =>str_replace("-","", "4307a3d9afee4b46b3da1a8fc6230db5"),
        "name" => $name,
        "taxId" => $taxId,
        "productNumber" => $productNumber,
        "minPurchase" => $minPurchase,
        "price" => [[
            "currencyId" => "b7d2554b0ce847cd82f3ac9bd1c0dfca",
            "net" => $net,
            "gross" => $price,
            "linked" => true
        ]],
        "purchasePrice" => $purchasePrice,
        "stock" => $stock,
        "description" => $description,
        "images" => $images,
        "atributes" => $atributes,
        "categoryId" => "7997459a37f94a75a14d7cbd872a926f"
];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM