from MongoDBConnection import db

products_collection = db["products"]


class ProductCatalogModel:
    @staticmethod
    def get_product_catalog_map():
        catalog = {}

        cursor = products_collection.find(
            {},
            {
                "_id": 0,
                "productId": 1,
                "title": 1,
            }
        )

        for product in cursor:
            product_id = str(product.get("productId") or "").strip()
            title = str(product.get("title") or "").strip()

            if product_id:
                catalog[product_id] = title or product_id

        return catalog