summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/solr/product_template.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-09-13 14:49:13 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-09-13 14:49:13 +0700
commit4cfc5c3214cc6060f978bc9e1f52533899330ee2 (patch)
tree129c9f52f41604675ce3d630e6fe3045cdd15ff6 /indoteknik_custom/models/solr/product_template.py
parent7c67529ed27e32d32a6ddc4cd3fe296ce0d7bca2 (diff)
Update product and variant sync flashsale data
Diffstat (limited to 'indoteknik_custom/models/solr/product_template.py')
-rw-r--r--indoteknik_custom/models/solr/product_template.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index 3470621e..ea976359 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -91,10 +91,11 @@ class ProductTemplate(models.Model):
"variants_code_t": variant_codes,
"search_rank_i": template.search_rank,
"search_rank_weekly_i": template.search_rank_weekly,
- 'has_product_info_b': True,
"category_id_i": category_id,
"category_name_s": category_name,
- "category_name": category_name
+ "category_name": category_name,
+ "description_t": template.website_description or '',
+ 'has_product_info_b': True,
})
self.solr().add(docs=[document], softCommit=True)
@@ -106,13 +107,8 @@ class ProductTemplate(models.Model):
def _sync_price_to_solr(self):
solr_model = self.env['apache.solr']
- solr = self.solr()
for template in self:
- document = {
- "id": template.id,
- "has_price_info_b": True
- }
flashsale_data = {}
for variant in template.product_variant_ids:
@@ -133,9 +129,12 @@ class ProductTemplate(models.Model):
document = solr_model.get_doc('product', template.id)
document.update({
+ "id": template.id,
"flashsale_id_i": flashsale_data.get('flashsale_id', 0),
"flashsale_tag_s": flashsale_data.get('flashsale_tag', ''),
"flashsale_name_s": flashsale_data.get('flashsale_name', ''),
+ "flashsale_start_date_s": flashsale_data.get('flashsale_start_date', ''),
+ "flashsale_end_date_s": flashsale_data.get('flashsale_end_date', ''),
"flashsale_base_price_f": flashsale_data.get('flashsale_base_price', 0),
"flashsale_discount_f": flashsale_data.get('flashsale_discount', 0),
"flashsale_price_f": flashsale_data.get('flashsale_price', 0),
@@ -149,6 +148,7 @@ class ProductTemplate(models.Model):
"price_tier2_f": tier2.get('price_tier2', 0),
"discount_tier3_f": tier3.get('discount_tier3', 0),
"price_tier3_f": tier3.get('price_tier3', 0),
+ "has_price_info_b": True
})
self.solr().add(docs=[document], softCommit=True)