Skip to content

eMAG Marketplace Feed ​

Flow ID: IN-05 | Module(s): feeds | Complexity: Low Last Updated: 2026-04-04

Business Overview ​

eMAG is a Romanian/Central European e-commerce marketplace. Unlike the Shopflix and Public integrations which include full order management, the eMAG integration is outbound product feed only -- there is no order reception or synchronization. The feed generates an XML product catalog that eMAG ingests to list products on their marketplace. The feed has several unique characteristics: negative-stock products are excluded entirely, numeric values are not wrapped in CDATA, prices are exported as net (without VAT), and descriptions are truncated to 250 characters.

API Reference ​

This integration does not use an API client. It exposes a single XML feed endpoint:

RouteControllerPurpose
/xml/emagAdvEmagXml::index()Product catalog XML feed

Authentication: Optional token-based protection via XML_FEEDS.EMAG_TOKEN query parameter.

Code Flow ​

Feed Generation ​

Entry point: AdvEmagXml::index()

AdvEmagXml::index()
  |-- secureXml()
  |     |-- Check XML_FEEDS.IS_ENABLED_EMAG
  |     |-- If IS_PROTECTED_EMAG, validate ?token= against EMAG_TOKEN
  |-- getProductData()
  |     |-- product_model::getFeedProductsForEmag()
  |     |     |-- Calls getFeedProducts(XML_FEEDS['EMAG']) with feed ID 13
  |     |-- getLiveProductsParsed() for real-time stock/price
  |     |-- mergeDataToProduct() for each product
  |-- parseForXml() inherited from AdvXml
  |     |-- parseItems() -> parseItem() per product
  |           |-- SKIP if availabilityStock < 0 (negative stock)
  |           |-- SKIP if no main image
  |           |-- Build item: Category, ID, Product_Name, Description, etc.
  |           |-- Net_Price = price_without_vat (+ modifier if CUSTOM_PRICE_EMAG)
  |-- OutputEmagXml::createXml()
        |-- Wraps in <Products><product>...</product></Products>
        |-- Numeric values: raw (no CDATA)
        |-- String values: wrapped in CDATA

XML Element Mapping ​

ElementSourceNotes
CategoryCategory breadcrumb&raquo; replaced with >
IDproduct->{xmlDbIdKey['emag']}Configured product ID field
Product_Nameskroutz_name or nameXML-sanitized
Descriptiondescription or skroutz_nameTruncated to 250 chars, HTML stripped
Product_linksite_url(productUrl)Full product URL
EANbarcodeEAN/barcode
StockavailabilityStockReal-time stock count
Pictures_linkMain product image URLFull asset URL
Brandvendor_nameManufacturer/brand
Net_Priceprice_without_vatPrice excluding VAT; optionally modified

Price Modifier ​

When XML_FEEDS.CUSTOM_PRICE_EMAG is enabled, the net price is adjusted:

Net_Price = price_without_vat + round(price_without_vat * priceModifier / 100, 2)

The priceModifier is a per-product percentage stored via the feed price modifier system (managed in Settings > XML Feeds).

Architecture ​

ecommercen/feeds/controllers/AdvEmagXml.php          -- Feed controller (extends AdvXml)
ecommercen/feeds/core/AdvXml.php                     -- Base XML feed class (extends Base_c)
src/Feeds/Output/OutputEmagXml.php                   -- XML output formatter (overrides addItem for CDATA logic)
src/Feeds/Output/OutputGenericXml.php                -- Base XML output class
src/Feeds/Output/OutputXmlConfig.php                 -- Config VO (collectionName='Products', collectionItemName='product')
src/Feeds/Feed.php                                   -- Feed orchestrator

Inheritance chain: AdvEmagXml extends AdvXml (base feed controller) extends Base_c (CI front controller). The OutputEmagXml class extends OutputGenericXml and overrides the addItem() method to conditionally apply CDATA wrapping based on value type.

Data Model ​

This integration does not have its own database tables. It reads from the standard product tables through the feed product query system:

SourcePurpose
shop_product + shop_product_muiProduct master data
product_codesSKU/barcode data
shop_product_barcodesEAN codes
shop_product_category_muiCategory breadcrumbs
shop_product_feedFeed assignment (feed ID = 13 for eMAG)
shop_product_feed_lpPer-product price modifiers

The feed ID constant is defined in application/config/constants.php:

php
'EMAG' => 13

Configuration ​

Registry Keys (XML_FEEDS group) ​

KeyTypePurpose
IS_ENABLED_EMAGintEnable/disable the eMAG feed
IS_PROTECTED_EMAGboolRequire token authentication
EMAG_TOKENstringAuthentication token (auto-generated if missing)
CUSTOM_PRICE_EMAGboolEnable custom price modifier
CUSTOM_PRICE_EMAG_MODIFIERfloatGlobal price modifier percentage

Product ID Key ​

The product identifier field is configured in application/config/app.php under xmlDbIdKey['emag']. This determines which product field maps to the <ID> XML element.

Feed URL ​

https://{domain}/xml/emag?token={EMAG_TOKEN}

Supports language prefix: /{lang}/xml/emag?token={EMAG_TOKEN}

Client Extension Points ​

  • Feed controller override: Create application/controllers/Xml.php with custom emag() method routing
  • Custom price modifiers: Per-product via admin product feed settings
  • Feed product assignment: Products must be assigned to feed ID 13 (eMAG) to appear
  • Product ID field: Configurable via xmlDbIdKey['emag'] in app config
  • Description source: Falls back from description to skroutz_name

Business Rules ​

RuleDescription
No negative stockProducts with availabilityStock < 0 are excluded entirely (not zero-stocked)
No image = excludedProducts without a main image are skipped
250 char descriptionDescription truncated to 250 characters after HTML stripping
Net price (no VAT)Net_Price field exports price_without_vat, not the retail price
Numeric = no CDATANumeric fields rendered as raw values; strings get CDATA wrapping
Feed-only integrationNo order sync, no webhooks, no background jobs
Token auto-generationIf EMAG_TOKEN is not set, a unique token is auto-generated on first settings save
Custom price additivePrice modifier adds a percentage to base price (not multiplicative)