1. Go to this page and download the library: Download yokel/gfeed 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/ */
yokel / gfeed example snippets
// Создать экземпляр класса
$feed = new \Yokel\GFeed\GFeed();
// Указать идентификатор инфоблока с товарами
// второй параметр - идентификатор родительского инфоблока (обязательный, если есть ТП)
$feed->setIblockId(25, 24);
// Указать название поля с ценой товара (для фильтрации - исключить товары с нулевой ценой)
$feed->setPriceField('CATALOG_PRICE_1');
// Экспорт в xml
$feed->export('/feed.xml');
// Экспорт в csv
$feed->export('/feed.csv', \Yokel\GFeed\GFeed::FORMAT_CSV);
// Экспорт в yml
$feed->export('/feed.xml', \Yokel\GFeed\GFeed::FORMAT_YML);
// Добавляет маппинг для xml
function addMappingXml($name, $value)
// Добавляет маппинг для csv
function addMappingCsv($name, $value)
// Добавляет маппинг для yml
function addMappingYml($name, $value)
// Добавляет маппинг для всех
function addMappingAll($name, $value)
// Подставляет значение 567 в поле google_product_category
$feed->addMappingCsv('google_product_category', '567');
// Подставляет значение поля SECTION_CODE из товара в поле custom_label_0 в файле
$feed->addMappingXml('custom_label_0', 'element.SECTION_CODE');
//или
$feed->addMappingXml('custom_label_0', '.SECTION_CODE');
// Подставляет значение поля SECTION_CODE из родительского товара (для ТП)
$feed->addMappingXml('custom_label_0', 'parent.SECTION_CODE');
// $item - товар из инфоблока
$feed->addMappingAll('description', function ($item) {
return $item['PARENT']['PROPS']['DESCRIPTION']['VALUE']['TEXT'];
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.