简体   繁体   中英

Php - Get Current Price of amazon products using Amazon API

I've successfully implemented amazon product search using the code given in:

I don't get prices with Amazon Product Advertising API .

Now I'm trying to fetch the current price of a product from Amazon. I got only the retail price.

For example, when I try to fetch the prices of the product: http://www.amazon.com/gp/product/0743273567/ref=ox_sc_act_title_1?ie=UTF8&psc=1&smid=ATVPDKIKX0DER using amazon API, I got the following values:

ListPrice] => Array
                    (
                        [0] => Array
                            (
                                [Amount] => 1500
                                [CurrencyCode] => USD
                                [FormattedPrice] => $15.00
                            )

                    )
....

[OfferSummary] => Array
    (
        [0] => Array
            (
                [LowestNewPrice] => Array
                    (
                        [0] => Array
                            (
                                [Amount] => 343
                                [CurrencyCode] => USD
                                [FormattedPrice] => $3.43
                            )

                    )

                [LowestUsedPrice] => Array
                    (
                        [0] => Array
                            (
                                [Amount] => 250
                                [CurrencyCode] => USD
                                [FormattedPrice] => $2.50
                            )

                    )

                [LowestCollectiblePrice] => Array
                    (
                        [0] => Array
                            (
                                [Amount] => 995
                                [CurrencyCode] => USD
                                [FormattedPrice] => $9.95
                            )

                    )
.....

[OfferListing] => Array
                                    (
                                        [0] => Array
                                            (
                                                [OfferListingId] => nmbRKFxxDoRqoOL8kMzXNMkb9X2XWMB44HkNuwC49%2F8Yfcc96dCsb3rHWjDaIQT9fWHO%2BUGNIXWaBug5raFqChfsnCsdiGqPu4F7x0PZSPByUJd5zQ%2BM0%2FuuINUX917HJRDhHGwa9HTfCSlqfJlAB5V62ZgCa%2FmY
                                                [Price] => Array
                                                    (
                                                        [0] => Array
                                                            (
                                                                [Amount] => 343
                                                                [CurrencyCode] => USD
                                                                [FormattedPrice] => $3.43
                                                            )

                                                    )

                                                [AmountSaved] => Array
                                                    (
                                                        [0] => Array
                                                            (
                                                                [Amount] => 1157
                                                                [CurrencyCode] => USD
                                                                [FormattedPrice] => $11.57
                                                            )

                                                    )

                                                [PercentageSaved] => 77 .....

The retail price : $15.00 can be seen in the ListPrice parameter, but I couldn't find the current price : $7.70 anywhere in the api response.

I've also tried the various ResponseGroups like: Offers, OfferFull, Large, Medium etc.

Please help me. Thanks in Advance !

This might be a little bit late but to get the current price , you need to include Offers Responsegroup , and then get the current price from this node

$price = htmlentities((string) $item->Offers->Offer->OfferListing->Price->Amount);

as the XML actually looks like this

<Item> 
  <ASIN>B00KOKTZLQ</ASIN> 
  <OfferSummary> 
    <LowestNewPrice> 
      <Amount>3998</Amount> 
      <CurrencyCode>USD</CurrencyCode> 
      <FormattedPrice>$39.98</FormattedPrice> 
    </LowestNewPrice>  
    <TotalNew>4</TotalNew> 
    <TotalUsed>0</TotalUsed> 
    <TotalCollectible>0</TotalCollectible> 
    <TotalRefurbished>0</TotalRefurbished> 
  </OfferSummary> 
  <Offers> 
    <TotalOffers>1</TotalOffers> 
    <TotalOfferPages>1</TotalOfferPages> 
    <MoreOffersUrl>
    https://www.amazon.com/gp/offer-listing/B00KOKTZLQ/?&AWSAccessKeyId=[Your_AWSAccessKeyID]&ie=UTF8&tag=[Your_AssociateTag]%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB00KOKTZLQ
    </MoreOffersUrl> 
    <Offer> 
      <OfferAttributes> 
        <Condition>New</Condition> 
      </OfferAttributes> 
      <OfferListing> 
        <OfferListingId>  
         LYcccWDl3oNWXKkngMuydLjjKXsOR4AO2tGTdMW%2BNOA%2F%2FV61ektF%2FstkahL39vySB75wmcQJ7lsWOW3NAjVZpwgnQnxZE62sf%2B34NWSBuAzkkR7lCjtGLXn0aFfQ5KAGmNFYzScqWHSecKmnMA%2BuBA%3D%3D 
        </OfferListingId> 
        <Price>  
          <Amount>6000</Amount>  
          <CurrencyCode>USD</CurrencyCode>  
          <FormattedPrice>$60.00</FormattedPrice> 
        </Price> 
        <SalePrice>
            <Amount>4495</Amount>
            <CurrencyCode>USD</CurrencyCode>
            <FormattedPrice>$44.95</FormattedPrice>
        </SalePrice>
        <AmountSaved>
            <Amount>1505</Amount>
            <CurrencyCode>USD</CurrencyCode>
            <FormattedPrice>$15.05</FormattedPrice>
        </AmountSaved>
        <PercentageSaved>25</PercentageSaved>
        <Availability>Usually ships in 1-2 business days</Availability> 
        <AvailabilityAttributes>  
          <AvailabilityType>now</AvailabilityType>  
          <MinimumHours>24</MinimumHours>  
          <MaximumHours>48</MaximumHours> 
        </AvailabilityAttributes> 
        <IsEligibleForSuperSaverShipping>0</IsEligibleForSuperSaverShipping>
        <IsEligibleForPrime>0</IsEligibleForPrime>
      </OfferListing> 
    </Offer> 
  </Offers>
</Item>

From amazon docs , it suggests that Operation=ItemLookup return the product data and from that response you have <LowestNewPrice><Amount> tag which gives you latest price of requested item. So please refer that document provided by amazon.

Hope this helps you.

Thanks!

You can easily get the price with response group like : responseGroup('Medium,OfferSummary,VariationSummary')

The key : VariationSummary has the object where you can find:

  • LowestPrice
  • HighestPrice
  • LowestSalePrice
  • HighestSalePrice

Note that you may not get all above price params in variationSummery object so make the check accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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