Search by

zdenekgebauer / heureka-cz-feed

zdenekgebauer

Create product XML feed for Heureka.cz

Package info

github.com/zdenekgebauer/heureka-cz-feed

pkg:composer/zdenekgebauer/heureka-cz-feed

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-12-01 17:40 UTC

This package is auto-updated.

Last update: 2026-12-01 17:45:55 UTC


README

Create the product XML feed for Heureka.cz and Heureka.sk by the specifications
https://sluzby.heureka.cz/napoveda/xml-feed/
https://sluzby.heureka.sk/napoveda/xml-feed/

Both feeds have the same format. Prices are in CZK for heureka.cz and in EUR for heureka.sk, and each has its own list of carriers (DeliveryIdCz, DeliveryIdSk).

Requirements

  • PHP 8.4 or newer
  • ext-libxml, ext-mbstring, ext-xmlreader and ext-xmlwriter

No runtime dependencies beyond that.

Installation

composer require zdenekgebauer/heureka-cz-feed

Usage

use ZdenekGebauer\HeurekaCzFeed\Delivery;
use ZdenekGebauer\HeurekaCzFeed\DeliveryDate;
use ZdenekGebauer\HeurekaCzFeed\DeliveryIdCz;
use ZdenekGebauer\HeurekaCzFeed\ExtendedWarranty;
use ZdenekGebauer\HeurekaCzFeed\Feed;
use ZdenekGebauer\HeurekaCzFeed\Gift;
use ZdenekGebauer\HeurekaCzFeed\ItemType;
use ZdenekGebauer\HeurekaCzFeed\Param;
use ZdenekGebauer\HeurekaCzFeed\SalesVoucher;
use ZdenekGebauer\HeurekaCzFeed\ShopItem;

$feed = new Feed();
// truncates the file; items are appended to it in batches, so the whole feed never sits in memory
$feed->open('/path/to/heureka.xml');

// required values
$item = new ShopItem(
    itemId: 'SKU-123',
    productName: 'Samsung Galaxy S25 128 GB černý',
    url: 'https://example.org/samsung-galaxy-s25',
    priceVat: 19990.0,
);

// optional values
$item->product = 'Samsung Galaxy S25 128 GB černý';
$item->description = 'Telefon s displejem 6,2"';
$item->imgUrl = 'https://example.org/img/s25.jpg';
$item->addImgUrlAlternative('https://example.org/img/s25-back.jpg');
$item->vat = 21;
$item->itemType = ItemType::BAZAR;
$item->heurekaCpc = 5.8;
$item->manufacturer = 'Samsung';
$item->manufacturerPostalAddress = 'Samsung Electronics Czech and Slovak, V Parku 2343/24, 148 00 Praha';
$item->manufacturerElectronicAddress = 'https://www.samsung.com/cz/info/contactus/';
$item->categoryText = 'Heureka.cz | Elektronika | Mobilní telefony';
$item->ean = '8806095000000';
$item->productNo = 'SM-S931B';
$item->addParam(new Param('Barva', 'černá'));
$item->deliveryDate = DeliveryDate::inStock();
$item->addDelivery(new Delivery(DeliveryIdCz::PPL, 99.0, 129.0));
$item->addDelivery(new Delivery(DeliveryIdCz::ZASILKOVNA, 79.0));
$item->addAccessoryId('SKU-456');
$item->addGift(new Gift('Pouzdro', 'GIFT-1'));
$item->extendedWarranty = new ExtendedWarranty(36, 'Prodloužená záruka na 3 roky');
$item->addSpecialService('Instalace aplikací zdarma');
$item->addSalesVoucher(new SalesVoucher('SLEVA10', 'Sleva 10 % na celý nákup'));

$feed->add($item);
// ...add more items

$feed->close();

For heureka.sk give the prices in EUR and the carriers from DeliveryIdSk:

$item->addDelivery(new Delivery(DeliveryIdSk::PACKETA, 2.9, 3.9));

Delivery date

Value DELIVERY_DATE Meaning
DeliveryDate::inStock() 0 in stock
DeliveryDate::days(5) 5 can be handed over within the given number of days
DeliveryDate::onDate($date) 2026-12-24 pre-order of a product not released yet
null (default) omitted availability is shown in the shop

Categories

Categories::parse() reads the category tree published at https://www.heureka.cz/direct/xml-export/shops/heureka-sekce.xml (or https://www.heureka.sk/direct/xml-export/shops/heureka-sekce.xml; download it first) and yields the ID and full path of every leaf category, a value for CATEGORYTEXT:

use ZdenekGebauer\HeurekaCzFeed\Categories;

foreach (new Categories()->parse('/path/to/heureka-sekce.xml') as $id => $categoryText) {
    // 1486 => 'Heureka.cz | Auto-moto | Auta'
}

The trees of heureka.cz and heureka.sk are not the same. The IDs are shared — one ID is the same category at the same place in both trees — but the full paths are in the language of the country (1486 => 'Heureka.sk | Auto-moto | Automobily') and some categories exist in one country only. Use the file of the target country for CATEGORYTEXT; a mapping of shop categories to Heureka IDs works for both countries.

Errors

Feed::add() validates the item before it writes anything and throws InvalidArgumentException when

  • productName is empty
  • priceVat is not greater than zero, heurekaCpc is set but not greater than zero (Heureka asks to omit a zero bid), vat is negative, or any of them is not finite
  • itemId, an accessory ID or a gift ID is not 1-36 characters A-Z a-z 0-9 _ - /; itemGroupId is not 1-36 characters A-Z a-z 0-9 _ -
  • url, imgUrl or an alternative image URL does not start with http:// or https://, contains whitespace, control or non-ASCII characters (percent-encode each path segment, e.g. with rawurlencode()), or is longer than 300 (url) or 255 characters (images)

Further InvalidArgumentExceptions:

Thrown by When
Delivery::__construct() a price is negative or not finite
DeliveryDate::days() the number of days is negative
ExtendedWarranty::__construct() months are not greater than zero or the description is empty
Gift::__construct() the name is empty
SalesVoucher::__construct() the code is empty
ShopItem::addAccessoryId() more than 10 accessories
ShopItem::addSpecialService() more than 5 special services (Heureka would ignore all of them)

Feed::add() and Feed::close() throw LogicException when open() was not called. Categories::parse() throws RuntimeException when the file is missing or is not well-formed XML.

Output notes

  • Texts over the length limits of the specification are truncated silently, by characters: PRODUCTNAME 200, GIFT 250, the description of an extended warranty 128, SPECIAL_SERVICE 128, voucher CODE 24 and DESC 128
  • HTML tags are stripped from DESCRIPTION
  • Free text (names, description, manufacturer, category, parameters, gifts, services, voucher description) is written as CDATA
  • Prices have two decimal places (1234.50), HEUREKA_CPC a decimal comma (5,80), VAT a percent sign (21%)
  • Adding a second delivery with the same carrier replaces the first one

Known Issues

  • Values are not checked against the specification beyond the rules above — e.g. the EAN and ISBN format, the limit of 100 carriers per feed or 500 000 items per feed
  • A feed may mix DeliveryIdCz and DeliveryIdSk; choosing the right list for the target country is up to the caller
  • Only UTF-8 output

License

MIT, see LICENSE