1) Add Celery shared_task decorator to `update_stock` method for asynchronous execution.
Fixes:
1) Replace direct `update_stock()` calls with `update_stock.delay()` to enable task queuing.
Extra:
1) Add missing import for `shared_task` in `core/vendors/__init__.py`.
Improve handling of duplicate and inactive objects during category and brand resolution. Ensures only the most relevant entry is retained while unused duplicates are deleted. Fixes potential issues with object retrieval and creation logic.
Replaced context manager suppress(KeyError) with try-except blocks to handle both KeyError and IndexError in auto_resolve_category and auto_resolve_brand methods. This improves clarity and ensures proper handling of potential IndexError cases.
Add error handling during the stock update process to log and skip problematic vendors without halting execution. Additionally, ensure `get_vendor_instance` only returns active vendors, raising an error if the vendor is inactive. This improves system resilience and data integrity.
Introduced a new static method, auto_resolve_brand, to simplify and automate the resolution or creation of Brand objects based on a given brand name. Updated imports in core/vendors/__init__.py to include the Brand model. This enhances the system's ability to process brands effectively.
Introduced the auto_resolve_category method to streamline category resolution using Elasticsearch. This enhances category lookup efficiency and ensures seamless creation or retrieval of categories when necessary.