@contextfunction
def get_listed_products(context, n_products, ordering=None, filter_dict=None, orderable_only=True):
 request = context['request']
 customer = request.customer
 shop = request.shop
 if (not filter_dict):
  filter_dict = {}
 products_qs = Product.objects.listed(shop=shop, customer=customer, language=get_language()).filter(**filter_dict)
 if ordering:
  products_qs = products_qs.order_by(ordering)
 if orderable_only:
  suppliers = Supplier.objects.all()
  products = []
  for product in products_qs[:(n_products * 4)]:
   if (len(products) == n_products):
    break
   shop_product = product.get_shop_instance(shop, allow_cache=True)
   for supplier in suppliers:
    if shop_product.is_orderable(supplier, customer, shop_product.minimum_purchase_quantity):
     products.append(product)
     break
  return products
 products = products_qs[:n_products]
 return products

@ contextfunction def get_listed_products ( context , n_products , ordering = None , filter_dict = None , orderable_only = True ) : request = context [ 'request' ] customer = request . customer shop = request . shop if ( not filter_dict ) : filter_dict = { } products_qs = Product . objects . listed ( shop = shop , customer = customer , language = get_language ( ) ) . filter ( ** filter_dict ) if ordering : products_qs = products_qs . order_by ( ordering ) if orderable_only : suppliers = Supplier . objects . all ( ) products = [ ] for product in products_qs [ : ( n_products * 4 ) ] : if ( len ( products ) == n_products ) : break shop_product = product . get_shop_instance ( shop , allow_cache = True ) for supplier in suppliers : if shop_product . is_orderable ( supplier , customer , shop_product . minimum_purchase_quantity ) : products . append ( product ) break return products products = products_qs [ : n_products ] return products
returns all products marked as listed that are determined to be visible based on the current context .