亚马逊MWS阅读库存现货腓(Amazon MWS Read Inventory Stock Php)

2019-10-16 23:36发布

我试图让一个产品的可用库存的SKU。 我搜索它,很多发现了一些他们的PDF文件不适合我。 我坚持抓我的头做什么,任何人都可以帮助我,我会更然后感谢。 我也试过这个代码,

$skus = new FBAInventoryServiceMWS_Model_SellerSkuList();
$skus->setmember( 'sku-111' );

invokeListInventorySupply($service, $request->withSellerSkus( $skus ) );

但它返回的InStockSupplyQuantity为0,你可以在此上看到链接

这是我使用的代码的完整版本,

<?php

include_once ('.config.inc.php'); 

$config = array (
  'ServiceURL' => MWS_ENDPOINT_URL,
  'ProxyHost' => null,
  'ProxyPort' => -1,
  'MaxErrorRetry' => 3
);

 $service = new FBAInventoryServiceMWS_Client(
     ACCESS_KEY_ID, 
     SECRET_ACCESS_KEY, 
     $config,
     APPLICATION_NAME,
     APPLICATION_VERSION);

 $request = new FBAInventoryServiceMWS_Model_ListInventorySupplyRequest();
  $request->setSellerId(SELLER_ID);

    $skus = new FBAInventoryServiceMWS_Model_SellerSkuList();
    $skus->setmember( 'sku-111' );

  invokeListInventorySupply($service, $request->withSellerSkus( $skus ) );

  function invokeListInventorySupply(FBAInventoryServiceMWS_Interface $service, $request) 
  {
      try {
              $response = $service->listInventorySupply($request);

                echo ("Service Response<br />");
                echo ("=============================================================================<br />");

                echo("        ListInventorySupplyResponse<br />");
                if ($response->isSetListInventorySupplyResult()) { 
                    echo("            ListInventorySupplyResult<br />");
                    $listInventorySupplyResult = $response->getListInventorySupplyResult();
                    if ($listInventorySupplyResult->isSetInventorySupplyList()) { 
                        echo("                InventorySupplyList<br />");
                        $inventorySupplyList = $listInventorySupplyResult->getInventorySupplyList();
                        $memberList = $inventorySupplyList->getmember();
                        foreach ($memberList as $member) {
                            echo("                    member<br />");
                            echo ("=============================================================================<br />");
                            if ($member->isSetSellerSKU()) 
                            {
                                echo("                        SellerSKU<br />");
                                echo("                            " . $member->getSellerSKU() . "<br /><br />");
                            }
                            if ($member->isSetFNSKU()) 
                            {
                                echo("                        FNSKU<br />");
                                echo("                            " . $member->getFNSKU() . "<br /><br />");
                            }
                            if ($member->isSetASIN()) 
                            {
                                echo("                        ASIN<br />");
                                echo("                            " . $member->getASIN() . "<br /><br />");
                            }
                            if ($member->isSetCondition()) 
                            {
                                echo("                        Condition<br />");
                                echo("                            " . $member->getCondition() . "<br /><br />");
                            }
                            if ($member->isSetTotalSupplyQuantity()) 
                            {
                                echo("                        TotalSupplyQuantity<br />");
                                echo("                            " . $member->getTotalSupplyQuantity() . "<br /><br />");
                            }
                            if ($member->isSetInStockSupplyQuantity()) 
                            {
                                echo("                        InStockSupplyQuantity<br />");
                                echo("                            " . $member->getInStockSupplyQuantity() . "<br /><br />");
                            }
                            if ($member->isSetEarliestAvailability()) { 
                                echo("                        EarliestAvailability<br />");
                                $earliestAvailability = $member->getEarliestAvailability();
                                if ($earliestAvailability->isSetTimepointType()) 
                                {
                                    echo("                            TimepointType<br />");
                                    echo("                                " . $earliestAvailability->getTimepointType() . "<br /><br />");
                                }
                                if ($earliestAvailability->isSetDateTime()) 
                                {
                                    echo("                            DateTime<br />");
                                    echo("                                " . $earliestAvailability->getDateTime() . "<br /><br />");
                                }
                            } 
                            if ($member->isSetSupplyDetail()) { 
                                echo("                        SupplyDetail<br />");
                                $supplyDetail = $member->getSupplyDetail();
                                $member1List = $supplyDetail->getmember();
                                foreach ($member1List as $member1) {
                                    echo("                            member<br />");
                                    if ($member1->isSetQuantity()) 
                                    {
                                        echo("                                Quantity<br />");
                                        echo("                                    " . $member1->getQuantity() . "<br /><br />");
                                    }
                                    if ($member1->isSetSupplyType()) 
                                    {
                                        echo("                                SupplyType<br />");
                                        echo("                                    " . $member1->getSupplyType() . "<br /><br />");
                                    }
                                    if ($member1->isSetEarliestAvailableToPick()) { 
                                        echo("                                EarliestAvailableToPick<br />");
                                        $earliestAvailableToPick = $member1->getEarliestAvailableToPick();
                                        if ($earliestAvailableToPick->isSetTimepointType()) 
                                        {
                                            echo("                                    TimepointType<br />");
                                            echo("                                        " . $earliestAvailableToPick->getTimepointType() . "<br /><br />");
                                        }
                                        if ($earliestAvailableToPick->isSetDateTime()) 
                                        {
                                            echo("                                    DateTime<br />");
                                            echo("                                        " . $earliestAvailableToPick->getDateTime() . "<br /><br />");
                                        }
                                    } 
                                    if ($member1->isSetLatestAvailableToPick()) { 
                                        echo("                                LatestAvailableToPick<br />");
                                        $latestAvailableToPick = $member1->getLatestAvailableToPick();
                                        if ($latestAvailableToPick->isSetTimepointType()) 
                                        {
                                            echo("                                    TimepointType<br />");
                                            echo("                                        " . $latestAvailableToPick->getTimepointType() . "<br /><br />");
                                        }
                                        if ($latestAvailableToPick->isSetDateTime()) 
                                        {
                                            echo("                                    DateTime<br />");
                                            echo("                                        " . $latestAvailableToPick->getDateTime() . "<br /><br />");
                                        }
                                    } 
                                }
                            } 
                        }
                    } 
                    if ($listInventorySupplyResult->isSetNextToken()) 
                    {
                        echo("                NextToken<br />");
                        echo("                    " . $listInventorySupplyResult->getNextToken() . "<br /><br />");
                    }
                } 
                if ($response->isSetResponseMetadata()) { 
                    echo("            ResponseMetadata<br />");
                    $responseMetadata = $response->getResponseMetadata();
                    if ($responseMetadata->isSetRequestId()) 
                    {
                        echo("                RequestId<br />");
                        echo("                    " . $responseMetadata->getRequestId() . "<br /><br />");
                    }
                } 

     } catch (FBAInventoryServiceMWS_Exception $ex) {
         echo("Caught Exception: " . $ex->getMessage() . "<br /><br />");
         echo("Response Status Code: " . $ex->getStatusCode() . "<br /><br />");
         echo("Error Code: " . $ex->getErrorCode() . "<br /><br />");
         echo("Error Type: " . $ex->getErrorType() . "<br /><br />");
         echo("Request ID: " . $ex->getRequestId() . "<br /><br />");
         echo("XML: " . $ex->getXML() . "<br /><br />");
     }
 }

