def testGetCategories(self): """ """ cm = ICategoryManagement(self.portal.myshop.categories.category_1) category_ids = [c.id for c in cm.getCategories()] for id in ["category_11", "category_12", "category_111"]: self.failUnless(id in category_ids) cm = ICategoryManagement(self.portal.myshop.categories.category_1.category_11) category_ids = [c.id for c in cm.getCategories()] self.assertEqual(["category_111"], category_ids) cm = ICategoryManagement(self.portal.myshop.categories.category_2) self.failUnless(len(cm.getCategories()) == 0)
def testGetCategories(self): """ """ cm = ICategoryManagement(self.portal.myshop.categories.category_1) category_ids = [c.id for c in cm.getCategories()] for id in ["category_11", "category_12", "category_111"]: self.failUnless(id in category_ids) cm = ICategoryManagement( self.portal.myshop.categories.category_1.category_11) category_ids = [c.id for c in cm.getCategories()] self.assertEqual(["category_111"], category_ids) cm = ICategoryManagement(self.portal.myshop.categories.category_2) self.failUnless(len(cm.getCategories()) == 0)
def testGetCategories(self): """ """ cm = ICategoryManagement(self.shop) ids = [c.id for c in cm.getCategories()] self.failUnless("category_1" in ids) self.failUnless("category_2" in ids) self.failUnless("category_11" in ids) self.failUnless("category_111" in ids)
def testGetTopLevelCategories(self): """ """ cm = ICategoryManagement(self.portal.myshop.categories.category_1) category_ids = [c.id for c in cm.getTopLevelCategories()] self.failUnless(len(category_ids) == 2) for id in ["category_11", "category_12"]: self.failUnless(id in category_ids) cm = ICategoryManagement(self.category_2) self.failUnless(len(cm.getCategories()) == 0)
def getAllProducts(self, sorted_on=None, sort_order=None): """ """ pm = IProductManagement(self.context) products = pm.getProducts() cm = ICategoryManagement(self.context) for category in cm.getCategories(): pm = IProductManagement(category) products.extend(pm.getProducts()) if sorted_on == "name": products = self._sortProductsByName(products, sort_order) elif sorted_on == "price": products = self._sortProductsByPrice(products, sort_order) return products