2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-yml-catalog

YML (Yandex Market Language) generator.

image

pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  • Thursday, June 14, 2018
  • by pastuhov
  • Repository
  • 6 Watchers
  • 15 Stars
  • 6,602 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 16 Forks
  • 3 Open issues
  • 31 Versions
  • 2 % Grown

The README.md

ΠšΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ Π²Ρ‹Π³Ρ€ΡƒΠ·ΠΊΠΈ ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π° Ρ‚ΠΎΠ²Π°Ρ€ΠΎΠ² Π² ЯндСкс.ΠœΠ°Ρ€ΠΊΠ΅Ρ‚ (YML)

Build Status Scrutinizer Code Quality Code Coverage Total Downloads, (*1)

Установка

Via Composer, (*2)

``` bash $ composer require pastuhov/yii2-yml-catalog, (*3)


## Features * Π»Π΅Π³ΠΊΠΈΠΉ * базируСтся Π½Π° ΠΎΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½ΠΎΠΉ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ https://yandex.ru/support/partnermarket/yml/about-yml.xml ## ИспользованиС 1. Π Π΅Π°Π»ΠΈΠ·ΡƒΠ΅ΠΌ интСрфСйсы (ΠΏΡ€ΠΈΠΌΠ΅Ρ€Ρ‹ Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ всСх классов смотри Π² Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ `tests`) 2. Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠΎΠ½ΡΠΎΠ»ΡŒΠ½Ρ‹ΠΉ ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€: ```php 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' ], ], ]; } }
  1. ЗапускаСм ΠΈΠ· консоли:
$ yii yml/generate

Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ

Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ с ΠΈΠΌΠ΅Π½Π΅ΠΌ класса, Ρ€Π΅Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ интСрфСйса, ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅Ρ€Π΅Π΄Π°Π²Π°Ρ‚ΡŒ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠ΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: 1. ΠžΠ±ΡŠΠ΅ΠΊΡ‚ класса ActiveQuery, ΠΈΠ»ΠΈ Π΅Π³ΠΎ наслСдника., (*4)

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

Π’ Π΄Π°Π½Π½ΠΎΠΌ случаС, Π²Ρ‹Π±ΠΎΡ€ΠΊΠ° Π΄Π°Π½Π½Ρ‹Ρ… Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ΡŒΡΡ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΏΠ΅Ρ€Π΅Π΄Π°Π²Π°Π΅ΠΌΠΎΠ³ΠΎ ActiveQuery ΠΈΠ»ΠΈ Π΅Π³ΠΎ наслСдника; ΠŸΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΡƒΠΆΠ΅ созданный ΠΎΠ±ΡŠΠ΅ΠΊΡ‚, для Π²Ρ‹Π±ΠΎΡ€ΠΊΠΈ Π΄Π°Π½Π½Ρ‹Ρ…., (*5)

  1. ΠžΠ±ΡŠΠ΅ΠΊΡ‚ класса ActiveDataProvider, ΠΈΠ»ΠΈ Π΅Π³ΠΎ наслСдника.
'categoryClass' => [
    'class' => 'class' => 'pastuhov\ymlcatalog\Test\models\Category',
    'dataProvider' => new ActiveDataProvider([
        'query' => Category::find(),
        'pagination' => [
            'pageSize' => 1000,
        ]
    ]),
]

Π’ Π΄Π°Π½Π½ΠΎΠΌ случаС, Π²Ρ‹Π±ΠΎΡ€ΠΊΠ° Π΄Π°Π½Π½Ρ‹Ρ… Π±ΡƒΠ΄Π΅Ρ‚ ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚ΡŒΡΡ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΏΠ΅Ρ€Π΅Π΄Π°Π²Π°Π΅ΠΌΠΎΠ³ΠΎ ActiveDataProvider ΠΈΠ»ΠΈ Π΅Π³ΠΎ наслСдника;, (*6)

ΠŸΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ‚ Π΄Π΅Π»Π°Ρ‚ΡŒ Π²Ρ‹Π±ΠΎΡ€ΠΊΡƒ Π΄Π°Π½Π½Ρ‹Ρ… с использованиСм постраничной ΠΏΠ°Π³ΠΈΠ½Π°Ρ†ΠΈΠΈ., (*7)

Π’Π°ΠΊ-ΠΆΠ΅ ΠΌΠΎΠΆΠ΅Ρ‚ Π±Ρ‹Ρ‚ΡŒ ΠΏΠ΅Ρ€Π΅Π΄Π°Π½ true, Π² качСствС ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°, для автоматичСского создания ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° класса ActiveDataProvider со Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ΠΌ количСства строк Π² страницС Ρ€Π°Π²Π½ΠΎΠΉ 1000., (*8)

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

