summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-17 17:08:06 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-17 17:08:06 +0700
commit245f5c63c40527b94cf45e20e4c8dd15f5b51e98 (patch)
tree97f0ed569dcaf7aee09340c98a9298d24a2ebbed
parent8914f55dba0a2d4a1e992c9d0635ae993950bcf1 (diff)
<iman> update menampilkan category dan brand, sebelum ditampilkan cek dulu apakah brand termasuk kedalam category
-rw-r--r--indoteknik_custom/models/find_page.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/indoteknik_custom/models/find_page.py b/indoteknik_custom/models/find_page.py
index b81b3845..463092ce 100644
--- a/indoteknik_custom/models/find_page.py
+++ b/indoteknik_custom/models/find_page.py
@@ -32,13 +32,41 @@ class FindPage(models.Model):
category_id = fields.Many2one('product.public.category', string='Category', help='Bisa semua level Category')
url = fields.Char(string='Url')
+ def _get_category_hierarchy(self, category):
+ categories = []
+ current_category = category
+ while current_category:
+ categories.insert(0, current_category)
+ current_category = current_category.parent_id
+ return categories
+
def _generate_url(self):
categories = self.env['v.brand.product.category'].search([])
count = 0
for category in categories:
- print(category.brand_id.x_name+' '+category.category_id.name)
+ category_hierarchy = self._get_category_hierarchy(category.category_id)
+
+ for level, cat in enumerate(category_hierarchy, start=1):
+ products = self.env['product.product'].search([
+ ('public_categ_ids', '=', cat.id),
+ ('x_manufacture', '=', category.brand_id.id)
+ ])
+
+ if products:
+ print(f"Level {level} : {cat.name} {category.brand_id.x_name}")
+
count += 1
- print(count)
+ # if count == 5:
+ # break
+ print(f"Total categories processed: {count}")
+
+ # def _generate_url(self):
+ # categories = self.env['v.brand.product.category'].search([])
+ # count = 0
+ # for category in categories:
+ # print(category.brand_id.x_name+' '+category.category_id.name)
+ # count += 1
+ # print(count)
def _generate_url_parent(self):
print(1)