Getting the number of active items for my merchant account

19 views
Skip to first unread message

Zgruntu online - development

unread,
Apr 19, 2021, 2:21:14 PM4/19/21
to Google Content API for Shopping
Hi everyone!

During the last few weeks we had some issues (=> problems) with generating our data feed thanks to which the amount of active products for the account went rapidly down. As a result, there was a massive breakdown of our dynamic ads that were using data from the feed. For my team this is an unwanted event (which we can't affect), therefore I wanted to make an auto-checker script using the awesome Google Apps Script and the Google Content API for Shopping.

I managed to progress on the script, but got into troubles and I'm not finding any hints how to move forward. The problem I am solving is getting the number of active items in my account. For this, I am using the ShoppingContent.Products.list request function, which (in default way) returns only 25 products, and the parameter of nextPageToken (I understand the importance of paging). Therefore I put the whole stuff into a loop and in every next iteration of the loop I send the nextPageToken parameter as custom parameter to the list() function.

However, the loop couldn't be stopped, because after receiving all of the products I start to receive them over and over again. I don't know, which conditions are met, when I managed to receive all of the active products (and nowhere found information about that).

For example, if there would be 75 active items in my merchant account and receiving 20 products per loop, I would expect the loop to be completed 4 times, and in the possible 5th iteration it would receive 0 products, so I could stop the loop and would come to conclusion there are totally 75 active items in my account. Unfortunately I can't, because the loop don't stop.

Any ideas how to get the number of active items in my account using the Content API for shopping? Thanks in advance for any advices!

With best regards,
Tomas Bako from Zgruntu Online

Zgruntu online - development

unread,
Apr 20, 2021, 9:19:13 AM4/20/21
to Google Content API for Shopping
Hey everyone!

After a day-off from the script I've checked it one more time with the API documentation as well and found out the correct name of the sent parameter in the continuous iterations of the request function ShoppingContent.Products.list is not nextPageToken, but pageToken.

See ya around :) ;).
Tomas Bako

Shopping API Forum Advisor Prod

unread,
Apr 21, 2021, 5:14:32 AM4/21/21
to zgruntu.d...@gmail.com, google-content-...@googlegroups.com
Hi Tomas,

I am happy to know that you've already determined the cause of the issue and you already fixed it.

But to provide you further information, it appears that you are using Shopping Content Service of Google Apps Scripts. Please note that this service and Content API are different tools, however, both can be used to manage products in merchant center account. With this, if you have further concerns with the Shopping Content Service, then you will need to reach out to their instead via this link.

Feel free to reach out again to our team if you have further concerns. Our team will be happy to provide support.

Regards,
Google Logo
Ernie John Blanca Tacata
Content API for Shopping Team
 


ref:_00D1U1174p._5004Q2FZnTJ:ref
Reply all
Reply to author
Forward
0 new messages