def getShop(self): """ """ object = self.context try: while object.meta_type not in ("MallEasyShop", "EasyMall"): if object.meta_type == "Plone Factory Tool": object = object.aq_parent else: object = object.aq_inner.aq_parent except AttributeError: # Next line is needed for the temporary products for payment and # shipping. As they have no real context above code seems not to # work. But they have given the shop as context so we can give # it back here. See also: # - adapters/shop/payment/createTemporaryPaymentProduct # - adapters/shop/shipping/createTemporaryShippingProduct. # I'm not sure whether this is clean, I assume it is not. if IShop.providedBy(object.context) or IMall.providedBy( object.context): return object.context else: return None return object
def getShop(self): """ """ object = self.context try: while object.meta_type not in ("MallEasyShop", "EasyMall"): if object.meta_type == "Plone Factory Tool": object = object.aq_parent else: object = object.aq_inner.aq_parent except AttributeError: # Next line is needed for the temporary products for payment and # shipping. As they have no real context above code seems not to # work. But they have given the shop as context so we can give # it back here. See also: # - adapters/shop/payment/createTemporaryPaymentProduct # - adapters/shop/shipping/createTemporaryShippingProduct. # I'm not sure whether this is clean, I assume it is not. if IShop.providedBy(object.context) or IMall.providedBy(object.context): return object.context else: return None return object
def getProducts(self, category_id=None): """ """ shop_or_mall = IShopManagement(self.context).getShop() # NOTE: The more specific one has to be the first, because a mall is # also a shop if IMall.providedBy(shop_or_mall): reference = "mall_categories_products" elif IShop.providedBy(shop_or_mall): reference = "categories_products" else: return [] mtool = getToolByName(self.context, "portal_membership") result = [] # Returns just "View"-able products. for product in self.context.getRefs(reference): if mtool.checkPermission("View", product) is not None: result.append(product) return result