From 890be59e4dadafc6e25651fcb9de20e2b24379cc Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Sep 2023 15:43:52 +0700 Subject: Sync to solr product variant solr flag 2, Sync to solr product template solr flag 2 --- indoteknik_custom/models/solr/product_product.py | 9 ++++++++- indoteknik_custom/models/solr/product_template.py | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py index a3bd3d04..23ab51fd 100644 --- a/indoteknik_custom/models/solr/product_product.py +++ b/indoteknik_custom/models/solr/product_product.py @@ -20,6 +20,13 @@ class ProductProduct(models.Model): products = self.search([('id', 'in', product_ids)]) for product in products: product.product_tmpl_id._create_solr_queue('_sync_product_template_to_solr') + + def variant_solr_flag_to_solr(self, limit=500): + variant_products = self.search([('solr_flag', '=', 2)], limit=limit) + if variant_products: + for product in variant_products: + product._create_solr_queue('_sync_price_to_solr') + product.solr_flag = 1 def _sync_variants_to_solr(self): solr_model = self.env['apache.solr'] @@ -62,7 +69,7 @@ class ProductProduct(models.Model): variant.change_solr_data('Perubahan pada data product') self.solr().commit() - + def _sync_price_to_solr(self): solr_model = self.env['apache.solr'] diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py index b93d0a4f..9d714713 100644 --- a/indoteknik_custom/models/solr/product_template.py +++ b/indoteknik_custom/models/solr/product_template.py @@ -35,6 +35,13 @@ class ProductTemplate(models.Model): template_ids = self.env.context.get('active_ids', []) templates = self.search([('id', 'in', template_ids)]) templates._create_solr_queue('_sync_product_template_to_solr') + + def solr_flag_to_solr(self, limit=500): + template_products = self.search([('solr_flag', '=', 2)], limit=limit) + if template_products: + for product in template_products: + product._create_solr_queue('_sync_price_to_solr') + product.solr_flag = 1 def _sync_active_template_solr(self): for template in self: -- cgit v1.2.3