Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/aerele/medusa_integration/llms.txt

Use this file to discover all available pages before exploring further.

This page documents the endpoints that power the storefront homepage: the hero section, the navigation bar, and the top-selling products carousel for each product category. All content is managed in ERPNext under Medusa Integration → Homepage Landing → “Active Homepage Landing”.

GET get homepage top section

GET /api/method/medusa_integration.api.get_homepage_top_section Returns the hero/top section content from the active Homepage Landing document. Each entry is either an Item Group with sub-categories or a Brand with associated product categories. No request parameters.

Response

Array of entry objects. The shape varies by type.
type
string
"Item Group" or "Brand".
title
string
Name of the Item Group or Brand.
thumbnail
string
Absolute URL of the attached image. null if none.
url
string
custom_medusa_route of the Item Group. Only present on "Item Group" entries.
sub_categories
array
First-level child Item Groups with their routes. Only present on "Item Group" entries.
categories
array
Item Groups that carry products from this brand. Only present on "Brand" entries.
Content is managed in ERPNext via Homepage Landing → Active Homepage Landing → top_section child table.

Example

curl 'https://your-erpnext.example.com/api/method/medusa_integration.api.get_homepage_top_section'
Response
[
  {
    "type": "Item Group",
    "title": "Dental",
    "thumbnail": "https://your-erpnext.example.com/files/dental-hero.png",
    "url": "products/dental",
    "sub_categories": [
      { "title": "Dental Equipment", "url": "products/dental/dental-equipment" },
      { "title": "Consumables", "url": "products/dental/consumables" }
    ]
  },
  {
    "type": "Brand",
    "title": "Dentsply",
    "thumbnail": "https://your-erpnext.example.com/files/dentsply-logo.png",
    "categories": [
      { "name": "Dental Equipment", "url": "products/dental/dental-equipment" }
    ]
  }
]

GET get homepage menu section

GET /api/method/medusa_integration.api.get_homepage_menu_section Returns the navigation bar entries from the active Homepage Landing document. Only Item Group entries are included; Brand entries are ignored. No request parameters.

Response

Array of menu link objects.
title
string
Item Group name, used as the menu label.
url
string
custom_medusa_route of the Item Group.
Content is managed in ERPNext via Homepage Landing → Active Homepage Landing → menu_section child table.

Example

curl 'https://your-erpnext.example.com/api/method/medusa_integration.api.get_homepage_menu_section'
Response
[
  { "title": "Dental", "url": "products/dental" },
  { "title": "Medical", "url": "products/medical" },
  { "title": "Infection Control", "url": "products/infection-control" },
  { "title": "Medical Laboratory IVD", "url": "products/medical-laboratory-ivd" }
]

POST fetch relevant collection products

POST /api/method/medusa_integration.api.fetch_relevant_collection_products Returns pre-computed top-selling products for the top-level collection that contains the given item_group. Use this endpoint to populate “Top Products” carousels on the homepage or category pages.

Request body

item_group
string
required
ERPNext Item Group name. The endpoint resolves this to one of the four supported top-level collections: Dental, Medical, Infection Control, or Medical Laboratory IVD.

Response

top_collection
string
The resolved top-level collection name: "Dental", "Medical", "Infection Control", or "Medical Laboratory IVD".
products
array
Top-selling products for the collection, sorted by sales_count descending.
Product data comes from the Product Collection doctype, which is refreshed nightly by the add_top_selling_items_to_collection scheduled task. The response reflects the state of the last nightly run, not real-time invoice data.

Example

curl --request POST \
  --url 'https://your-erpnext.example.com/api/method/medusa_integration.api.fetch_relevant_collection_products' \
  --header 'Content-Type: application/json' \
  --data '{"item_group": "Dental Equipment"}'
Response
{
  "top_collection": "Dental",
  "products": [
    {
      "product_id": "prod_01ABCDEF",
      "item_code": "DENT-001",
      "variant_id": "variant_01ABCDEF",
      "title": "Pro Dental Scaler",
      "item_group": "Dental Equipment",
      "thumbnail": "https://your-erpnext.example.com/files/scaler.jpg",
      "rating": 4.5,
      "is_wishlisted": 0,
      "has_variants": 0,
      "standard_price": 125.0,
      "negotiated_price": 0,
      "sales_count": 320
    }
  ]
}

POST add top selling items to collection

POST /api/method/medusa_integration.api.add_top_selling_items_to_collection Recalculates the top-selling items for each category and updates the Product Collection singleton doctype. This endpoint requires authentication. This endpoint is also executed automatically on the nightly cron schedule defined in hooks.py (0 1 * * *). Call it manually to force an immediate refresh without waiting for the scheduled run. No request parameters.

How it works

For each of the four categories — Dental, Medical, Infection Control, and Medical Laboratory IVD — the endpoint:
  1. Finds all Item Groups in the full hierarchy under that category name.
  2. Queries Sales Invoice Item records from submitted invoices for items in those groups.
  3. Groups by item_code and sums quantities to determine total units sold.
  4. Selects the top 20 items by total quantity.
  5. Replaces the corresponding child table on the Product Collection doctype.

Response

status
string
"success" on completion, "error" if an exception occurred.
message
string
Human-readable result message.
curl --request POST \
  --url 'https://your-erpnext.example.com/api/method/medusa_integration.api.add_top_selling_items_to_collection' \
  --header 'Authorization: token api_key:api_secret'
Response
{
  "status": "success",
  "message": "Top-selling products updated successfully."
}

Build docs developers (and LLMs) love