From 0ad377114ba088982edf4a56cc1725393864d1da Mon Sep 17 00:00:00 2001 From: thekiwismarthome <134335563+thekiwismarthome@users.noreply.github.com> Date: Sat, 14 Feb 2026 07:29:27 +1300 Subject: [PATCH] Update storage.py --- custom_components/shopping_list_manager/storage.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/custom_components/shopping_list_manager/storage.py b/custom_components/shopping_list_manager/storage.py index bb2adc1..d55734a 100644 --- a/custom_components/shopping_list_manager/storage.py +++ b/custom_components/shopping_list_manager/storage.py @@ -141,7 +141,15 @@ class ShoppingListStorage: await self._save_products() _LOGGER.info("Successfully imported %d products from catalog", len(self._products)) - +# Initialize search engine after products are loaded + if self._products: + products_dict = {pid: p.to_dict() for pid, p in self._products.items()} + self._search_engine = ProductSearch(products_dict) + _LOGGER.debug("Initialized product search engine with %d products", len(self._products)) + else: + self._search_engine = None + _LOGGER.warning("No products loaded, search engine not initialized") + # Lists methods async def _save_lists(self) -> None: """Save lists to storage."""