Closed cralls closed 8 years ago
Sorry, I think you misunderstood how this SDK uses the fillup/array2xml
library. In the array you pass to the calls in this SDK you need to structure the array like the XML required in the API call.
Please see https://github.com/fillup/walmart-partner-api-sdk-php/blob/develop/docs/item.md for examples.
Hi fillup,
You're probably right, I may not be using the SDK as intended but there is definitely an issue when passing a sequential array to bulk, it doesn't format the XML correctly because it's not able to get the $position from the $schema. Try sending a sequential array instead of an associative array of items to bulk and you'll see what I mean. The change I originally posted to line 121 is incorrect. I've updated A2X.php with the following changes:
1: I've added $position = null to the __construct so that the actual $position can be passed. 2: I'm passing the $position variable in the toXml call.
public function __construct($array, $schema = [], $position = null, $version = '1.0', $encoding = 'UTF-8') { $this->xml = sprintf('<?xml version="%s" encoding="%s"?>', $version, $encoding); $this->xml .= $this->toXml($array, $schema, $position); }
So now when I create a new A2X object I pass the position:
$a2x = new A2X($items, $schema, '/InventoryFeed/inventory');
And now I'm able to successfully pass $items as a sequential array instead of an associative array to A2X.
When you say "sequential array" are you talking about an array with an integer index? Such as:
[
0 => [],
1 => [],
2 => [],
]
As opposed to a simple non-indexed array like:
[
[],
[],
[],
]
Correct.
Casey Ralls http://www.vectorns.com/blog?format=feed&type=rss https://twitter.com/VectorNetSol https://plus.google.com/u/0/b/111960571789264200297/111960571789264200297/posts/p/pub
https://www.facebook.com/pages/Vector-Network-Solutions-eCommerce-Custom-PHP-Development-Services/51307794206 http://www.youtube.com/user/ax10m E-Commerce Manager | cralls@vectorns.com | 208.572.0468 | www.vectorns.com http://www.vectorns.com
On Thu, Oct 27, 2016 at 9:20 AM, Phillip Shipley notifications@github.com wrote:
When you say "sequential array" are you talking about an array with an integer index? Such as:
[ 0 => [], 1 => [], 2 => [],]
As opposed to a simple non-indexed array like:
[ [], [], [],]
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fillup/walmart-partner-api-sdk-php/issues/18#issuecomment-256672814, or mute the thread https://github.com/notifications/unsubscribe-auth/AIH0kZnjgyj0VpejmthHVZlk6a0eIhGIks5q4MEsgaJpZM4KQbfT .
On line 121 of A2X.php:
$elementName = 'item';
needs to be changed to:
$elementName = 'MPItem';