На Π±ΠΎΠ»ΡŒΡˆΠΈΡ… ΠΎΠ±ΡŠΠ΅ΠΌΠ°Ρ… Π΄Π°Π½Π½Ρ‹Ρ…, Π²Ρ‹Π±ΠΎΡ€ΠΊΠ°, с использованиСм ActiveQuery->batch(), расходуСт ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΈΠ²Π½ΡƒΡŽ ΠΏΠ°ΠΌΡΡ‚ΡŒ, Π³ΠΎΡ€Π°Π·Π΄ΠΎ Π±ΠΎΠ»ΡŒΡˆΡƒΡŽ, Ρ‡Π΅ΠΌ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ установлСнноС Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠ»Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»Π°Ρ…. (Π‘ΠΊΠΎΡ€Π΅Π΅ всСго особСнности Ρ€Π°Π±ΠΎΡ‚Ρ‹ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ PDO)., (*9)

Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅: ИспользованиС ActiveDataProvider ΡƒΠ²Π΅Π»ΠΈΡ‡ΠΈΠ²Π°Π΅Ρ‚ врСмя Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΠΈ Π²Ρ‹Π³Ρ€ΡƒΠ·ΠΊΠΈ., (*10)

ΠŸΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Π½ΠΈΠ΅ символов " & > < ' Π² html-сущности

ЯндСкс ΠœΠ°Ρ€ΠΊΠ΅Ρ‚ ругаСтся Π½Π° символы " & > < '. Π˜Ρ… Π½ΡƒΠΆΠ½ΠΎ ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Ρ‹Π²Π°Ρ‚ΡŒ Π² html-сущности, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° прайса ΠΏΡ€ΠΎΡ…ΠΎΠ΄ΠΈΠ»Π° ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ. Π§Ρ‚ΠΎΠ±Ρ‹ это ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ, Π² ΠΌΠΎΠ΄Π΅Π»ΠΈ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Ρ‚ΡŒ интСрфСйс pastuhov\ymlcatalog\EscapedAttributes ΠΈ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ ΠΌΠ΅Ρ‚ΠΎΠ΄ getEscapedAttributes, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ список Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹Ρ… для чистки Π°Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ΠΎΠ². Π’ ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π΅ Π½ΠΈΠΆΠ΅ ΠΌΡ‹ ΡƒΠΊΠ°Π·Ρ‹Π²Π°Π΅ΠΌ, Ρ‡Ρ‚ΠΎ Π°Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ name Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Ρ„ΠΈΠ»ΡŒΡ‚Ρ€ΠΎΠ²Π°Ρ‚ΡŒ:, (*11)

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

ВСстированиС

$ composer test

ΠΈΠ»ΠΈ, (*12)

$ phpunit

ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒ качСство сгСнСрируСмого Ρ„Π°ΠΉΠ»Π° ΠΌΠΎΠΆΠ½ΠΎ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΌΠΈ способами: 1. ΠžΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½Ρ‹ΠΌ Π²Π°Π»ΠΈΠ΄Π°Ρ‚ΠΎΡ€ΠΎΠΌ https://old.webmaster.yandex.ru/xsdtest.xml 2. ΠŸΡ€ΠΈ ΠΏΠΎΠΌΠΎΡ‰ΠΈ xmllint (ΠΏΡ€ΠΈΠΌΠ΅Ρ€: xmllint --valid --noout yml-test.xml) 3. IDE PhpStorm Ρ‚Π°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ΅Ρ‚ ΠΏΠΎΠΌΠΎΡ‡ΡŒ, (*13)

Security

If you discover any security related issues, please email kirill@pastukhov.su instead of using the issue tracker., (*14)

Credits

License

GNU General Public License, version 2. Please see License File for more information., (*15)

The Versions

14/06 2018

dev-master

9999999-dev https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex

14/06 2018
11/11 2017
14/09 2017
14/09 2017

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex

14/09 2017
15/06 2017
22/05 2017
19/05 2017
19/05 2017
10/05 2017
07/05 2017
17/02 2017
15/09 2016
15/09 2016
26/08 2016
24/08 2016
23/08 2016

16.x-dev

16.9999999.9999999.9999999-dev https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex

06/05 2016
15/04 2016
14/03 2016
03/03 2016
02/03 2016
26/02 2016
26/02 2016

dev-pastuhov-patch-1

dev-pastuhov-patch-1 https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex

15/01 2016
23/10 2015
23/10 2015

dev-test

dev-test https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex

03/07 2015

v0.1.2

0.1.2.0 https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex

26/06 2015

v0.1.1

0.1.1.0 https://github.com/pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

generator e-commerce yml yandex