zdenekgebauer / zbozi-cz-feed
Create product XML feed for Zbozi.cz
Requires
- php: >=8.4
- ext-json: *
- ext-mbstring: *
- ext-xmlwriter: *
Requires (Dev)
- codeception/codeception: ^5.3
- codeception/module-asserts: ^3.3
- infection/codeception-adapter: ^0.4
- infection/infection: ^0.35
- phpstan/phpstan: ^2.3
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.1
- rector/rector: ^2.9
- shipmonk/composer-dependency-analyser: ^1.8
- symplify/easy-coding-standard: ^13.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 16:28:04 UTC
README
Create the product XML feed for Zboží.cz by the specification
https://napoveda.sklik.cz/reklamy/xml-feed/specifikace/
Requirements
- PHP 8.4 or newer
ext-json,ext-mbstringandext-xmlwriter
No runtime dependencies beyond that.
Installation
composer require zdenekgebauer/zbozi-cz-feed
Usage
use ZdenekGebauer\ZboziCzFeed\Condition; use ZdenekGebauer\ZboziCzFeed\Delivery; use ZdenekGebauer\ZboziCzFeed\DeliveryDate; use ZdenekGebauer\ZboziCzFeed\DeliveryId; use ZdenekGebauer\ZboziCzFeed\ExtraMessage; use ZdenekGebauer\ZboziCzFeed\Feed; use ZdenekGebauer\ZboziCzFeed\Item; use ZdenekGebauer\ZboziCzFeed\Param; use ZdenekGebauer\ZboziCzFeed\SalesVoucher; $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/zbozi.xml'); // required values $item = new Item( itemId: 'SKU-123', productName: 'Samsung Galaxy S25 128 GB černý', description: 'Telefon s displejem 6,2"', url: 'https://example.org/samsung-galaxy-s25', priceVat: 19990.0, deliveryDate: DeliveryDate::inStock(), imgUrl: 'https://example.org/img/s25.jpg', ); // optional values $item->product = 'Samsung Galaxy S25'; $item->addImgUrlAlternative('https://example.org/img/s25-back.jpg'); $item->priceBeforeDiscount = 21990.0; $item->addDelivery(new Delivery(DeliveryId::PPL, 99.0, 129.0)); $item->addDelivery(new Delivery(DeliveryId::ZASILKOVNA, 79.0)); $item->addCategoryText('Elektronika | Mobilní telefony'); $item->ean = '8806095000000'; $item->productNo = 'SM-S931B'; $item->manufacturer = 'Samsung'; $item->addParam(new Param('Barva', 'černá')); $item->addParam(new Param('Hmotnost', '162', 'g')); $item->itemGroupId = 'galaxy-s25'; $item->condition = Condition::NEW; $item->warranty = 24; $item->visibility = true; $item->customLabel0 = 'novinka'; $item->addExtraMessage(ExtraMessage::FREE_GIFT, 'pouzdro'); $item->addExtraMessage(ExtraMessage::FREE_RETURN); $item->addSalesVoucher( new SalesVoucher('SLEVA10', 17990.0, new DateTimeImmutable('2026-12-01'), new DateTimeImmutable('2026-12-31')), ); $feed->add($item); // ...add more items $feed->close();
Delivery date
| Method | DELIVERY_DATE |
Meaning |
|---|---|---|
DeliveryDate::inStock() |
0 |
in stock, ships immediately |
DeliveryDate::days(5) |
5 |
ships within the given number of days |
DeliveryDate::onDate($date) |
2026-12-24 |
pre-order, available on the date |
DeliveryDate::unknown() |
-1 |
availability unknown |
Categories
Categories::parse() reads the category list published at https://www.zbozi.cz/static/categories.json (download it
first) and yields the ID and full path of every leaf category, the value expected in CATEGORYTEXT:
use ZdenekGebauer\ZboziCzFeed\Categories; foreach (new Categories()->parse('/path/to/categories.json') as $id => $categoryText) { // 1234 => 'Elektronika | Mobilní telefony' }
Errors
Feed::add() validates the item before it writes anything and throws InvalidArgumentException when
itemId,productName,description,urlorimgUrlis emptypriceVatis not greater than zero orpriceBeforeDiscountis negative, or either is not finiteurl,imgUrlor an alternative image URL does not start withhttp://orhttps://, or contains whitespace, control or non-ASCII characters (zbozi.cz rejects such URLs; percent-encode each path segment, e.g. withrawurlencode())
Further InvalidArgumentExceptions:
| Thrown by | When |
|---|---|
Delivery::__construct() |
a price is negative or not finite |
SalesVoucher::__construct() |
the price is negative or not finite |
DeliveryDate::days() |
the number of days is negative |
Item::addCategoryText() |
more than 10 categories |
Item::addImgUrlAlternative() |
more than 20 alternative images |
Feed::add() and Feed::close() throw LogicException when open() was not called. Categories::parse() throws
RuntimeException when the file is missing or is not a JSON list.
Output notes
- Values over the length limits of the specification are truncated silently, by characters:
PRODUCT64,PRODUCTNAME255,CATEGORYTEXT500,ITEMGROUP_ID36,CUSTOM_LABEL_0andCUSTOM_LABEL_1250,CUSTOM_LABEL_325, the text of an extra message 160, voucherCODE24 andTEXT128 - HTML tags are stripped from
DESCRIPTION - Free text (product name, description, parameters, labels, messages) is written as CDATA
- Adding a second delivery with the same
DeliveryIdreplaces the first one - An extra message text is written only for messages that have a text element:
CUSTOM,FREE_ACCESSORIES,FREE_GIFTandVOUCHER WARRANTYis written only when positive (999= lifetime)
Known Issues
- Values are not checked against the specification beyond the rules above — e.g. the EAN format, the length of
ITEM_IDor the number of parameters - Only UTF-8 output
License
MIT, see LICENSE