示例#1
0
文件: product.py 项目: vidifox/sumsum
 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())
示例#2
0
    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())
示例#3
0
文件: product.py 项目: vidifox/sumsum
 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
示例#4
0
    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))
示例#5
0
文件: models.py 项目: vidifox/sumsum
 def articles(self):
     """
     Returns an array of all articles in a blog.
     """
     raise NotImplemented
     return List()
示例#6
0
文件: models.py 项目: vidifox/sumsum
 def fulfillments(self):
     return List(self.fulfillment_set.all())
示例#7
0
文件: models.py 项目: vidifox/sumsum
 def discounts(self):
     return List(self.discounts_m2m.all())
示例#8
0
文件: product.py 项目: vidifox/sumsum
 def compare_at_prices(self):
     return List([v.compare_at_price for v in self.variants()])
示例#9
0
文件: product.py 项目: vidifox/sumsum
 def variants(self):
     """
     Returns an array the product's variants.
     """
     return List(self.productvariant_set.all())
示例#10
0
文件: product.py 项目: vidifox/sumsum
 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])
示例#11
0
文件: product.py 项目: vidifox/sumsum
 def collections(self):
     return List(self.collections_m2m.all())
示例#12
0
 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))))
示例#13
0
 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))))