Giter Site home page Giter Site logo

ymlgenerator's Introduction

YML (Yandex Market Language) file generator

Build Status Code Coverage Scrutinizer Code Quality License Latest Stable Version Total Downloads

About

YML (Yandex Market Language) generator. Uses standard XMLWriter for generating YML file. Not required any other library you just need PHP 5.5.0 or >= version.

Generator supports this offer types:

Installation

Run composer require

composer require bukashk0zzz/yml-generator

Or add this to your composer.json file:

"require": {
	"bukashk0zzz/yml-generator": "dev-master",
}

Usage examples

<?php

use Bukashk0zzz\YmlGenerator\Model\Offer\OfferSimple;
use Bukashk0zzz\YmlGenerator\Model\Category;
use Bukashk0zzz\YmlGenerator\Model\Currency;
use Bukashk0zzz\YmlGenerator\Model\Delivery;
use Bukashk0zzz\YmlGenerator\Model\ShopInfo;
use Bukashk0zzz\YmlGenerator\Settings;
use Bukashk0zzz\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-requirements.xml#shop)
$shopInfo = (new ShopInfo())
    ->setName('BestShop')
    ->setCompany('Best online seller Inc.')
    ->setUrl('http://www.best.seller.com/')
;

// Creating currencies array (https://yandex.ru/support/webmaster/goods-prices/technical-requirements.xml#currencies)
$currencies = [];
$currencies[] = (new Currency())
    ->setId('USD')
    ->setRate(1)
;

// Creating categories array (https://yandex.ru/support/webmaster/goods-prices/technical-requirements.xml#categories)
$categories = [];
$categories[] = (new Category())
    ->setId(1)
    ->setName($this->faker->name)
;

// Creating offers array (https://yandex.ru/support/webmaster/goods-prices/technical-requirements.xml#offers)
$offers = [];
$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')
;

// Optional creating deliveries array (https://yandex.ru/support/partnermarket/elements/delivery-options.xml)
$deliveries = [];
$deliveries[] = (new Delivery())
    ->setCost(2)
    ->setDays(1)
    ->setOrderBefore(14)
;

(new Generator($settings))->generate(
    $shopInfo,
    $currencies,
    $categories,
    $offers,
    $deliveries
);

Adding custom elements

if you need additional offers elements in your yml file using method addCustomElement('type','value'). For example:

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

Copyright / License

See LICENSE

ymlgenerator's People

Contributors

bessamu avatar bukashk0zzz avatar butochnikov avatar chibrikina avatar dimawar avatar jrfnl avatar l1a7t avatar mmjurov avatar pashamesh avatar remitmaster avatar rodnyco avatar taarim avatar veezex avatar zyura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ymlgenerator's Issues

Return the generated data in a string.

When working with a small product catalog, I want to generate and give it away each time a bot accesses without using files.

Acceptance criteria: the generated product catalog can be obtained as a string variable.

Yml file

How do I use that ^ & what is a yml file how do I paste tokens into my yml file??

How add custom stock tag?

How add custom stocks?

 <offer id="1638" available="false" group_id="12345">
        <url>http://example.com/product/id1638</url>
        <price>545.30</price>
        <categoryId>1293</categoryId>
        <categoryId>1345</categoryId>
        <picture>http://example.com/images/1638_1.jpg</picture>
        <name>Товар 2</name>
        <param name="Цвет">Белый</param>
        <description>Описание товара 1638</description>
        <vendor>Название производителя</vendor>
        <model>Модель товарного предложения</model>
        <stock id="Москва">
          <available>true</available>
          <price>500</price>
          <oldprice>550</oldprice>
          <url>http://example.com/product/id1638</url>
          <picture>http://example.com/images/1638_2.jpg</picture>
        </stock>
        <stock id="Екатеринбург">
          <available>true</available>
          <price>540.50</price>
          <oldprice>600</oldprice>
          <url>http://example.com/product/id1638</url>
          <picture>http://example.com/images/1638_3.jpg</picture>
        </stock>
      </offer>

Ability to add enable_auto_discounts tag for offers and shop info

https://yandex.ru/support/partnermarket/elements/enable_auto_discounts.html

Было бы полезно добавить возможность управлять тегом enable_auto_discounts глобально из ShopInfo и индивидуально в Offers, чтобы все было из коробки. Сейчас проблему можно решить наследованием. Предложение больше для удобства

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.