Answer 1:

此代码工作正常,我:

...
$skus= new FBAInventoryServiceMWS_Model_SellerSkuList();
$skus->setmember("??-????-????"); // Your SKU
$request = new FBAInventoryServiceMWS_Model_ListInventorySupplyRequest();
$request->setSellerId(SELLER_ID);
$request->setMarketplace(MARKETPLACE_ID);
$request->setSellerSkus($skus);
invokeListInventorySupply($service, $request);
...

我完整的代码是基于文件\src\FBAInventoryServiceMWS\Samples\ListInventorySupplySample.php从PHP客户端库v20101001其中上面的代码替换线71。

输出看起来像:



Answer 2:

- 编辑 -

在于PHP和我都不是最好的朋友,我要套用需要确保你可以得到你想要的数据的步骤:

  1. 建立与ListInventorySupply您的要求
  2. 抓取您的响应通过查看下面的XML,并确保你正确地调用对象的寻找:

     <?xml version="1.0"?> <ListInventorySupplyResponse xmlns="http://mws.amazonaws.com/FulfillmentInventory/2010-10-01"> <ListInventorySupplyResult> <InventorySupplyList> <member> <SellerSKU>SampleSKU1</SellerSKU> <ASIN>B00000K3CQ</ASIN> <TotalSupplyQuantity>20</TotalSupplyQuantity> <FNSKU>X0000000FM</FNSKU> <Condition>NewItem</Condition> <SupplyDetail/> <InStockSupplyQuantity>15</InStockSupplyQuantity> <EarliestAvailability> <TimepointType>Immediately</TimepointType> </EarliestAvailability> .... 
  3. 在C#中的每个效应初探可通过一组对象,例如:

     submitFeedResponse.SubmitFeedResult.FeedSubmissionInfo.FeedType 

    要么

     submitFeedResponse.ResponseMetadata.RequestId 

我已经找到了我的大部分响应无效一直没有合适的对象,结果被调用,或者如果我做了正确的对象,我没有正确显示它(不要求如的toString())。

在另一方面,你正在返回您的SKU的名字,所以你确保你正在使用的SKU应该通过卖家中心将返回一个实际的数量是多少?

另外一些优秀的支持,请访问:

https://sellercentral.amazon.com/forums/forum.jspa?forumID=35



文章来源: Amazon MWS Read Inventory Stock Php