From 215fde914a2eae20928b9e40a9a5dd1ac179c4e1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 31 Aug 2023 14:06:21 +0700 Subject: fix error solr --- indoteknik_custom/models/solr/product_template.py | 1 + 1 file changed, 1 insertion(+) (limited to 'indoteknik_custom/models/solr/product_template.py') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 6ae0bec2..692eaa94 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -151,6 +151,7 @@ class ProductTemplate(models.Model): 'has_price_info_b': True }) self.solr().add([document]) + template.product_variant_ids._sync_price_to_solr() template.change_solr_data('Ada perubahan pada harga product') if not document.get('has_product_info_b'): -- cgit v1.2.3 From a08e9a90e24159b8d3a22844dac4416809c5ddff Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 1 Sep 2023 14:19:16 +0700 Subject: Fix solr product template --- indoteknik_custom/models/solr/product_template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/solr/product_template.py') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 692eaa94..63daeb46 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -106,14 +106,17 @@ class ProductTemplate(models.Model): for template in self: price_excl_after_disc = price_excl = discount = tax = 0 flashsale_data = tier1 = tier2 = tier3 = {} - + for variant in template.product_variant_ids: if price_excl_after_disc == 0 or variant._get_website_price_after_disc_and_tax() < price_excl_after_disc: + variant_flashsale = variant._get_flashsale_price() + flashsale_price = flashsale_data.get('flashsale_price') + if not flashsale_price or variant_flashsale['flashsale_price'] < flashsale_data.get('flashsale_price', 0): + flashsale_data = variant_flashsale price_excl = variant._get_website_price_exclude_tax() price_excl_after_disc = variant._get_website_price_after_disc_and_tax() discount = variant._get_website_disc(0) tax = variant._get_website_tax() - flashsale_data = variant._get_flashsale_price() # add price tiering for base price, discount, and price after discount (tier 1 - 3) tier1 = variant._get_pricelist_tier1() tier2 = variant._get_pricelist_tier2() -- cgit v1.2.3 From 513bce9e13dee0453ce24b41a54d3b408e58c7f0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Sep 2023 14:45:18 +0700 Subject: Fix bug solr product variants, add analytic tags to jurnal entries line, remove validation edit di purchase pricelist --- indoteknik_custom/models/solr/product_template.py | 42 +++++++++-------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'indoteknik_custom/models/solr/product_template.py') diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index 63daeb46..9950c93a 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -104,35 +104,25 @@ class ProductTemplate(models.Model): solr = self.solr() for template in self: - price_excl_after_disc = price_excl = discount = tax = 0 - flashsale_data = tier1 = tier2 = tier3 = {} + document = solr_model.get_doc('product', template.id) + flashsale_data = {} for variant in template.product_variant_ids: - if price_excl_after_disc == 0 or variant._get_website_price_after_disc_and_tax() < price_excl_after_disc: - variant_flashsale = variant._get_flashsale_price() - flashsale_price = flashsale_data.get('flashsale_price') - if not flashsale_price or variant_flashsale['flashsale_price'] < flashsale_data.get('flashsale_price', 0): - flashsale_data = variant_flashsale - price_excl = variant._get_website_price_exclude_tax() - price_excl_after_disc = variant._get_website_price_after_disc_and_tax() - discount = variant._get_website_disc(0) - tax = variant._get_website_tax() - # add price tiering for base price, discount, and price after discount (tier 1 - 3) - tier1 = variant._get_pricelist_tier1() - tier2 = variant._get_pricelist_tier2() - tier3 = variant._get_pricelist_tier3() - - if template.product_variant_count == 1: - price_excl = template.product_variant_id._get_website_price_exclude_tax() - discount = template.product_variant_id._get_website_disc(0) - price_excl_after_disc = template.product_variant_id._get_website_price_after_disc_and_tax() - tax = template.product_variant_id._get_website_tax() - flashsale_data = template.product_variant_id._get_flashsale_price() - tier1 = template.product_variant_id._get_pricelist_tier1() - tier2 = template.product_variant_id._get_pricelist_tier2() - tier3 = template.product_variant_id._get_pricelist_tier3() + variant_flashsale = variant._get_flashsale_price() + variant_flashsale_price = variant_flashsale.get('flashsale_price', 0) + flashsale_data_price = flashsale_data.get('flashsale_price', 0) + + if flashsale_data_price == 0 or (variant_flashsale_price != 0 and variant_flashsale_price < flashsale_data_price): + flashsale_data = variant_flashsale + + price_excl = variant._get_website_price_exclude_tax() + price_excl_after_disc = variant._get_website_price_after_disc_and_tax() + discount = variant._get_website_disc(0) + tax = variant._get_website_tax() + tier1 = variant._get_pricelist_tier1() + tier2 = variant._get_pricelist_tier2() + tier3 = variant._get_pricelist_tier3() - document = solr_model.get_doc('product', template.id) document.update({ 'id': template.id, 'flashsale_id_i': flashsale_data.get('flashsale_id', 0), -- cgit v1.2.3