I am developing a script that syncs my stock quantities across Amazon, Ebay, and my website. I have now stumbled at the finishing line. I am trying to update my Amazon stock quantities using the SubmitFeedSample.php as provided by Amazon. I can update a single SKU without issue, however I need to know how to update multiple SKU quantities by passing in an array into the request.
I tried the following which did not give me any errors but has not succeeded in updating the quantities:
$testArray = array();
$testArray[0][0] = 'P768';
$testArray[0][1] = 1;
$testArray[1][0] = 'ULP40';
$testArray[1][1] = 3;
$toStr = '';
for($i = 0, $j = 1; $i < sizeof($testArray); $i++, $j++) {
$toStr .= '<Message>' . '<MessageID>' . $j . '</MessageID>' . '<OperationType>Update</OperationType>' . '<Inventory>' . '<SKU>' . $testArray[$i][0] . '</SKU>' . '<Quantity>' . $testArray[$i][1] . '</Quantity>' . '</Inventory>' . '</Message>';
}
$feed ='<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>MYMERCHANTID</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>' . $toStr .
'</AmazonEnvelope>';
I am a novice programmer and I’m quite proud, and very surprised, that I’ve managed to get this far. However; I feel like there should be an easy solution for this?