diff --git a/core/graphene/object_types.py b/core/graphene/object_types.py index 1106fd63..d0e60f40 100644 --- a/core/graphene/object_types.py +++ b/core/graphene/object_types.py @@ -501,6 +501,7 @@ class ProductType(DjangoObjectType): feedbacks_count = Int(description=_("number of feedbacks")) personal_orders_only = Boolean(description=_("only available for personal orders")) seo_meta = Field(SEOMetaType, description=_("SEO Meta snapshot")) + rating = Float(description=_("rating value from 1 to 10, inclusive, or 0 if not set.")) class Meta: model = Product @@ -521,6 +522,7 @@ class ProductType(DjangoObjectType): "attribute_groups", "images", "price", + "rating", ) filter_fields = ["uuid", "name"] description = _("products") @@ -528,6 +530,9 @@ class ProductType(DjangoObjectType): def resolve_price(self: Product, _info) -> float: return self.price or 0.0 + def resolve_rating(self: Product, _info) -> float: + return self.rating or 0.0 + def resolve_feedbacks(self: Product, _info): if _info.context.user.has_perm("core.view_feedback"): return Feedback.objects.filter(order_product__product=self)