Skip to content

Commit

Permalink
fix the search result page product img display
Browse files Browse the repository at this point in the history
  • Loading branch information
hjlarry committed Dec 31, 2023
1 parent 39f8108 commit 8b1396a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flaskshop/public/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 8b1396a

Please sign in to comment.