summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2024-06-18 16:27:52 +0700
committerstephanchrst <stephanchrst@gmail.com>2024-06-18 16:27:52 +0700
commit2ca257f21bd5087604e3d0110eff16e40b0d8f83 (patch)
treed4becd6449987a10a8b73bb461d727001df80a60
parentacca01df9c8f8ac22551d02d80d93dd00362f993 (diff)
bf
-rw-r--r--indoteknik_custom/models/solr/apache_solr.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/indoteknik_custom/models/solr/apache_solr.py b/indoteknik_custom/models/solr/apache_solr.py
index d25b5fd6..0b1bd821 100644
--- a/indoteknik_custom/models/solr/apache_solr.py
+++ b/indoteknik_custom/models/solr/apache_solr.py
@@ -295,6 +295,7 @@ class ApacheSolr(models.Model):
def _solr_sync_recommendation(self, limit=100):
variants = self.env['product.product'].search([('solr_flag', '=', 2)], limit=limit)
+ documents = []
document = {}
for variant in variants:
if variant.product_tmpl_id: # Check if product_tmpl_id exists
@@ -310,7 +311,9 @@ class ApacheSolr(models.Model):
'type_s': variant.product_tmpl_id.type or ''
}
variant.write({'solr_flag': 1}) # Ensure the flag is updated correctly
- _recommendation_solr.add(document)
+ documents.append(document)
except Exception as e:
_logger.error("Failed to add document to Solr: %s", e)
_logger.error("Document data: %s", document)
+ _recommendation_solr.add(documents)
+ return True