sokil / php-merchant-product-feed
Builder of Facebook and Google product feeds
Installs: 2 451
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Builder of Facebook and Google product feeds
Useful links
Useful links
Useage
<?php // build set of products $product = new Product( 'sku', 'title', 'description', new Availability(Availability::IN_STOCK), new Condition(Condition::NEW), new Price('42.42', 'UAH'), new Url('https://example.com/item'), new Url('https://example.com/item.png'), 'SomeBrand' ); // build feed $feed = new Feed([$product]); // create formatter, devince product normaliser for martketing platform and define encoder to some formats $formatter = new Formatter( [new FacebookProductNormaliser()], [new FacebookFeedCsvEncoder()] ); // formatted feed is generator which yields parts of feed $generator = $formatter->format($feed, 'facebook', 'csv'); // send feed to output header('Content-type: text/csv'); foreach ($generator as $streamChunk) { echo $streamChunk; }