jlevers / selling-partner-api

A PHP client library for Amazon's Selling Partner API
BSD 3-Clause "New" or "Revised" License
398 stars 185 forks source link

Argument To Not Build "$this->data" for Document.php #54

Closed steverobison closed 3 years ago

steverobison commented 3 years ago

Hello,

First thanks for this application. I've just started using it and it works great.

We have 350k+ listings on Amazon so some of the reports for us are very large. This app is causing memory errors when attempting to build the data structure. Can you add an argument so that $this->data is not built? I made a quick change to the Document.php file that works and would not affect anyone unless they also wanted only the raw data for the report. Feel free to use it or build something similar that is more in line with your coding structure. Thanks again!

public function download($rawOnly = false): string {

Then I put the following around the switch that builds the data.

if(!$rawOnly) { }

jlevers commented 3 years ago

Glad you're finding the library useful!

Try upgrading to v3.0.5 -- I just added a $postProcess parameter to Document::download() which defaults to true. If you pass false, I think your problem will be solved. I still set Document::$data, but I just set it to the raw document contents instead of parsing it.

steverobison commented 3 years ago

Perfect. Thanks Jesse! I'll be slowly migrating from MWS over the next few months. I'll let you know if I find anything else with my use cases. So much nicer to be working with SP v2 instead of the old clunky MWS api. Long overdue by Amazon.