PHP code example of aluch / yml-generator

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

    

aluch / yml-generator example snippets




use Aluch\YmlGenerator\Model\Offer\OfferSimple;
use Aluch\YmlGenerator\Model\Category;
use Aluch\YmlGenerator\Model\Currency;
use Aluch\YmlGenerator\Model\Delivery;
use Aluch\YmlGenerator\Model\ShopInfo;
use Aluch\YmlGenerator\Settings;
use Aluch\YmlGenerator\Generator;

$file = tempnam(sys_get_temp_dir(), 'YMLGenerator');
$settings = (new Settings())
    ->setOutputFile($file)
    ->setEncoding('UTF-8')
;

// Creating ShopInfo object (https://yandex.ru/support/webmaster/goods-prices/technical- (new Category())
    ->setId(1)
    ->setName($this->faker->name)
;

// Creating offers array (https://yandex.ru/support/webmaster/goods-prices/technical-ries
);

$offers[] = (new OfferSimple())
    ->setId(12346)
    ->setAvailable(true)
    ->setUrl('http://www.best.seller.com/product_page.php?pid=12348')
    ->setPrice($this->faker->numberBetween(1, 9999))
    ->setCurrencyId('USD')
    ->setCategoryId(1)
    ->setDelivery(false)
    ->setName('Best product ever')
    ->addCustomElement('type', 'value')
;