The ERPNext Medusa Integration exports Item Price records from ERPNext to Medusa price lists, keeping the storefront’s displayed prices in sync with the ERP. This page covers how prices are created and updated in Medusa, how amounts are converted, how customer-specific negotiated prices work, and how the price visibility threshold controls what customers see.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.
How price sync is triggered
Avalidate hook on the Item Price doctype calls create_medusa_price_list() every time an Item Price record is saved:
Price amount conversion
Medusa stores prices in the smallest currency unit (e.g., fils for OMR, paise for INR). ERPNext stores prices as decimal values. The conversion multiplies by 1000:12.500 OMR becomes 12500 in the Medusa price list payload.
Creating a price list in Medusa
When an Item Price record without amedusa_id is saved, create_medusa_price_list() calls POST /admin/price-lists and stores the returned IDs:
medusa_id— the ID of the Medusa price list object.medusa_price_id— the ID of the individual price entry within the list.
Updating an existing price
When a price record already has amedusa_id (and get_doc_before_save() is available, indicating an actual edit), the function calls POST /admin/price-lists/{medusa_id} with only the price entry, using medusa_price_id to target the specific record:
Bulk sync: sync_missing_prices_to_medusa()
This function finds all Website Items that have a Medusa product (medusa_id set) and a variant (medusa_variant_id set), but whose Standard Selling Item Price record does not yet have a medusa_price_id. It creates a price list in Medusa for each such item.
It runs as part of the nightly cron at 0 1 * * *:
Fetch synced Website Items
Retrieves all Website Items that have both
medusa_id and medusa_variant_id set.Find unsynced Item Prices
Queries Item Prices where
price_list = 'Standard Selling', customer is empty, and medusa_price_id is not set. Builds a map of item_code → price_data.Storefront price endpoints
get_medusa_prices()
Returns standard and negotiated prices for a list of products, intended for the Medusa storefront cart or product detail pages. Parameters:| Parameter | Type | Description |
|---|---|---|
items | list | Array of {medusa_product_id} or {medusa_variant_id} objects |
price_list | string | ERPNext price list name (default: "Standard Selling") |
customer_id | string | Medusa customer ID; used to look up negotiated prices |
draft_order_id | string | Optional; if provided, also returns payment_url for the linked order |
item_code, fetches both the standard price and any customer-specific negotiated price, then applies the price_visibility_threshold before returning:
fetch_standard_price()
Internal utility used across multiple endpoints. Returns both the standard list price and any customer-specific negotiated price for a set of items:{item_code}-negotiated key in the result holds the customer-specific price. This allows callers to display negotiated prices to logged-in customers while showing the standard price to guests.
Price visibility threshold
Theprice_visibility_threshold is a field on the Homepage Landing singleton document (fetched as "Active Homepage Landing"). Any item whose standard price meets or exceeds this threshold has its displayed price set to 0, effectively hiding the price from the storefront.
get_medusa_prices(), get_website_items(), get_website_image(), and the homepage item fetch functions.
Standard vs. negotiated prices
| Price type | ERPNext source | Medusa usage |
|---|---|---|
| Standard price | Item Price with price_list = "Standard Selling" and no customer | Shown to all storefront users; hidden if above threshold |
| Negotiated price | Item Price with price_list = "Standard Selling" and customer set | Shown only to the specific logged-in customer |
medusa_id) and returned alongside the standard price in every price endpoint response.