1. Go to this page and download the library: Download eko/feedbundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$feed = $this->get('eko_feed.feed.manager')->get('article');
$feed->add(new FakeEntity());
$feed->addItemField(
new GroupItemField(
'categories',
new ItemField('category', 'getFeedCategoriesCustom', array(), array('category-attribute', 'test'),
array('categories-attribute', 'getAttributeValue')
)
);
$feed->addItemField(
new GroupItemField('author', array(
new ItemField('name', 'getFeedItemAuthorName', array('cdata' => true)),
new ItemField('email', 'getFeedItemAuthorEmail')
)
);
$feed->addItemField(
new GroupItemField('authors', array(
new GroupItemField('author', array(
new ItemField('name', 'Vincent', array('cdata' => true)),
new ItemField('email', '[email protected]')
)),
new GroupItemField('author', array(
new ItemField('name', 'Audrey', array('cdata' => true)),
new ItemField('email', '[email protected]')
))
)
);
$feed->addChannelField(
new GroupChannelField('author', array(
new ChannelField('name', 'My author name'),
new ChannelField('email', '[email protected]')
)
);
/**
* Returns a custom media field
*
* @return string
*/
public function getFeedMediaItem()
{
return array(
'type' => 'image/jpeg',
'length' => 500,
'value' => 'http://website.com/image.jpg'
);
}
use Eko\FeedBundle\Service\FeedDumpService;
$feedDumpService = $this->get(FeedDumpService::class);
$feedDumpService
->setName($name)
//You can set an entity
//->setEntity($entity)
// Or set you Items
->setItems($MyOwnItemList)
->setFilename($filename)
->setFormat($format)
->setLimit($limit)
->setDirection($direction)
->setOrderBy($orderBy)
;
$feedDumpService->dump();