summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/solr
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-07-26 15:43:46 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-07-26 15:43:46 +0700
commit525072694a3544d65a1075d6087600edbe173f18 (patch)
tree8963a437df3e40a57f9f95633e58c652e9d7a452 /indoteknik_custom/models/solr
parent5e6c42803281ffc3098061113ca153a59a6eeb58 (diff)
parent54f5accd8e23cdc944f74dcf4399ac1d21455065 (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models/solr')
-rw-r--r--indoteknik_custom/models/solr/product_template.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 3d7d3a80..19143be3 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -65,11 +65,9 @@ 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 = ''
- for category in template.public_categ_ids:
- category_id, category_name = category.id, category.name
- break
+ # Mengumpulkan semua kategori
+ category_ids = [category.id for category in template.public_categ_ids]
+ category_names = [category.name for category in template.public_categ_ids]
document = solr_model.get_doc('product', template.id)
document.update({
@@ -92,21 +90,21 @@ 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_ids": 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,
'sni_b': template.unpublished,
'tkdn_b': template.unpublished,
"qty_sold_f": template.qty_sold,
- "voucher_pastihemat" : {
- "min_purchase" : voucher.min_purchase_amount,
- "discount_type" : voucher.discount_type,
- "discount_amount" : voucher.discount_amount,
- "max_discount" : voucher.max_discount_amount
- }
+ # "voucher_pastihemat" : {
+ # "min_purchase" : voucher.min_purchase_amount,
+ # "discount_type" : voucher.discount_type,
+ # "discount_amount" : voucher.discount_amount,
+ # "max_discount" : voucher.max_discount_amount
+ # }
})
self.solr().add(docs=[document], softCommit=True)