def images(self): """ Returns an array of the product's images. Use the product_img_url filter to link to the product image on Shopify's Content Delivery Network. """ return List(self.productimage_set.all())
def products(self): """ Returns all of the products in a collection. You can show a maximum of 50 products per page. Use the paginate tag to choose how many products are shown per page. """ return List(self.product_set.all())
def options_with_values(self): """ Returns an array of the product's options including their available and currently selected values. """ opts = List() if self.option1_name: values = [v.option1 for v in self.variants if v.option1] opts.append(Option(self.option1_name, values)) if self.option2_name: values = [v.option2 for v in self.variants if v.option2] opts.append(Option(self.option2_name, values)) if self.option3_name: values = [v.option3 for v in self.variants if v.option3] opts.append(Option(self.option3_name, values)) return opts
def all_tags(self): """ Returns a list of all product tags in a collection. collection.all_tags will return the full list of tags even when the collection view is filtered. collection.all_tags will return at most 1,000 tags. In comparison, collection.tags returns all tags for a collection for the current view. For example, if a collection is filtered by tag, collection.tags returns only the tags that match the current filter. """ tags = set() for p in self.products: tags.union(p.tags) return List(sorted(tags))
def articles(self): """ Returns an array of all articles in a blog. """ raise NotImplemented return List()
def fulfillments(self): return List(self.fulfillment_set.all())
def discounts(self): return List(self.discounts_m2m.all())
def compare_at_prices(self): return List([v.compare_at_price for v in self.variants()])
def variants(self): """ Returns an array the product's variants. """ return List(self.productvariant_set.all())
def options(self): """ Returns an array of the product's option names. """ names = [self.option1_name, self.option2_name, self.option3_name] return List([n for n in names if n])
def collections(self): return List(self.collections_m2m.all())
def all_types(self): """ Returns a list of all product types in a collection. """ return List(sorted(filter(None, set(p.product_type for p in self.products))))
def all_vendors(self): """ Returns a list of all product vendors in a collection. """ return List(sorted(filter(None, set(p.vendor for p in self.products))))