diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-26 10:34:08 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-26 10:34:08 +0700 |
| commit | 093455f8ad3219670a50898c16d70394d2f1e227 (patch) | |
| tree | 001c6cdf784f471dc01c77a2860ff6238726d82e | |
| parent | 468a7d1cea1b19844ae18be4c926bdd5276d7bbd (diff) | |
<iman> update code category_id_i sync to solr
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 15 |
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 b3787499..4bf0b88d 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, |
