コード例 #1
0
    def testGetAllProducts(self):
        """
        """
        pm = IProductManagement(self.portal.myshop.categories.category_1)
        product_ids = [p.getId() for p in pm.getAllProducts()]
        self.assertEqual(product_ids, ["product_1", "product_2"])

        pm = IProductManagement(self.portal.myshop.categories.category_1.category_11)
        product_ids = [p.getId() for p in pm.getAllProducts()]
        self.assertEqual(product_ids, ["product_1", "product_2"])
コード例 #2
0
    def testGetAllProducts(self):
        """
        """
        pm = IProductManagement(self.portal.myshop.categories.category_1)
        product_ids = [p.getId() for p in pm.getAllProducts()]
        self.assertEqual(product_ids, ["product_1", "product_2"])

        pm = IProductManagement(
            self.portal.myshop.categories.category_1.category_11)
        product_ids = [p.getId() for p in pm.getAllProducts()]
        self.assertEqual(product_ids, ["product_1", "product_2"])
コード例 #3
0
    def _getBatch(self):
        """
        """
        # Calculate products per page
        fi = self.getFormatInfo()
        products_per_page = fi.get("lines_per_page") * \
                            fi.get("products_per_line")        

        # Get all products                    
        mtool = getToolByName(self.context, "portal_membership")        
        sorting = self.request.SESSION.get("sorting")
        try:
            sorted_on, sort_order = sorting.split("-")
        except (AttributeError, ValueError):
            sorted_on  = "price"
            sort_order = "desc"
        
        pm = IProductManagement(self.context)
        products = pm.getAllProducts(sorted_on=sorted_on,
                                     sort_order = sort_order)
        
        # Get start page
        b_start  = self.request.get('b_start', 0);

        # Calculate Batch
        return Batch(products, products_per_page, int(b_start), orphan=0);
コード例 #4
0
ファイル: easyshop_macros.py プロジェクト: Easyshop/Easyshop
    def getProductURLs(self):
        """
        """
        sorting = self.request.SESSION.get("sorting")
        try:
            sorted_on, sort_order = sorting.split("-")
        except (AttributeError, ValueError):
            sorted_on  = "price"
            sort_order = "desc"
        
        # all categories of the product
        cm = ICategoryManagement(self.context)
        categories = cm.getTopLevelCategories()
        
        result = []
        for category in categories:
            pm = IProductManagement(category)
            products = pm.getAllProducts(
                sorted_on=sorted_on,
                sort_order = sort_order)
            
            # determine position of product within category
            index = products.index(self.context)
            
            # generate previous/next url
            temp = {}            
            if index==0:
                temp["previous"] = None
                temp["first"] = None
            else:
                product = products[index-1]
                temp["previous"] = product.absolute_url()
                temp["first"] = products[0].absolute_url()
            try:
                product = products[index+1]
                temp["next"] = product.absolute_url()
                temp["last"] = products[-1].absolute_url()
            except IndexError:
                temp["next"] = None
                temp["last"] = None

            temp["category_url"] = category.absolute_url()
            temp["category"] = category.Title()
            temp["position"] = index + 1
            temp["amount"] = len(products)            
            
            result.append(temp)
            
        return result
コード例 #5
0
    def getProductURLs(self):
        """
        """
        sorting = self.request.SESSION.get("sorting")
        try:
            sorted_on, sort_order = sorting.split("-")
        except (AttributeError, ValueError):
            sorted_on = "price"
            sort_order = "desc"

        # all categories of the product
        cm = ICategoryManagement(self.context)
        categories = cm.getTopLevelCategories()

        result = []
        for category in categories:
            pm = IProductManagement(category)
            products = pm.getAllProducts(sorted_on=sorted_on,
                                         sort_order=sort_order)

            # determine position of product within category
            index = products.index(self.context)

            # generate previous/next url
            temp = {}
            if index == 0:
                temp["previous"] = None
                temp["first"] = None
            else:
                product = products[index - 1]
                temp["previous"] = product.absolute_url()
                temp["first"] = products[0].absolute_url()
            try:
                product = products[index + 1]
                temp["next"] = product.absolute_url()
                temp["last"] = products[-1].absolute_url()
            except IndexError:
                temp["next"] = None
                temp["last"] = None

            temp["category_url"] = category.absolute_url()
            temp["category"] = category.Title()
            temp["position"] = index + 1
            temp["amount"] = len(products)

            result.append(temp)

        return result