PHP code example of windstep / yandex-realty-feed-generator

1. Go to this page and download the library: Download windstep/yandex-realty-feed-generator 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/ */

    

windstep / yandex-realty-feed-generator example snippets



use Windstep\YRLGenerator\YRLGenerator;
use Windstep\YRLGenerator\Offer;

$outputFilePath = __DIR__ . '/files/created_file.xml';
$temporaryFilePath = __DIR__ . '/files/tmp_file.xml';

$generator = new YRLGenerator($outputFilePath, $temporaryFilePath); // Note, that last one could be null
$generator->beforeWrite();
$offers = [new Offer(1, $data), new Offer(2, $data)]; // Offer keys (first value) must be unique
foreach ($offers as $offer) {
    $generator->bulkWrite($offer);
}
$generator->afterWrite();



$offer = new Offer(123456);
        $offer->setType(Type::SELL())
            ->setPropertyType(PropertyType::LIVING())
            ->setCategory(Category::FLAT())
            ->setLocation('Россия', null, null, 'Санкт-Петербург', null, '18-я линия В.О., 32')
            ->setMetro('Василеостровская')
            ->setPrice(4780000, Currency::RUB())
            ->setSalesAgent(null,
                '+7812500400',
                SalesAgentCategory::DEVELOPER(),
                'ЗАО "Застройщик"',
                'http://www.developer.ru/',
                null,
                'http://www.developer.ru/company/logo'
            )
            ->setRooms(2)
            ->setNewFlat()
            ->setBathroomUnit(BathroomUnit::SEPARATED())
            ->setBalcony(BalconyType::BALCONY())
            ->setFloor(13)
            ->setFloorsTotal(15)
            ->setBuildingName('Северная фантазия')
            ->setYandexBuildingId(12345)
            ->setYandexHouseId(54321)
            ->setBuildingSection('Корпус 1')
            ->setBuildingState(BuildingState::UNFINISHED())
            ->setReadyQuarter(3)
            ->setBuiltYear(2018)
            ->setBuildingPhase(3)
            ->setImage('http://www.developer.ru/images/plans/000001289.jpg')
            ->setDescription('Продается 2 к. кв., 13 этаж, 15 минут на машине до метро "Василеостровская". Дом комфорт-класса с продуманными планировочными решениями и широким выбором квартир. Внутренний двор «Северной фантазии» выполнен по эксклюзивному дизайн-проекту. В районе постройки нового ЖК развита инфраструктура: школы и детские сады, больница, аптеки магазины, кафе и спортивные центры. Доступны разные условия ипотеки, скидки и зачет жилья.')
            ->setArea(63.00, Unit::METER_SQUARE())
            ->setLivingSpace(50.00, Unit::METER_SQUARE())
            ->setKitchenSpace(10.00, Unit::METER_SQUARE())
            ->setRoomSpace(15, Unit::METER_SQUARE())
            ->setRoomSpace(35, Unit::METER_SQUARE())
            ->setCreationDate('2015-04-02T19:00:06+03:00');


    $data = [
        'type' => 'продажа',
        'property-type' => 'жилая',
        'category' => 'квартира',
        'creation-date' => '2015-04-02T19:00:06+03:00',
        'location' => [
            'country' => 'Россия',
            'locality-name' => 'Санкт-Петербург',
            'address' => '18-я линия В.О., 32',
            'metro' => [
                'name' => 'Василеостровская'
            ],
        ],
        'price' => [
            'value' => 4780000,
            'currency' => 'RUR',
        ],
        'sales-agent' => [
            'phone' => '+7812500400',
            'organization' => 'ЗАО "Застройщик"',
            'url' => 'http://www.developer.ru/',
            'category' => 'developer',
            'photo' => 'http://www.developer.ru/company/logo',
        ],
        'rooms' => 2,
        'new-flat' => 1,
        'bathroom-unit' => 'раздельный',
        'balcony' => 'балкон',
        'floor' => 13,
        'floors-total' => 15,
        'building-name' => 'Северная фантазия',
        'yandex-building-id' => 12345,
        'yandex-house-id' => 54321,
        'building-section' => 'Корпус 1',
        'building-state' => 'unfinished',
        'ready-quarter' => 3,
        'built-year' => 2018,
        'building-phase' => 3,
        'image' => [
            'http://www.developer.ru/images/plans/000001289.jpg',
        ],
        'description' => 'Продается 2 к. кв., 13 этаж, 15 минут на машине до метро "Василеостровская". 
                        Дом комфорт-класса с продуманными планировочными решениями и широким выбором квартир. 
                        Внутренний двор «Северной фантазии» выполнен по эксклюзивному дизайн-проекту. 
                        В районе постройки нового ЖК развита инфраструктура: школы и детские сады, больница, аптеки,
                        магазины, кафе и спортивные центры. Доступны разные условия ипотеки, скидки и зачет жилья.', // No html tags available here
        'area' => [
            'value' => 63.00,
            'unit' => 'кв. м',
        ],
        'living-space' => [
            'value' => 50.00,
            'unit' => 'кв. м',
        ],
        'kitchen-space' => [
            'value' => 10.00,
            'unit' => 'кв. м',
        ],
        'room-space' => [
            [
                'value' => 15,
                'unit' => 'кв. м',
            ],
            [
                'value' => 35,
                'unit' => 'кв. м',
            ]
        ],

    ]