function invokeListInventorySupplyByNextToken(FBAInventoryServiceMWS_Interface $service, $request)
{
    try {
        $response = $service->listInventorySupplyByNextToken($request);
        if ($response->isSetListInventorySupplyByNextTokenResult()) {
            $listInventorySupplyByNextTokenResult = $response->getListInventorySupplyByNextTokenResult();
            if ($listInventorySupplyByNextTokenResult->isSetInventorySupplyList()) {
                $inventorySupplyList = $listInventorySupplyByNextTokenResult->getInventorySupplyList();
                $memberList = $inventorySupplyList->getmember();
                $countResult = count($memberList);
                $level = "Neutral";
                $category = "Inventory";
                $title = "Update Inventory (Next Token)";
                if ($listInventorySupplyByNextTokenResult->isSetNextToken()) {
                    $info = $countResult . " Products Retrieved, Getting more with next token...";
                } else {
                    $info = $countResult . " Products Retrieved.";
                }
                AmzFBA_Woo_Log($level, $category, $title, $info);
                foreach ($memberList as $member) {
                    $inventory_level = $member->getInStockSupplyQuantity();
                    $sku = $member->getSellerSKU();
                    AmzFBA_Woo_install_data($sku, $inventory_level);
                    $ProductID = GetIdFromSKU($sku);
                    if ($ProductID != '') {
                        // Sharad: adding logs
                        AmzFBA_Woo_Log($level, $category, $title, "New level for [" . $sku . "] is " . $inventory_level);
                        wc_update_product_stock($ProductID, $inventory_level);
                    }
                }
            }
            if ($listInventorySupplyByNextTokenResult->isSetNextToken()) {
                $NextToken = $listInventorySupplyByNextTokenResult->getNextToken();
                ListInventorySupplyByNextToken($NextToken);
            }
        }
    } catch (FBAInventoryServiceMWS_Exception $ex) {
        // echo("XML: " . $ex->getXML() . "\n");
        $level = "Bad";
        $category = "Inventory";
        $title = "Retrieve Inventory Error (Next Token)";
        $info = "Caught Exception: " . $ex->getMessage() . " | Response Status Code: " . $ex->getStatusCode() . " | Error Code: " . $ex->getErrorCode() . " | Error Type: " . $ex->getErrorType() . " | Request ID: " . $ex->getRequestId();
        AmzFBA_Woo_Log($level, $category, $title, $info);
        SendErrorEmail($category, $info);
    } catch (Exception $e) {
        HandleGenericException("Inventory", $e);
    }
}
コード例 #2
0
/**
 * List Inventory Supply By Next Token Action Sample
 * Continues pagination over a resultset of inventory data for inventory
 * items.
 * 
 * This operation is used in conjunction with ListUpdatedInventorySupply.
 * Please refer to documentation for that operation for further details.
 *   
 * @param FBAInventoryServiceMWS_Interface $service instance of FBAInventoryServiceMWS_Interface
 * @param mixed $request FBAInventoryServiceMWS_Model_ListInventorySupplyByNextToken or array of parameters
 */
