简体   繁体   English

MWS Amazon PHP API GetFulfillmentPreviewItemList:不清楚如何设置多个SKU的列表

[英]MWS Amazon PHP API GetFulfillmentPreviewItemList: unclear how to set a list with more than one sku

there are two items.member in the array $order['Items.member'], only the last one appears in $itemList. $ order ['Items.member']数组中有两个item.member,只有最后一个出现在$ itemList中。 first item[0] get apparently overwritten. 第一项[0]显然被覆盖。

foreach ($order['Items.member'] as $lineitem) {

            $item[$v] = new FBAOutboundServiceMWS_Model_GetFulfillmentPreviewItem();
            $item[$v]->setSellerSKU($SKUselected);
            $item[$v]->setQuantity(round($lineitem['qty'],0));
            echo "qty: ".$lineitem['qty']."<br>";
            $item[$v]->setSellerFulfillmentOrderItemId($lineitem['SellerFulfillmentOrderItemId']);
            echo "SellerFulfillmentOrderItemId: ".$lineitem['SellerFulfillmentOrderItemId']."<br>";             

            $itemList->setmember($item[$v]);
            $v++;
        }
        $request->setItems($itemList);
        echo 'item0: <pre>';print_r($item[0]);echo '</pre>';
        echo 'item1: <pre>';print_r($item[1]);echo '</pre>';
        echo 'itemList: <pre>';print_r($itemList);echo '</pre>';

here the itemlist object dumped; 这里的itemlist对象已转储; filled only with last item 999938-1. 仅填充最后一个项目999938-1。 The item 999938-0 is missing: 缺少项目999938-0:

FBAOutboundServiceMWS_Model_GetFulfillmentPreviewItemList Object
(
    [_fields:protected] => Array
        (
            [member] => Array
                (
                    [FieldValue] => Array
                        (
                            [0] => FBAOutboundServiceMWS_Model_GetFulfillmentPreviewItem Object
                                (
                                    [_fields:protected] => Array
                                        (
                                            [SellerSKU] => Array
                                                (
                                                    [FieldValue] => XX-XXXX-JRBG
                                                    [FieldType] => string
                                                )

                                            [Quantity] => Array
                                                (
                                                    [FieldValue] => 1
                                                    [FieldType] => int
                                                )

                                            [SellerFulfillmentOrderItemId] => Array
                                                (
                                                    [FieldValue] => 999938-1
                                                    [FieldType] => string
                                                )

                                        )

                                )

                        )

                    [FieldType] => Array
                        (
                            [0] => FBAOutboundServiceMWS_Model_GetFulfillmentPreviewItem
                        )

                )

        )

)

the items itself are defined correctly (as per echo). 项目本身已正确定义(根据回显)。

I created already separate list as new object, however all items are supposed to send into a single fulfillment order eventually. 我已经创建了单独的列表作为新对象,但是所有项目最终都应该发送到单个履行订单中。

Now I am pretty much lost and looking into the model did not bring any clarification. 现在我几乎迷失了,对模型的研究并没有带来任何澄清。 this would be so easy with a loop just to create the XML code directly. 仅通过循环直接创建XML代码将非常容易。 lol 大声笑

thank you for some hints 谢谢你的一些提示

ok the answer is pretty simple: introduction of another temporary array 好吧,答案很简单:引入另一个临时数组

$item[$v]->setSellerFulfillmentOrderItemId($lineitem['SellerFulfillmentOrderItemId']);

                $memberArray[] = $item[$v] ;


                $v++;
            }
            $itemList->setmember($memberArray);
            $request->setItems($itemList);

the list/array of member items must be given with the "setmember" function and not with "setItems". 成员项目的列表/数组必须使用“ setmember”函数而不是“ setItems”给出。 this is not intuitive and questionable naming, so it is not recommended to rely on names of functions. 这是不直观和可疑的命名,因此不建议依赖函数名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM