diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-16 17:16:26 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-16 17:16:26 +0700 |
| commit | 8c4bf3e27b2491955a3f94fa3f3478da6d23fea2 (patch) | |
| tree | 996f2353884e17ab9ea82d1873af910446f2ea55 /indoteknik_custom/models/solr | |
| parent | be39266e634e750c553fe004a067dd1b8024dfc4 (diff) | |
<iman> update tampilan untuk category management
Diffstat (limited to 'indoteknik_custom/models/solr')
| -rw-r--r-- | indoteknik_custom/models/solr/website_categories_homepage.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/indoteknik_custom/models/solr/website_categories_homepage.py b/indoteknik_custom/models/solr/website_categories_homepage.py index 75d84e73..70c7860d 100644 --- a/indoteknik_custom/models/solr/website_categories_homepage.py +++ b/indoteknik_custom/models/solr/website_categories_homepage.py @@ -2,6 +2,10 @@ from odoo import models, fields, api from datetime import datetime import json +import logging + +_logger = logging.getLogger(__name__) + class WebsiteCategoriesHomepage(models.Model): _inherit = 'website.categories.homepage' @@ -56,6 +60,15 @@ class WebsiteCategoriesHomepage(models.Model): for category in self: if category.status == 'tidak_tayang': continue + + category_id2_data = [ + { + x.id: { + 'child_frontend_id_i': [child.id for child in x.child_frontend_id] + } + } + for x in category.category_id2 + ] document = solr_model.get_doc('product_category_homepage', category.id) document.update({ @@ -65,12 +78,13 @@ class WebsiteCategoriesHomepage(models.Model): 'image_s': self.env['ir.attachment'].api_image('website.categories.homepage', 'image', category.id), 'sequence_i': category.sequence or '', 'url_s': category.url or '', - 'product_ids': [x.id for x in category.product_ids] + 'category_id2': category_id2_data, }) - self.solr().add([document]) - category.update_last_update_solr() + _logger.info('Category %s synchronized to Solr with document: %s', category.id, json.dumps(document)) + # self.solr().add([document]) + # category.update_last_update_solr() - self.solr().commit() + # self.solr().commit() # def _sync_delete_solr(self): # for rec in self: |
