summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-07-26 03:34:48 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-07-26 03:34:48 +0000
commit88035e3c9586fdd58275834f64b6cad4c8df0711 (patch)
tree39b2e5080302b1a0b397b2e4cbfd73a162c5addb
parent5bebaee33872d528f1b007a1cb0cc28cfb39cab0 (diff)
parent093455f8ad3219670a50898c16d70394d2f1e227 (diff)
Merged in feature/iman-categories-homepage (pull request #179)
Feature/iman categories homepage
-rw-r--r--indoteknik_custom/models/solr/product_template.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 3d7d3a80..3305c7ba 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -65,11 +65,12 @@ class ProductTemplate(models.Model):
variant_names = ', '.join([x.display_name or '' for x in template.product_variant_ids])
variant_codes = ', '.join([x.default_code or '' for x in template.product_variant_ids])
- category_id = 0
- category_name = ''
+ # Mengumpulkan semua kategori
+ category_ids = []
+ category_names = []
for category in template.public_categ_ids:
- category_id, category_name = category.id, category.name
- break
+ category_ids.append(category.id)
+ category_names.append(category.name)
document = solr_model.get_doc('product', template.id)
document.update({
@@ -92,9 +93,9 @@ class ProductTemplate(models.Model):
"variants_code_t": variant_codes,
"search_rank_i": template.search_rank,
"search_rank_weekly_i": template.search_rank_weekly,
- "category_id_i": category_id,
- "category_name_s": category_name,
- "category_name": category_name,
+ "category_id_i": ','.join(map(str, category_ids)), # ID kategori sebagai string yang dipisahkan koma
+ "category_name_s": ', '.join(category_names), # Nama kategori sebagai string yang dipisahkan koma
+ "category_name": category_names, # Nama kategori sebagai list
"description_t": template.website_description or '',
'has_product_info_b': True,
'publish_b': not template.unpublished,