2017 © Pedro Peláez
 

library feed-generator

Feed generator

image

inteve/feed-generator

Feed generator

  • Sunday, June 24, 2018
  • by janpecha
  • Repository
  • 1 Watchers
  • 0 Stars
  • 529 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 31 % Grown

The README.md

Feed Generator

Tests Status, (*1)

Become a Patron! Buy me a coffee, (*2)

Installation

Download a latest package or use Composer:, (*3)

composer require inteve/feed-generator

Feed Generator requires PHP 5.6.0 or later., (*4)

Usage

Feeds

Google Merchant

``` php use Inteve\FeedGenerator\Feeds\GoogleMerchant;, (*8)

$feed = new GoogleMerchant\GoogleMerchantFeed; $feed->setTitle('Products'); $feed->setWebsiteUrl('http://www.example.com/'); $feed->setUpdated(new DateTime('2017-01-01 00:00:00 UTC')); $feed->setAuthor('Example.com'); $items = array();, (*9)

foreach ($products as $product) { $item = new GoogleMerchant\GoogleMerchantItem; $item->setId($product->id) ->setTitle($product->title) ->setDescription($product->description) ->setUrl('https://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setAvailability($product->qty > 0 ? $item::AVAILABILITY_IN_STOCK : $item::AVAILABILITY_OUT_OF_STOCK) ->setPrice($product->price, 'USD'); $items[] = $item; }, (*10)

$feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(DIR . '/feeds/google.xml'));, (*11)



#### Glami.cz ``` php use Inteve\FeedGenerator\Feeds\Glami; $feed = new Glami\GlamiFeed; $items = array(); foreach ($products as $product) { $items[] = Glami\GlamiItem::create() ->setId($product->id) ->setProductName($product->name) ->setDescription($product->description) ->setCategoryText($product->categoryName) ->setUrl('http://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setPriceVat($product->price) ->setDeliveryDate($product->qty > 0 ? 0 : 10) // number of days ->addParameter('velikost', 'XS'); } $feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(__DIR__ . '/feeds/glami.xml'));

Heureka.cz

``` php use Inteve\FeedGenerator\Feeds\Heureka;, (*12)

$feed = new Heureka\HeurekaFeed; $items = array();, (*13)

foreach ($products as $product) { $items[] = Heureka\HeurekaItem::create() ->setId($product->id) ->setProductName($product->name) ->setDescription($product->description) ->setCategoryText($product->categoryName) ->setUrl('http://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setPrice($product->price) ->setDeliveryDate($product->qty > 0 ? 0 : 10); // number of days or DateTime }, (*14)

$feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(DIR . '/feeds/heureka.xml'));, (*15)



#### Zbozi.cz ``` php use Inteve\FeedGenerator\Feeds\Zbozi; $feed = new Zbozi\ZboziFeed; $items = array(); foreach ($products as $product) { $items[] = Zbozi\ZboziItem::create() ->setId($product->id) ->setProductName($product->name) ->setDescription($product->description) ->setUrl('http://www.example.com/product/' . $product->url) ->setImageUrl('https://www.example.com/images/product/' . $product->id) ->setPrice($product->price) ->setDeliveryDate($product->qty > 0 ? 0 : 10); // number of days or DateTime } $feed->setItems($items); $feed->generate(new Inteve\FeedGenerator\Outputs\FileOutput(__DIR__ . '/feeds/zbozi.xml'));

Outputs

FileOutput

Sends output to file., (*16)

``` php $output = new Inteve\FeedGenerator\Outputs\FileOutput('/path/to/destination/feed.xml'); $feed->generate($output);, (*17)



#### DirectOutput Sends output to STDIN. ``` php $output = new Inteve\FeedGenerator\Outputs\DirectOutput; $feed->generate($output);

MemoryOutput

Saves output in memory., (*18)

``` php $output = new Inteve\FeedGenerator\Outputs\MemoryOutput; $feed->generate($output); echo $output->getOutput();, (*19)



### Integrations #### [Nette](https://nette.org/) Requires package [`nette/application`](https://packagist.org/packages/nette/application). ``` php $response = new FeedGenerator\Responses\NetteDownloadResponse($feed, 'filename'); $presenter->sendResponse($response);

For example:, (*20)

``` php class FeedPresenter extends Nette\Application\UI\Presenter { public function actionGoogle() { $feed = new FeedGenerator\Feeds\GoogleMerchant\GoogleMerchantFeed; // prepare feed & items, (*21)

    $response = new FeedGenerator\Responses\NetteDownloadResponse($feed, 'google.xml');
    $this->sendResponse($response);
}

} ```, (*22)


License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/, (*23)

The Versions

24/06 2018

dev-master

9999999-dev

Feed generator

  Sources   Download

BSD-3-Clause BSD-3

The Requires

 

The Development Requires

26/12 2017

v1.1.0

1.1.0.0

Feed generator

  Sources   Download

BSD-3

The Requires

 

The Development Requires

04/04 2017

v1.0.0

1.0.0.0

Feed generator

  Sources   Download

BSD-3

The Requires

 

The Development Requires