def main(client, product_template_id):
  # Initialize appropriate service.
  product_service = client.GetService('ProductService', version='v201508')

  # Create a filter statement to select only products created from a single
  # a product template.
  values = [{
      'key': 'productTemplateId',
      'value': {
          'xsi_type': 'NumberValue',
          'value': product_template_id
      }
  }]
  query = 'WHERE productTemplateId = :productTemplateId ORDER BY id ASC'
  statement = dfp.FilterStatement(query, values)

  # Get products by statement.
  while True:
    response = product_service.getProductsByStatement(statement.ToStatement())
    if 'results' in response:
      # Display results.
      for product in response['results']:
        print ('Product with id \'%s\' and name \'%s\' was found.' % (
            product['id'], product['name']))
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

  print '\nNumber of results found: %s' % response['totalResultSetSize']
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201508/product_service/get_products_for_product_template.py/main/original