summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-11-23 17:21:13 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-11-23 17:21:13 +0700
commit070823b3e5229b911a2e57508d9ad33bc3a1d0ee (patch)
tree8d9afb172364a76178d4fab7240436f18e351920 /indoteknik_api/controllers/api_v1
parent59d2d758d4866c5f6a844e885dd49cbee4a2e7c2 (diff)
add categories in brand homepage
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/brand_homepage.py8
1 files changed, 8 insertions, 0 deletions
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]
})