简体   繁体   English

如何仅为Amazon商人ID检索Amazon API产品价格

[英]How to retrieve the amazon api product price only for amazon merchantID

Here is my code, but it returns the lowest price from third party seller, what I'm doing wrong ? 这是我的代码,但是它从第三方卖家处返回了最低价格,我在做什么错呢? I'm using response group Offers as it seems it's the way to get results according to documentation. 我使用的是响应组“优惠”,因为这似乎是根据文档获得结果的方法。

function getAmazonPrice($region, $asin) {

    $xml = aws_signed_request($region, array(
        "Operation" => "ItemLookup",
        "ItemId" => $asin,
        "IncludeReviewsSummary" => False,
        "ResponseGroup" => "Medium, Offers",
        "MerchantId" => "Amazon",
    ));

    $item = $xml->Items->Item;
    $title = htmlentities((string) $item->ItemAttributes->Title);
    $url = htmlentities((string) $item->DetailPageURL);
    $image = htmlentities((string) $item->MediumImage->URL);
    $price = htmlentities((string) $item->OfferSummary->LowestNewPrice->Amount);
    $code = htmlentities((string) $item->OfferSummary->LowestNewPrice->CurrencyCode);
    $qty = htmlentities((string) $item->OfferSummary->TotalNew);

    if ($qty !== "0") {
        $response = array(
            "code" => $code,
            "price" => number_format((float) ($price / 100), 2, '.', ''),
            "image" => $image,
            "url" => $url,
            "title" => $title
        );
    }

    return $response;
}

I am having the same issue. 我有同样的问题。

What I did is assuming when AMAZON offers a discount, it is in SalePrice: 我所做的是假设当AMAZON提供折扣时,它在SalePrice中:

$SalePrice=$xmlProduct->Items->Item->Offers->Offer->OfferListing->SalePrice->Amount; $ SalePrice = $ xmlProduct->项 - >用品 - >优惠 - >优惠 - > OfferListing-> SalePrice->量;

if that node doesnt exist, then there is no discount, just use the Listing Price: $xmlProduct->Items->Item->Offers->Offer->OfferListing->Price->Amount 如果该节点不存在,则没有折扣,只需使用标价:$ xmlProduct-> Items-> Item-> Offers-> Offer-> OfferListing-> Price-> Amount

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM