PHP code example of pastuhov / yii2-yml-catalog

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

    

pastuhov / yii2-yml-catalog example snippets


namespace console\controllers;

use pastuhov\ymlcatalog\actions\GenerateAction;
use yii\console\Controller;

/**
 * Class GenerateController
 */
class YmlController extends Controller
{
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'generate' => [
                'class' => GenerateAction::className(),
                'enableGzip' => true, # запаковать gzip-ом yml после генерации
                'fileName' => 'yml-test.xml', # желаемое название файла
                'publicPath' => '@runtime/public', # публичная директория (обычно корень веб сервера)
                'runtimePath' => '@runtime', # временная директория
                'keepBoth' => true, # опубликовать yml и .gz
                'shopClass' => 'pastuhov\ymlcatalog\Test\models\Shop',
                'currencyClass' => 'pastuhov\ymlcatalog\Test\models\Currency',
                'categoryClass' => 'pastuhov\ymlcatalog\Test\models\Category',
                'localDeliveryCostClass' => 'pastuhov\ymlcatalog\Test\models\LocalDeliveryCost',
                'offerClasses' => [
                    'pastuhov\ymlcatalog\Test\models\SimpleOffer'
                ],
            ],
        ];
    }
}

'categoryClass' => [
    'class' => 'pastuhov\ymlcatalog\Test\models\Category',
    'query' => \pastuhov\ymlcatalog\Test\models\Category\Category::find(),
]

'categoryClass' => [
    'class' => 'class' => 'pastuhov\ymlcatalog\Test\models\Category',
    'dataProvider' => new ActiveDataProvider([
        'query' => Category::find(),
        'pagination' => [
            'pageSize' => 1000,
        ]
    ]),
]

'categoryClass' => [
    'class' => 'class' => 'pastuhov\ymlcatalog\Test\models\Category',
    'dataProvider' => new ActiveDataProvider([
        'query' => Category::find(),
        'pagination' => true,
    ]
]

use pastuhov\ymlcatalog\EscapedAttributes;
use pastuhov\ymlcatalog\SimpleOfferInterface;
class SimpleOffer extends ActiveRecord implements SimpleOfferInterface, EscapedAttributes
{
...
    public function getEscapedAttributes() {
        return [
            'name'
        ];
    }
...
}