Example use case of Cataloglake
1. Create Cataloglake
First step is to create a Cataloglake in which we can store the products
# Initialize Groclake catalog instance
cataloglake = CatalogLake()
groclake_catalog = cataloglake.create()
print("catalog_create----", groclake_catalog)
Output
catalog_create---- {'cataloglake_id': '2739542733'}
2. Generate product data using image
Here as an example we take an image of the product using a image url and then generate a metadada rich product using the image only We can also take a local image and use the base64 encoded format of that image
product_create_request = {
"product_name_hint": "Nightsuit Shirt And Pants",
"category_name_hint": "Nightsuit",
"provider_name_hint": "Breathables",
"images": [
{
"image_name": "Nightsuit image",
"image_url": "https://cdnaz.plotch.io/image/upload/C/V/PLOVqkPpi21729804127_df022e0a1fe58015a2c80ed0229cc5d1735c5812de5d9218b030c0c6414a457d.png?product_id=1153906002&s=1"
}
]
}
groclake_create_product = cataloglake.gen(product_create_request)
print("gen data", groclake_create_product)
Output
gen data {'ai_product_name': 'Breathables Red Plaid Cotton Nightsuit for Women', 'allergen_in
3. Fetch products from cataloglake
Now we can fetch the products from cataloglake. We can use multiple filters to fetch or no filters to fetch all which is controlled by page_size (number of products to fetch) and page_number (which is used to move to next page)
product_fetch_request = {
"groc_item_id": "",
"groc_category": "",
"is_in_stock": "",
"page_size": "20",
"page_number": "1"
}
catalog_fetch_product = cataloglake.fetch(product_fetch_request)
print("catalog_fetch_data----", catalog_fetch_product)
Output
catalog_fetch_data---- {'catalog_fetch_request_id': '1e1c5642-594d-488d-9481-3f5ac376248c', '
4. Cache products in cataloglake
Now to enable search and recommendation operations on cataloglake, we need to cache index the products stored in cataloglake. This caching helps in reducing latency of search results and build conversational capabilities on your catalog
product_cache_request = {
"groc_item_id": ["2147483647"]
}
catalog_cache_product = cataloglake.cache(product_cache_request)
print("catalog_cache_data----", catalog_cache_product)
Output
{
"catalog_cache_request_id": "0b6f7624-f176-461a-828b-1ba9bf3d56ac"
}
5. Search products in cataloglake
Now suppose you want to search for a product like a "Belt" in the catalog using semantic search. Here's how you can do it:
product_search_request = {
"query":"Belt",
"search_type": "semantic",
"image_url": "",
"price": 0,
"image_bytes": ""
}
catalog_search_product = cataloglake.search(product_search_request)
print("catalog_search_data----", catalog_search_product)
Output
# {
#
# "items": [
# {
# "product_name": "Loopa - Black PU Men's Casual Belt ( Pack of 1 ) -",
# "product_id": 1851175867,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "https://cdnaz.plotch.io/image/upload/C/V/PLOc0HAn3P1732004167_6d102fa9d8c248c694b99bb33223f074848766330b21b5c189f48d1aadff62d6.png",
# "image_link2": "https://cdnaz.plotch.io/image/upload/C/V/PLOhVIHomh1732004169_8e170aa06a1aaeda0e6ff066c00fba14032e6825e7f89dc78d3716254c6215e3.png",
# "image_link3": "https://cdnaz.plotch.io/image/upload/C/V/PLOW3Pp0B81732004172_ef9c65e70824487cadae221e2225ae79fc70b7acbc0a04ce4c8e3c94ec637a21.png",
# "product_url": "",
# "brand": "",
# "category_name": "Belts",
# "price": 599.0,
# "sale_price": 599.0,
# "rating": "",
# "weight": "0",
# "score": 1.4819418
# },
# {
# "product_name": "Loopa - Black PU Men's Casual Belt ( Pack of 1 ) -",
# "product_id": 1169020518,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "https://cdnaz.plotch.io/image/upload/C/V/PLOWysQaul1732007566_6d102fa9d8c248c694b99bb33223f074848766330b21b5c189f48d1aadff62d6.png",
# "image_link2": "https://cdnaz.plotch.io/image/upload/C/V/PLOYnjqZrk1732007566_8e170aa06a1aaeda0e6ff066c00fba14032e6825e7f89dc78d3716254c6215e3.png",
# "image_link3": "https://cdnaz.plotch.io/image/upload/C/V/PLOqbI8GBo1732007567_ef9c65e70824487cadae221e2225ae79fc70b7acbc0a04ce4c8e3c94ec637a21.png",
# "product_url": "",
# "brand": "",
# "category_name": "Belts",
# "price": 599.0,
# "sale_price": 599.0,
# "rating": "",
# "weight": "0",
# "score": 1.4819418
# },
# {
# "product_name": "SILKSHOPPING - Black Synthetic Men's Casual Belt (",
# "product_id": 2131791766,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "https://cdnaz.plotch.io/image/upload/C/V/PLODg8I4RQ1732004177_d1861c3c0b0470290a162d547e1f915c3ee50117d22bcd919f32bc866aaa4f13.png",
# "image_link2": "https://cdnaz.plotch.io/image/upload/C/V/PLO9gr0bmU1732004178_2f1ae7d12dc6b4036de63cbcf5ccf052e0ac1b0044c22382e7f5b23b5874f78f.png",
# "image_link3": "https://cdnaz.plotch.io/image/upload/C/V/PLOSTCdoda1732004180_d9d457100f6f3a90d63f2dab1205fdba2f7caed695f65afd57aff6cf27b72323.png",
# "product_url": "",
# "brand": "",
# "category_name": "Belts",
# "price": 599.0,
# "sale_price": 599.0,
# "rating": "",
# "weight": "0",
# "score": 1.4800572
# },
# {
# "product_name": "EMPERO - Black PU Analog Mens Watch",
# "product_id": 2324575804,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "",
# "image_link2": "",
# "image_link3": "",
# "product_url": "",
# "brand": "",
# "category_name": "Watches",
# "price": 599.0,
# "sale_price": 599.0,
# "rating": "",
# "weight": "0",
# "score": 1.3512266
# },
# {
# "product_name": "Sambhav Deals - Tan PU Mens Regular Wallet ( Pack ",
# "product_id": 2531836235,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "",
# "image_link2": "",
# "image_link3": "",
# "product_url": "",
# "brand": "",
# "category_name": "Handbags",
# "price": 1299.0,
# "sale_price": 1299.0,
# "rating": "",
# "weight": "0",
# "score": 1.3334281
# },
# {
# "product_name": "Saleh Silicone Shower Bath Belt Back Scrubber Brus",
# "product_id": 1440714048,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "",
# "image_link2": "",
# "image_link3": "",
# "product_url": "",
# "brand": "",
# "category_name": "Body Care - Bath Salt and Additives",
# "price": 799.0,
# "sale_price": 799.0,
# "rating": "",
# "weight": "0",
# "score": 1.3296758
# },
# {
# "product_name": "Fitmonkey - Best Sports Biker Face Cover Balaclava",
# "product_id": 2092570718,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "https://cdnaz.plotch.io/image/upload/C/V/PLO77Cq8Al1732004200_94eef0f8765f1bbb188610ab1a2852f2bf8dfc243efaa0aadfe2fe1983888b56.png",
# "image_link2": "https://cdnaz.plotch.io/image/upload/C/V/PLOvgiFTkO1732004201_c5124874f0354ec91995bf65eba476c58907a845eb404232feb42bcab0c9f1d2.png",
# "image_link3": "https://cdnaz.plotch.io/image/upload/C/V/PLOMmezVly1732004202_3396a074569bf55e01066eb0fd4241c65b12503c7e6835d81b0e5409ecf0f178.png",
# "product_url": "",
# "brand": "",
# "category_name": "Home Decor",
# "price": 499.0,
# "sale_price": 499.0,
# "rating": "",
# "weight": "0",
# "score": 1.3133097
# },
# {
# "product_name": "Fitmonkey - Best Sports Biker Face Cover Balaclava",
# "product_id": 2553890008,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "",
# "image_link2": "",
# "image_link3": "",
# "product_url": "",
# "brand": "",
# "category_name": "Home Improvement",
# "price": 699.0,
# "sale_price": 699.0,
# "rating": "",
# "weight": "0",
# "score": 1.2975796
# },
# {
# "product_name": "PrettyKrafts Shirt Stacker Closet Organizer - Shir",
# "product_id": 1598314842,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "",
# "image_link2": "",
# "image_link3": "",
# "product_url": "",
# "brand": "",
# "category_name": "Closet/Laundry/Shoe Organization",
# "price": 599.0,
# "sale_price": 599.0,
# "rating": "",
# "weight": "0",
# "score": 1.2704629
# },
# {
# "product_name": "Hauser Aerox Ball Pen Blue Pack Of 10",
# "product_id": 2237403527,
# "provider_id": "",
# "provider_url": "",
# "image_link1": "https://cdnaz.plotch.io/image/upload/C/V/PLOSvSir6p1732004215_d8bed3aa82dc495c5a7e6be66ca162e31535b843be99eba2d199999e17844f2d.png",
# "image_link2": "https://cdnaz.plotch.io/image/upload/C/V/PLOaoRPuAz1732004217_cd54112879bb8c27a947b3a30f63c1eff068bf0e7f1960c78e7ebed6d4e6435f.png",
# "image_link3": "https://cdnaz.plotch.io/image/upload/C/V/PLOYD7OzL91732004218_04385520a918d24296d13f9585f2a8af11595f236ca870d077b2da65e7de0b02.png",
# "product_url": "",
# "brand": "",
# "category_name": "Stationery",
# "price": 100.0,
# "sale_price": 100.0,
# "rating": "",
# "weight": "0",
# "score": 1.2699537
# }
# ],
# "app_action": {
# "action_intent": "search",
# "items": []
# },
# "search_id": "365914f1-afe9-4d09-8526-2e4e3df82a14"
# }
6. Build Recommendation Systems in Cataloglake
You want to recommend similar products based on a specific item, like "Headphone," to improve user engagement or offer alternatives in an e-commerce catalog.
product_search_request = {
"cataloglake_id": "groclake_products_81skstvyw3",
"product_name":"Headphone",
"num_items":"1",
"filters":{}
}
catalog_search_product = cataloglake.search(product_search_request)
print("catalog_search_data----", catalog_search_product)
Output
# {
# "items": [
# {
# "product_name": "Foxin 306 Big Bass Wired Headphone Headphone Foxin ",
# "product_id": 2116465766.0,
# "provider_id": "27086",
# "provider_url": "",
# "image_link1": "",
# "image_link2": "",
# "image_link3": "",
# "product_url": "",
# "brand": "",
# "category_name": "Headphone",
# "price": 1500.0,
# "sale_price": 599.0,
# "rating": "",
# "weight": "0",
# "score": 1.5418848
# }
# ]
# }
7. Push Products to Shopify
Cataloglake allows products housed there to be pushed to platforms like Shopify
List item
List item
product_push_request = {
"shopify_store_name": "cartesian-sample-test",
"shopify_access_token": "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",
"groc_item_id": ["3548221525"]
}
catalog_send = cataloglake.send(product_push_request)
print("catalog_send----", catalog_send)
Output
# {
# "shopify_product_id": [
# "gid://shopify/Product/7340319801434"
# ]
# }
8. Deleting items from catalog
Suppose your e-commerce platform no longer offers a product, and you need to remove it from the catalog to ensure the inventory remains current. Using catalog.delete()
, you can seamlessly delete the item by specifying its groc_item_id
.
item_object = {
"items": [
{
"groc_item_id": "1698596981"
}
]
}
catalog_delete = catalog.delete(item_object)
print("catalog_delete_data----", catalog_delete)
Output
# {
# "status": "Items deleted successfully"
# }
Last updated