Why is ItemLookup not returning any price information even when requesting all 3 offer groups?

試著忘記壹切 提交于 2019-12-03 11:32:43

Edit:

An item returned by the Amazon Product API can represent either a single variation item (a single size and/or a single color) or a variation parent. When a single variation item is returned, you just have to use the same approach as you initially did and you'll be able to fetch the price.

A parent variation item (your case), however, is not associated with any offer (price), because it is an abstraction of a product and acts as a container for the existing product variations (different sizes, colors).

In this case, every variation contained within the variation parent has its own price and you can simply iterate through the set of variations and fetch the price you need.

Adding the Variations response group to your search/look up request is crucial, so don't omit it.

The request body:

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
   <env:Header/>
   <env:Body>
       <ns1:ItemLookup xmlns='http://webservices.amazon.com/AWSECommerceService/2011-08-01' xmlns:ns1='http://webservices.amazon.com/AWSECommerceService/2011-08-01'>
           <AWSAccessKeyId>xxxxxxxxxxxxxxxxxxx</AWSAccessKeyId>
           <AssociateTag>xxxxxxxx</AssociateTag>
           <Request>
               <IdType>ASIN</IdType>
               <MerchantId>All</MerchantId>
               <ItemId>B008M4TB9C</ItemId>
               <ResponseGroup>Variations</ResponseGroup>
           </Request>
           <Signature>xxxxxxxx</Signature>
           <Timestamp>2012-12-13T23:49:27Z</Timestamp>
       </ns1:ItemLookup>
   </env:Body>
</env:Envelope>

The response body.

A price for a single variation can be found under:

Item->Variations->Item->Offer->OfferListing->Price.

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
    <env:Body>
       <ItemLookupResponse xmlns='http://webservices.amazon.com/AWSECommerceService/2011-08-01'>
         <OperationRequest>
           <HTTPHeaders>
             <Header Name='UserAgent' Value='JBossRemoting - 2.5.1 (Flounder)'/>
           </HTTPHeaders>
           <RequestId>05c3ecdd-60ae-4a87-8bcb-70f80a5f5d5b</RequestId>
           <Arguments>
             <Argument Name='Service' Value='AWSECommerceService'/>
           </Arguments>
           <RequestProcessingTime>0.1092920000000000</RequestProcessingTime>
         </OperationRequest>
         <Items>
           <Request>
            <IsValid>True</IsValid>
            <ItemLookupRequest>
              <IdType>ASIN</IdType>
              <MerchantId>Deprecated</MerchantId>
              <ItemId>B008M4TB9C</ItemId>
              <ResponseGroup>Variations</ResponseGroup>
              <VariationPage>All</VariationPage>
            </ItemLookupRequest>
          </Request>
          <Item>
            <ASIN>B008M4TB9C</ASIN>
            <ParentASIN>B008M4TB9C</ParentASIN>  
            <VariationSummary>
              <LowestPrice>
                <Amount>49500</Amount>
                <CurrencyCode>USD</CurrencyCode>
                <FormattedPrice>$495.00</FormattedPrice>
              </LowestPrice>
              <HighestPrice>
                <Amount>49500</Amount>
                <CurrencyCode>USD</CurrencyCode>
                <FormattedPrice>$495.00</FormattedPrice>
              </HighestPrice>
            </VariationSummary>  
            <Variations>
                  ...
              <Item>
                <ASIN>B007HQYIBW</ASIN>
                <ParentASIN>B008M4TB9C</ParentASIN>
                   ...
                <ImageSets>
                   ...
                </ImageSets>
                <ItemAttributes>
                    ....
                </ItemAttributes>
                <VariationAttributes>
                  <VariationAttribute>
                    <Name>Color</Name>
                    <Value>Black</Value>
                  </VariationAttribute>
                  <VariationAttribute>
                    <Name>Size</Name>
                    <Value>6 B(M) US</Value>
                  </VariationAttribute>
                </VariationAttributes>
                <Offers>
                  <Offer>
                    <Merchant>
                      <Name>Amazon.com</Name>
                    </Merchant>
                    <OfferAttributes>
                     <Condition>New</Condition>
                    </OfferAttributes>
                    <OfferListing>
                      <OfferListingId>xxxxxxxxxx</OfferListingId>
                      <Price>
                        <Amount>49500</Amount>
                        <CurrencyCode>USD</CurrencyCode>
                        <FormattedPrice>$495.00</FormattedPrice>
                      </Price>
                      <Availability>Usually ships in 24 hours</Availability>
                      <AvailabilityAttributes>
                       <AvailabilityType>now</AvailabilityType>
                       <MinimumHours>0</MinimumHours>
                       <MaximumHours>0</MaximumHours>
                      </AvailabilityAttributes>
                    <IsEligibleForSuperSaverShipping>1</IsEligibleForSuperSaverShipping>
                    </OfferListing>
                  </Offer>
                </Offers>
              </Item>
          </Variations>
        </Item>
         ...
       </Items>
      </ItemLookupResponse>
     </env:Body>
   </env:Envelope>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!