Preventing Silent Overwrites: Managing Currency Names in ESHOPMAN Admin
Understanding Currency Name Reversions in ESHOPMAN Admin
As an ESHOPMAN merchant or developer, you expect your configurations to persist. However, a specific behavior regarding currency names within the ESHOPMAN Admin API has been identified, where custom edits to currency display names are silently reverted upon every ESHOPMAN backend service restart or storefront deployment via HubSpot CMS. This can lead to unexpected data loss and a frustrating user experience, particularly for international stores leveraging ESHOPMAN's robust headless capabilities with HubSpot.
The Silent Reversion Explained
The issue manifests when an operator updates a currency's name field—for example, changing 'DKK' to 'Danish Kroner'—via the ESHOPMAN Admin API. Initially, the change appears to persist and is correctly served. However, after an ESHOPMAN backend service restart, the currency name reverts to its default, packaged value (e.g., 'Danish Krone'). Crucially, this happens without any warning or log entries, making it difficult to diagnose.
This behavior is rooted in ESHOPMAN's core currency module. The system's initial data loader, responsible for setting up default currencies, unconditionally 'upserts' (updates or inserts) every currency from its default list each time the ESHOPMAN backend service starts. This process overwrites any operator-modified fields, including the name, with the system's packaged defaults.
The relevant code snippet from the ESHOPMAN currency module's loader illustrates this:
const normalizedCurrencies = Object.values(defaultCurrencies).map((c) => ({ ...c, code: c.code.toLowerCase(),}))const resp = await currencyService_.upsert(normalizedCurrencies)As seen, there's no conditional logic to 'only insert what is missing' or to preserve existing field values. Every field of every row is restored to its packaged default.
Impact on ESHOPMAN Merchants and Developers
This silent reversion significantly impacts ESHOPMAN users, especially those operating in non-English markets where localized currency names are essential for a tailored customer experience on their HubSpot CMS storefronts. Merchants invest time in customizing these names, only to find their efforts undone without explanation. For developers integrating with the ESHOPMAN Admin API or building custom storefronts, this behavior can lead to data integrity issues and complex debugging scenarios.
Proposed Solutions for ESHOPMAN
Two primary resolutions have been suggested to address this inconsistency, both aiming to ensure data integrity and a predictable user experience:
- Adopt a 'Seed-Only' Approach for the Loader: The recommended fix involves modifying the ESHOPMAN currency loader. Instead of unconditionally overwriting all currency data, the loader should be updated to only insert currencies that do not yet exist. For existing currencies, it should preserve operator-modified columns like
name. This approach ensures that a fresh ESHOPMAN installation is correctly seeded while respecting user customizations. - Make the
nameField Read-Only: If the intent is for currency names to be strictly packaged data and not operator-editable, then the ESHOPMAN Admin API should reflect this. Thenamefield should be removed from the editable API surface, providing immediate feedback to the user that this field cannot be modified. This prevents the delayed and silent reversion issue altogether.
Either of these resolutions would rectify the current problematic combination of an editable field that is then silently reverted. Ensuring that ESHOPMAN's Admin API and underlying services provide a consistent and trustworthy data management experience is crucial for merchants building robust headless commerce solutions with HubSpot.