function invokeListInventorySupplyByNextToken(FBAInventoryServiceMWS_Interface $service, $request)
{
    try {
        $response = $service->listInventorySupplyByNextToken($request);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ListInventorySupplyByNextTokenResponse\n";
        if ($response->isSetListInventorySupplyByNextTokenResult()) {
            echo "            ListInventorySupplyByNextTokenResult\n";
            $listInventorySupplyByNextTokenResult = $response->getListInventorySupplyByNextTokenResult();
            if ($listInventorySupplyByNextTokenResult->isSetInventorySupplyList()) {
                echo "                InventorySupplyList\n";
                $inventorySupplyList = $listInventorySupplyByNextTokenResult->getInventorySupplyList();
                $memberList = $inventorySupplyList->getmember();
                foreach ($memberList as $member) {
                    echo "                    member\n";
                    if ($member->isSetSellerSKU()) {
                        echo "                        SellerSKU\n";
                        echo "                            " . $member->getSellerSKU() . "\n";
                    }
                    if ($member->isSetFNSKU()) {
                        echo "                        FNSKU\n";
                        echo "                            " . $member->getFNSKU() . "\n";
                    }
                    if ($member->isSetASIN()) {
                        echo "                        ASIN\n";
                        echo "                            " . $member->getASIN() . "\n";
                    }
                    if ($member->isSetCondition()) {
                        echo "                        Condition\n";
                        echo "                            " . $member->getCondition() . "\n";
                    }
                    if ($member->isSetTotalSupplyQuantity()) {
                        echo "                        TotalSupplyQuantity\n";
                        echo "                            " . $member->getTotalSupplyQuantity() . "\n";
                    }
                    if ($member->isSetInStockSupplyQuantity()) {
                        echo "                        InStockSupplyQuantity\n";
                        echo "                            " . $member->getInStockSupplyQuantity() . "\n";
                    }
                    if ($member->isSetEarliestAvailability()) {
                        echo "                        EarliestAvailability\n";
                        $earliestAvailability = $member->getEarliestAvailability();
                        if ($earliestAvailability->isSetTimepointType()) {
                            echo "                            TimepointType\n";
                            echo "                                " . $earliestAvailability->getTimepointType() . "\n";
                        }
                        if ($earliestAvailability->isSetDateTime()) {
                            echo "                            DateTime\n";
                            echo "                                " . $earliestAvailability->getDateTime() . "\n";
                        }
                    }
                    if ($member->isSetSupplyDetail()) {
                        echo "                        SupplyDetail\n";
                        $supplyDetail = $member->getSupplyDetail();
                        $member1List = $supplyDetail->getmember();
                        foreach ($member1List as $member1) {
                            echo "                            member\n";
                            if ($member1->isSetQuantity()) {
                                echo "                                Quantity\n";
                                echo "                                    " . $member1->getQuantity() . "\n";
                            }
                            if ($member1->isSetSupplyType()) {
                                echo "                                SupplyType\n";
                                echo "                                    " . $member1->getSupplyType() . "\n";
                            }
                            if ($member1->isSetEarliestAvailableToPick()) {
                                echo "                                EarliestAvailableToPick\n";
                                $earliestAvailableToPick = $member1->getEarliestAvailableToPick();
                                if ($earliestAvailableToPick->isSetTimepointType()) {
                                    echo "                                    TimepointType\n";
                                    echo "                                        " . $earliestAvailableToPick->getTimepointType() . "\n";
                                }
                                if ($earliestAvailableToPick->isSetDateTime()) {
                                    echo "                                    DateTime\n";
                                    echo "                                        " . $earliestAvailableToPick->getDateTime() . "\n";
                                }
                            }
                            if ($member1->isSetLatestAvailableToPick()) {
                                echo "                                LatestAvailableToPick\n";
                                $latestAvailableToPick = $member1->getLatestAvailableToPick();
                                if ($latestAvailableToPick->isSetTimepointType()) {
                                    echo "                                    TimepointType\n";
                                    echo "                                        " . $latestAvailableToPick->getTimepointType() . "\n";
                                }
                                if ($latestAvailableToPick->isSetDateTime()) {
                                    echo "                                    DateTime\n";
                                    echo "                                        " . $latestAvailableToPick->getDateTime() . "\n";
                                }
                            }
                        }
                    }
                }
            }
            if ($listInventorySupplyByNextTokenResult->isSetNextToken()) {
                echo "                NextToken\n";
                echo "                    " . $listInventorySupplyByNextTokenResult->getNextToken() . "\n";
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
    } catch (FBAInventoryServiceMWS_Exception $ex) {
        echo "Caught Exception: " . $ex->getMessage() . "\n";
        echo "Response Status Code: " . $ex->getStatusCode() . "\n";
        echo "Error Code: " . $ex->getErrorCode() . "\n";
        echo "Error Type: " . $ex->getErrorType() . "\n";
        echo "Request ID: " . $ex->getRequestId() . "\n";
        echo "XML: " . $ex->getXML() . "\n";
    }
}