PHPackages                             mysutka/product\_feed\_generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. mysutka/product\_feed\_generator

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

mysutka/product\_feed\_generator
================================

Class helping to generate product feed for various price comparison services suitable for Atk14 applications

v0.1.25(5mo ago)017.1k↑95%MITPHPPHP &gt;=5.3.0CI failing

Since Mar 20Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/mysutka/ProductFeedGenerator)[ Packagist](https://packagist.org/packages/mysutka/product_feed_generator)[ Docs](https://github.com/mysutka/datalayer_generator)[ RSS](/packages/mysutka-product-feed-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (27)Used By (0)

Product Feed Generator
======================

[](#product-feed-generator)

This package provides library which helps create XML and CSV feeds for various price comparison services, e.g. Google Shopping, Heureka, etc. The library is intended to be extensible. A developer can create own generator for other price comparison services and he can also create own reader if he for example needs to alter selection of objects or work with different objects.

First you can see examples in `src/robots/product_feed_generator_robot.php`

Generators available for these price comparators

- Heureka.cz
- Zbozi.cz
- Google Shopping
- Google Merchants

Base classes
------------

[](#base-classes)

Two basic classes are used which can be extended **Atk14EshopReader** selects, reads objects (usually products) and converts them to array **FeedGenerator** works with arrays returned by Atk14EshopReader. It should not be used directly. New class should be created which inherits FeedGenerator

### Atk14EshopReader options

[](#atk14eshopreader-options)

- price\_with\_currency - boolean \[default: false\]
- price\_finder
- lang - string \[default: null =&gt; application default\] - forces the reader to use object translations for specified language when the object supports it
- category\_path\_connector - string \[default: '&gt;'\]
- hostname - string \[default: ATK14\_HTTP\_HOST\]
- image\_geometry - string \[default: '800x800'\]
- image\_watermark - string \[default: null =&gt; no watermark is used\]

### FeedGenerator options

[](#feedgenerator-options)

- logger
- output\_format
- xml\_item\_element\_name
- feed\_begin
- feed\_end
- fixed\_values

### Examples

[](#examples)

Usually only the `FeedGenerator` class can be used:

```
$generator = new \ProductFeedGenerator\Generator\GoogleShoppingGenerator();
$generator->exportTo("/path/to/public/web/directory/product_feeds/google_shopping.xml")
```

This will output xml element DELIVERY\_DATE containing text '25'. It will override original value if it should be generated by the generator.

```
$generator = new \ProductFeedGenerator\Generator\HeurekaCzGenerator(null, [
  "fixed_values" => [
    "DELIVERY_DATE" => 25,
]);
```

Output

```
25
```

When needed elements that are normally in output can be removed. In this example generator by default outputs element EAN in each item. By specifying null for EAN in fixed\_values option, the element will disappear from output.

```
$generator = new \ProductFeedGenerator\Generator\HeurekaCzGenerator(null, [
  "fixed_values" => [
    "EAN" => null,
]);
```

Creating feed with prices in another currency, EUR for example

```
$eur_price_finder = PriceFinder::GetInstance(null, Currency::FindByCode("EUR"));
$generator = new \ProductFeedGenerator\Generator\HeurekaCzGenerator(null, [
  "price_finder" => $eur_price_finder,
]);
```

Custom Reader
-------------

[](#custom-reader)

Most common example is a reader which generates a feed for a limited set of products. In this case we create a new class as a descendant of `ProductFeedGenerator\Reader\Atk14EshopReader` which consists of a single method getObjectIds(). This LimitedEshopReader provides ids of products created during the last month.

```
class LimitedEshopReader extends ProductFeedGenerator\Reader\Atk14EshopReader {

  function getObjectIds($options=[]) {
    $options += [
      "offset" => 0,
    ];
    $ids = $this->dbmole->selectIntoArray("SELECT distinct(id) FROM cards
      WHERE
        created_at>now() - interval '1 month' AND
        NOT deleted AND
        visible
      ORDER BY id
      LIMIT 100 OFFSET :offset", array(
        ":offset" => $options["offset"],
      ));
    return $ids;
  }
}
```

Custom Generator
----------------

[](#custom-generator)

Sometimes happenes that we need to send the comparison service a value that is a bit altered while the generator provides it as it is stored in the database. So let's create our custom Generator. Let's say our standard GoogleShoppingGenerator does not provide "g:availability" attribute (which in actually does) but there is attribute STOCKCOUNT provided by the main `Atk14EshopReader` class. So we create new Generator class which adds the STOCKCOUNT attribute to the values from the Reader class and then adds the "g:availability" attribute to the output.

```
class CustomGoogleShoppingGenerator extends ProductFeedGenerator\Generator\GoogleShoppingGenerator {
  function getAttributesMap() {
    return parent::getAttributesMap() + [
      "g:availability" => "STOCKCOUNT",
    ];
  }

  function afterFilter($values) {
    $values["g:availability"] = ($values["g:availability"]) > 0 ? "in stock" : "out of stock";
    return $values;
  }
}
```

The method `getAttributesMap()` is called in the parent Generator class. Here, we override it and add the `g:availability` attribute by using the general `STOCKCOUNT` attribute provided by the Reader class which is simply a number of products in our warehouse. Then we add the `afterFilter()` method which is also called by the parent class FeedGenerator. It is used to transform the values which would be normally sent to final output. In our method we modify the `g:availability` attribute to our needs, which means we send a text "in stock" or "out of stock" to the output instead of exact number.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance71

Regular maintenance activity

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~83 days

Recently: every ~101 days

Total

26

Last Release

164d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/63850884295d8ba2feeca5607fb01db937060f526ed7e71fcbd184fd00ce2799?d=identicon)[michal.vojan](/maintainers/michal.vojan)

---

Top Contributors

[![mysutka](https://avatars.githubusercontent.com/u/974669?v=4)](https://github.com/mysutka "mysutka (45 commits)")

---

Tags

xmlfeedgeneratorcsvproductatk14price\_comparison\_services

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mysutka-product-feed-generator/health.svg)

```
[![Health](https://phpackages.com/badges/mysutka-product-feed-generator/health.svg)](https://phpackages.com/packages/mysutka-product-feed-generator)
```

###  Alternatives

[mledoze/countries

List of world countries in JSON, CSV, XML and YAML

6.2k699.7k6](/packages/mledoze-countries)[faisalman/simple-excel-php

Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats

582599.4k1](/packages/faisalman-simple-excel-php)[soapbox/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML and a few others.

2501.1M12](/packages/soapbox-laravel-formatter)[rodenastyle/stream-parser

PHP Multiformat Streaming Parser

443195.7k2](/packages/rodenastyle-stream-parser)[ee/dataexporter-bundle

Easy export data to CSV, XML, HTML, JSON or XLS

4982.5k](/packages/ee-dataexporter-bundle)[dracoblue/craur

A lossless xml to json and json to xml converter (and csv/xlsx/yaml). Writing PHP Json/Xml/Csv/Yaml/excel Importers made easy

4643.1k2](/packages/dracoblue-craur)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
