Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamsaint/yml
Yandex Market YML Writer
https://github.com/iamsaint/yml
php yandex-market yml
Last synced: 13 days ago
JSON representation
Yandex Market YML Writer
- Host: GitHub
- URL: https://github.com/iamsaint/yml
- Owner: iamsaint
- License: bsd-3-clause
- Created: 2018-06-25T14:12:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-26T11:44:23.000Z (about 3 years ago)
- Last Synced: 2024-10-12T01:22:54.668Z (about 1 month ago)
- Topics: php, yandex-market, yml
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/iamsaint/yml/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/iamsaint/yml/?branch=master) [![Code Intelligence Status](https://scrutinizer-ci.com/g/iamsaint/yml/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) [![Build Status](https://scrutinizer-ci.com/g/iamsaint/yml/badges/build.png?b=master)](https://scrutinizer-ci.com/g/iamsaint/yml/build-status/master) [![Latest Stable Version](https://poser.pugx.org/iamsaint/yml/v/stable)](https://packagist.org/packages/iamsaint/yml) [![Total Downloads](https://poser.pugx.org/iamsaint/yml/downloads)](https://packagist.org/packages/iamsaint/yml) [![License](https://poser.pugx.org/iamsaint/yml/license)](https://packagist.org/packages/iamsaint/yml) [![Monthly Downloads](https://poser.pugx.org/iamsaint/yml/d/monthly)](https://packagist.org/packages/iamsaint/yml)
Installation
-------------
```
composer require iamsaint/yml
```After that, make sure your application autoloads Composer classes by including
`vendor/autoload.php`.How to use it
-------------```php
use iamsaint\yml\Writer;
use iamsaint\yml\components\{
Shop,
Currency,
Category
}// create shop
$shop = new Shop();
$shop->setName('Shop Name')
->setUrl('http://...')
->setCompany('My Company');// create currency
$currency = new Currency();
$currency
->setId(Currency::RUR)
->setRate(Currency::DEFAULT_RATE);// add currency
$shop->addCurrency($currency);// create category
$category = new Category();
$category
->setId(1)
->setName("My category");// create subcategory
$subCategory = new Category();
$subCategory
->setId(2)
->setParentId(1)
->setName("My subcategory");// add categories to shop
$shop->addCategory($category);
$shop->addCategory($subCategory);// create offer
$offer = new Offer();$offer->setId(123)
->setUrl('http://...')
->setPrice(1000)
->setCurrencyId(Currency::RUR);// add offer to shop
$shop->addOffer($offer);// create writer
$writer = new Writer();// write to file
$writer->write('path/to/file.yml', $shop);```