From 7d9ab0d2d9ce5dce5976d6d86e38593c7cf20cd5 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 10:23:41 +0700 Subject: update code category_id_i sync to solr --- indoteknik_custom/models/solr/apache_solr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/solr/apache_solr.py b/indoteknik_custom/models/solr/apache_solr.py index 6560c9b5..9ba3b721 100644 --- a/indoteknik_custom/models/solr/apache_solr.py +++ b/indoteknik_custom/models/solr/apache_solr.py @@ -22,10 +22,10 @@ class ApacheSolr(models.Model): url = '' if env == 'development': - url = 'http://192.168.23.5:8983/solr/' + url = 'http://localhost:8983/solr/' elif env == 'production': url = 'http://34.101.189.218:8983/solr/' - + return pysolr.Solr(url + schema, always_commit=False, timeout=10) def get_doc(self, schema, id): -- cgit v1.2.3 From 468a7d1cea1b19844ae18be4c926bdd5276d7bbd Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 10:29:40 +0700 Subject: Revert " update code category_id_i sync to solr" This reverts commit 7d9ab0d2d9ce5dce5976d6d86e38593c7cf20cd5. --- indoteknik_custom/models/solr/apache_solr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/solr/apache_solr.py b/indoteknik_custom/models/solr/apache_solr.py index 9ba3b721..6560c9b5 100644 --- a/indoteknik_custom/models/solr/apache_solr.py +++ b/indoteknik_custom/models/solr/apache_solr.py @@ -22,10 +22,10 @@ class ApacheSolr(models.Model): url = '' if env == 'development': - url = 'http://localhost:8983/solr/' + url = 'http://192.168.23.5:8983/solr/' elif env == 'production': url = 'http://34.101.189.218:8983/solr/' - + return pysolr.Solr(url + schema, always_commit=False, timeout=10) def get_doc(self, schema, id): -- cgit v1.2.3 From 093455f8ad3219670a50898c16d70394d2f1e227 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 10:34:08 +0700 Subject: update code category_id_i sync to solr --- indoteknik_custom/models/solr/product_template.py | 15 ++++++++------- 1 file 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, -- cgit v1.2.3