项目作者: iamsaint

项目描述 :
Yandex Market YML Writer
高级语言: PHP
项目地址: git://github.com/iamsaint/yml.git
创建时间: 2018-06-25T14:12:55Z
项目社区:https://github.com/iamsaint/yml

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Scrutinizer Code Quality Code Intelligence Status Build Status Latest Stable Version Total Downloads License Monthly Downloads

Installation

  1. composer require iamsaint/yml

After that, make sure your application autoloads Composer classes by including
vendor/autoload.php.

How to use it

  1. use iamsaint\yml\Writer;
  2. use iamsaint\yml\components\{
  3. Shop,
  4. Currency,
  5. Category
  6. }
  7. // create shop
  8. $shop = new Shop();
  9. $shop->setName('Shop Name')
  10. ->setUrl('http://...')
  11. ->setCompany('My Company');
  12. // create currency
  13. $currency = new Currency();
  14. $currency
  15. ->setId(Currency::RUR)
  16. ->setRate(Currency::DEFAULT_RATE);
  17. // add currency
  18. $shop->addCurrency($currency);
  19. // create category
  20. $category = new Category();
  21. $category
  22. ->setId(1)
  23. ->setName("My category");
  24. // create subcategory
  25. $subCategory = new Category();
  26. $subCategory
  27. ->setId(2)
  28. ->setParentId(1)
  29. ->setName("My subcategory");
  30. // add categories to shop
  31. $shop->addCategory($category);
  32. $shop->addCategory($subCategory);
  33. // create offer
  34. $offer = new Offer();
  35. $offer->setId(123)
  36. ->setUrl('http://...')
  37. ->setPrice(1000)
  38. ->setCurrencyId(Currency::RUR);
  39. // add offer to shop
  40. $shop->addOffer($offer);
  41. // create writer
  42. $writer = new Writer();
  43. // write to file
  44. $writer->write('path/to/file.yml', $shop);