From 070823b3e5229b911a2e57508d9ad33bc3a1d0ee Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 23 Nov 2022 17:21:13 +0700 Subject: add categories in brand homepage --- indoteknik_api/controllers/api_v1/brand_homepage.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/brand_homepage.py b/indoteknik_api/controllers/api_v1/brand_homepage.py index 75b779d7..a6a17e88 100644 --- a/indoteknik_api/controllers/api_v1/brand_homepage.py +++ b/indoteknik_api/controllers/api_v1/brand_homepage.py @@ -25,6 +25,13 @@ class BrandHomepage(controller.Controller): ('x_manufacture', '=', brand_homepage.manufacture_id.id) ] products = request.env['product.template'].search(query_product, order='product_rating desc', limit=8) + + categories = [] + for product in products: + for c in product.public_categ_ids: + categories.append(c.name) + categories = list(dict.fromkeys(categories)) + data.append({ 'sequence': brand_homepage.sequence, 'manufacture_id': brand_homepage.manufacture_id.id, @@ -32,6 +39,7 @@ class BrandHomepage(controller.Controller): 'image': base_url + 'api/image/website.brand.homepage/image/' + str( brand_homepage.id) if brand_homepage.image else '', 'url': brand_homepage.url, + 'categories': [y for y in categories], 'products': [request.env['product.template'].api_single_response(x) for x in products] }) -- cgit v1.2.3