rohos/rsyayml

A package for generating Yandex YML

1.0.0 2020-06-01 15:13 UTC

This package is auto-updated.

Last update: 2024-05-23 04:02:47 UTC


README

A package for generating Yandex YML

1. Installation

composer require rohos/rsyayml

2. Require:

"require": {
    "php": ">=7.1.0",
    "ext-dom": "*"
}

3. Offer types:

4. Example:

$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();