PHP code example of rohos / rsyayml

1. Go to this page and download the library: Download rohos/rsyayml 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/ */

    

rohos / rsyayml example snippets


$filePath = 'test.xml';
$yml = new RsYaYml($filePath);
$yml->createBaseShopElements(
    'PrinterShop',
    'ООО PrinterShop',
    'https://some-printer-shop-url.com'
);

$yml->addCategory(1, 'Принтеры');
$yml->addCategory(2, 'Струйные принтеры', 1);
$yml->addCurrency('RUR');

$yml->createFile();

$yml->addOffer(
    (new OfferVendorModel('id-1', true))
        ->setUrl('https://some-printer-shop-url.com/catalog/product-id-1')
        ->setPrice(200)
        ->setCurrencyId('RUR')
        ->setCategoryId(2)
        ->setDescription('Description')
        ->setModel('Deskjet D2663')
        ->setTypePrefix('Принтер')
        ->setSalesNote('Минимум 10')
        ->setManufacturerWarranty(true)
        ->setParam('Максимальный формат', 'А4')
        ->setParam('Количество страниц в месяц', 1000, 'стр')
        ->setDownloadable(true)
        ->setCountryOfOrigin('Россия')
        ->setVendor('Yandex')
        ->setVendorCode('CH366C')
        ->setDelivery(true)
        ->setDeliveryOptions(100)
);

$yml->saveFile();
bash
""php": ">=7.1.0",
    "ext-dom": "*"
}