def __init__(self, config): relation_type = config.get("type", None) if relation_type: # Map initial config string to enum type try: type = map_relation_type(relation_type) except AttributeError: type = ProductCrossSellType.RELATED config["type"] = type super(ProductCrossSellsPlugin, self).__init__(config)
def get_context_data(self, context): count = self.config.get("count", 4) product = context.get("product", None) orderable_only = self.config.get("orderable_only", True) relation_type = self.config.get("type") try: type = map_relation_type(relation_type) except AttributeError: type = ProductCrossSellType.RELATED return { "request": context["request"], "title": self.get_translated_value("title"), "product": product, "type": type, "count": count, "orderable_only": orderable_only, }