diff options
Diffstat (limited to 'indoteknik_custom/models/solr')
| -rw-r--r-- | indoteknik_custom/models/solr/product_template.py | 42 |
1 files changed, 16 insertions, 26 deletions
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), |
