CPIGroup / phpAmazonMWS

A library to connect to Amazon's MWS web services in an object oriented manner
Apache License 2.0
257 stars 229 forks source link

Undefined offset: 0 on fetching a Request List #146

Open nnsdev opened 6 years ago

nnsdev commented 6 years ago

Hey, I am currently trying to pull the orders ordered by last updated from the MWS api, I've used your SDK for some other calls and it worked fine there.

My problem is on report type _GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_ my call works without problems, but as soon as I switch to _GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_ I am getting an error with Undefined offset: 0 while getting the Report ID.

As I found out, the whole fetched request list is empty.

$list = new AmazonReportRequestList('x');
$list->setReportTypes("_GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_");
$list->fetchRequestList();
$bericht = new AmazonReport('x');
$bericht->setReportId($list->getReportId());

Is there anything I can do to fix this problem?

Note: This is using the laravel wrapper by Sonnenglas, although it uses pretty much all your code.

Peardian commented 6 years ago

The undefined offset error is happening because I didn't write the list-based get functions very well. It assumes that any given numeric value will be a valid array key and doesn't check to see if the key exists.

As for the problem of why the list is empty, that could just be what Amazon is giving you. Assuming the fork you are using is moderately up-to-date, you can use the getLastResponse() method to see the full raw XML data that Amazon sent.

nnsdev commented 6 years ago

Hey, thanks for the help. I backtracked this and it appears Amazon doesn't give us any data at all which might be the reason why this error pops up, although this report type just sorts the orders after the last update, while the other sorting method for orders sorts after created, which gives a lot of data. Really strange, but I can't really expect much from an 8 year old API.

If I find out why I'll let you know :)

nnsdev commented 6 years ago

Hey, small followup on this.

So as I found out, _GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_ only works if you get it enabled through the MWS support, after we got it enabled the error (obviously) disappeared and everything is working fine.