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(-) (limited to 'indoteknik_custom/models/solr') 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(-) (limited to 'indoteknik_custom/models/solr') 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(-) (limited to 'indoteknik_custom/models/solr') 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 From e394d734ca4e53bd63b767c9c7fe77a5ebe49245 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 26 Jul 2024 13:48:31 +0700 Subject: add website categories lob --- indoteknik_custom/models/solr/product_template.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'indoteknik_custom/models/solr') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 4bf0b88d..2143fbe2 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -66,11 +66,8 @@ class ProductTemplate(models.Model): variant_codes = ', '.join([x.default_code or '' for x in template.product_variant_ids]) # Mengumpulkan semua kategori - category_ids = [] - category_names = [] - for category in template.public_categ_ids: - category_ids.append(category.id) - category_names.append(category.name) + 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({ @@ -93,7 +90,7 @@ 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": ','.join(map(str, category_ids)), # ID kategori sebagai string yang dipisahkan koma + "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 '', @@ -102,12 +99,12 @@ class ProductTemplate(models.Model): '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 + # } }) print(document) -- cgit v1.2.3