Created
September 21, 2016 16:13
-
-
Save sharoonthomas/6ee78fd7ed3b8164637fb2142bc104f7 to your computer and use it in GitHub Desktop.
Finding products and their inventory using Fulfil REST API (python example)
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
import os | |
from pprint import pprint | |
from fulfil_client import Client | |
client = Client(os.environ['FULFIL_SUBDOMAIN'], os.environ['FULFIL_API_KEY']) | |
Product = client.model('product.product') | |
def get_inventory(): | |
"Return shipments between start and end date" | |
products = [] | |
search_filter = [] | |
total_count = Product.search_count(search_filter) | |
print "Found %d products" % total_count | |
page_size = 250 | |
for offset in xrange(0, total_count, page_size): | |
products.extend( | |
Product.search_read( | |
search_filter, | |
offset, # pagination/offset | |
page_size, # pagination/limit | |
None, # ordering | |
[ | |
'code', | |
'variant_name', | |
'rec_name', | |
'description', | |
'quantity_on_hand', | |
'quantity_available', | |
] | |
) | |
) | |
return products | |
if __name__ == '__main__': | |
products = get_inventory() | |
pprint(products) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment