Skip to content

Instantly share code, notes, and snippets.

@sharoonthomas
Created September 21, 2016 16:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharoonthomas/6ee78fd7ed3b8164637fb2142bc104f7 to your computer and use it in GitHub Desktop.
Save sharoonthomas/6ee78fd7ed3b8164637fb2142bc104f7 to your computer and use it in GitHub Desktop.
Finding products and their inventory using Fulfil REST API (python example)
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