From 8b1396a5dce2c6a6756c0204c1f32a1c9755d72c Mon Sep 17 00:00:00 2001 From: hejl Date: Sun, 31 Dec 2023 11:28:21 +0800 Subject: [PATCH] fix the search result page product img display --- flaskshop/public/search.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flaskshop/public/search.py b/flaskshop/public/search.py index 647709ff..11306466 100644 --- a/flaskshop/public/search.py +++ b/flaskshop/public/search.py @@ -5,6 +5,7 @@ from flask_sqlalchemy.pagination import Pagination from flaskshop.settings import Config +from flaskshop.product.models import ProductImage if Config.USE_ES: connections.create_connection(hosts=Config.ES_HOSTS) @@ -88,7 +89,6 @@ def bulk_update(cls, items, chunk_size=5000, op_type="update", **kwargs): @classmethod def get_es(cls): - # search = cls.search() return connections.get_connection() @classmethod @@ -109,6 +109,8 @@ def __init__(self, page, per_page, **kwargs): super().__init__(page, per_page, **kwargs) def _query_items(self): + for item in self.rs: + item.first_img = ProductImage.query.filter(ProductImage.product_id == item.id).first() return self.rs def _query_count(self):