Created
April 27, 2019 02:15
-
-
Save hamletbatista/96ab561758668a696b67939e221e8653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_PAGE_SIZE = 10 | |
MAX_RESULT = 20 | |
merchant_id = XXXXXXX | |
#execute list API | |
request = service.products().list( | |
merchantId=merchant_id, maxResults=MAX_PAGE_SIZE) | |
#iterate over results and stop at MAX_RESULT products | |
count = MAX_RESULT | |
while request is not None and count > 0: | |
result = request.execute() | |
products = result.get('resources') | |
if not products: | |
print('No products were found.') | |
break | |
for product in products: | |
print('Product "%s" with title "%s" was found.' % | |
(product['id'], product['title'])) | |
count = count -1 | |
if count == 0: | |
break | |
request = service.products().list_next(request, result) | |
#example output | |
#Product "online:en:US:XX-XXXXX-XX" with title "Produc Title 1" was found. | |
#Product "online:en:US:XX-XXX-XX-XX" with title "Produc Title 2" was found. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment