0

I have a large dataset that I need to push to the account-level shipping settings in Google Merchant Center. I am using the Google Shopping API via the PHP Client Library.

If I load a subset of the data and call it once at the end, it works fine:

$settings = $clientservice->shippingsettings->get('XXXXXX', 'XXXXXX');

for each data point that represents a service
    for each data point that represents a rate group
        create weight/destination state table
    next
next

$settings->setServices($services);
$updatedSettings = $clientservice->shippingsettings->update('XXXXXX', 'XXXXXX', $settings);

However, if I load the entire set of data and try to apply it at once, I get a 413 Request Too Large response. So I would like to load it incrementally, one service at a time. I tried this:

$settings = $clientservice->shippingsettings->get('XXXXXX', 'XXXXXX');

for each data point that represents a service
    for each data point that represents a rate group
        create weight/destination state table
    next
    $settings->setServices([$service]);
    $updatedSettings = $clientservice->shippingsettings->patch('XXXXXX', 'XXXXXX', $settings);
next

However, each service just overwrites the previous one. "patch" seems to operate just like "update", as best I can tell. Anyone know how to make this work?

FLSusan
  • 35
  • 5

1 Answers1

1

Not 100% sure i understand the question part of your question. However I can tell you this Update will update all of the fields you send with the request. say we have an object

class Foo { 
    public $aname= 'Jane'; 
    public $aaddress = '12 Blueberry Hill'; 
    public $aage = '23';        

} 

If i do an update

 update('Jane Doe', '12 Blueberry Hill');

It expects all of the fileds to be sent in this instance age will probably be set to null because it wasnt included in the request.

Now patch will only update the fields you include

 update('Jane Doe', '112 Blueberry Hill');

so this request will update name and address and not touch age.

If you are having an issue with size then you should see if the api you are using includes the fields optional parameter i think most of the Google apis do. Then you could request only the fields you want to update and then send a patch with that.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • DalmTo, thank you, it sounds like you understand what I'm saying pretty well. The problem is that patch appears to act just like update - it doesn't leave the existing fields in place. (The other services.) Which makes me wonder if I'm using it incorrectly. – FLSusan Jun 12 '18 at 21:32
  • The trick is to send an object only containing the feeds you want updated. not the full object – Linda Lawton - DaImTo Jun 13 '18 at 04:49
  • DalmTo - thanks. I wonder if I need to "roll my own" to do that rather than using the PHP wrapper, which seems to put everything there by itself. I am going to give it a shot. Thank you. – FLSusan Jun 13 '18 at 14:22
  • $settings should only contain the values you want to change everything else should be null – Linda Lawton - DaImTo Jun 13 '18 at 17:15
  • Someone at Google responded to my question on their groups and said this is not possible with the shippingsettings object, whether with the library or directly. They don't support adding/editing one service at a time. – FLSusan Jun 15 '18 at 01:45