yml-generator

An yii component that generates Yandex.Market exchange file in YML format
4 followers

Yandex.Market YML generator. An extension for Yii framework. It supports output to a file or browser and uses XMLWriter as xml engine.

Requirements

Yii 1.1 or above

Usage

For generating xml data you need to create your own generator class and implement four methods:

  • shopInfo()
  • currencies()
  • categories()
  • offers()
class MyYmlGenerator extends YmlGenerator {
 
    protected function shopInfo() {...}
 
    protected function currencies() {...}
 
    protected function categories() {...}
 
    protected function offers() {...}
}

How to implement these metnods see YmlGenerator.php and sample class MyYmlGenerator.php

config/main.php:

'import'=>array(
        ...
        'ext.YmlGenerator.YmlGenerator',
        ...
    ),
 
    // application components
    'components'=>array(
        ...
        'ymlGenerator'=>array(
            'class'=>'MyYmlGenerator',
            // create file in DOCUMENT_ROOT directory
            'outputFile'=>dirname($_SERVER['SCRIPT_FILENAME']).'/catalogue.yml'
        ),
        ...
    )

Run generator:

$generator = Yii::app()->ymlGenerator;
$generator->run();

Resources

Be the first person to leave a comment

Please to leave your comment.

Create extension