From 96aa78d337428ab65cafc88480f78f7779c5ba47 Mon Sep 17 00:00:00 2001 From: IT Fixcomart Date: Wed, 16 Nov 2022 09:37:31 +0700 Subject: Update product rating --- indoteknik_api/models/product_template.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/models/product_template.py b/indoteknik_api/models/product_template.py index b616a773..e140b326 100644 --- a/indoteknik_api/models/product_template.py +++ b/indoteknik_api/models/product_template.py @@ -21,13 +21,24 @@ class ProductTemplate(models.Model): 'categories': self.api_categories(product_template), } if with_detail: + rate = 0 + if data['lowest_price']['price'] > 0: + rate += 1 + if product_template.have_promotion_program: + rate += 1 + if product_template.image_128: + rate += 1 + if product_template.website_description: + rate += 1 + if product_template.qty_stock_vendor > 0: + rate += 1 data_with_detail = { 'image': base_url + 'api/image/product.template/image_512/' + str(product_template.id) if product_template.image_512 else '', 'display_name': product_template.display_name, 'variants': [self.env['product.product'].api_single_response(variant) for variant in product_template.product_variant_ids], 'description': product_template.website_description or '', 'solr_flag': product_template.solr_flag, - 'product_rating': product_template.product_rating, + 'product_rating': rate, } data.update(data_with_detail) return data -- cgit v1.2.3