andrey-helldar/yandex-goods-prices

Simple Yandex Markup Generator for Online Stores.

v1.6.1 2020-12-30 19:50 UTC

This package is auto-updated.

Last update: 2021-11-29 20:15:47 UTC


README

Yandex Goods Prices

StyleCI Total Downloads Latest Stable Version Latest Unstable Version Travis CI License

Installation

To get the latest version of Laravel Yandex Goods Prives package, simply require the project using Composer:

composer require andrey-helldar/yandex-goods-prices

Instead, you may of course manually update your require block and run composer update if you so choose:

{
    "require": {
        "andrey-helldar/yandex-goods-prices": "^1.0"
    }
}

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php:

Helldar\Yandex\GoodsPrices\ServiceProvider::class,

You can also publish the config file to change implementations (ie. interface to specific class):

php artisan vendor:publish --provider="Helldar\Yandex\GoodsPrices\ServiceProvider"

Using

$currency = app('yandex_goods_prices')->currency()->id('RUB')->rate(2);
$category = app('yandex_goods_prices')->category()->id(1)->name('foo');

$offer = app('yandex_goods_prices')->offer()->other()
    ->id(1234)
    ->available()
    ->categoryId(2)
    ->countryOfOrigin('Россия')
    ->currencyId('USD')
    ->delivery(true)
    ->deliveryOptions(200)
    ->description('foo')
    ->downloadable(true)
    ->manufacturerWarranty('foo')
    ->model('bar')
    ->price(200)
    ->salesNotes('foo')
    ->typePrefix('foo')
    ->url('http://example.com')
    ->vendor('FOO')
    ->vendorCode('foo');

app('yandex_goods_prices')->service()
    ->categories($category, $category)
    ->currencies($currency)
    ->offers($offer)
    ->name('foo')
    ->company('bar')
    ->url('http://example.com')
    ->save();

Saved as:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
<yml_catalog date="2018-10-19 12:00">
    <shop>
        <company>bar</company>
        <name>foo</name>
        <url>http://example.com</url>
        <categories>
            <category id="1">foo</category>
            <category id="1">foo</category>
        </categories>
        <currencies>
            <currency id="RUB" rate="2"/>
        </currencies>
        <offers>
            <offer id="1234" type="audiobook" available="true">
                <categoryId>2</categoryId>
                <country_of_origin>Россия</country_of_origin>
                <currencyId>2</currencyId>
                <delivery>true</delivery>
                <delivery-options>200</delivery-options>
                <description>foo</description>
                <downloadable>true</downloadable>
                <manufacturer_warranty>foo</manufacturer_warranty>
                <model>bar</model>
                <price>200</price>
                <sales_notes>foo</sales_notes>
                <typePrefix>foo</typePrefix>
                <url>http://example.com</url>
                <vendor>FOO</vendor>
                <vendorCode>foo</vendorCode>
            </offer>
        </offers>
    </shop>
</yml_catalog>

You can also use an array for a categories(), currencies() and offers methods:

$currencies = [];

for ($i = 0; $i < 10; $i++) {
    $currency = app('yandex_goods_prices')->currency()->id('USD')->rate($i);
    
    array_push($currencies, $currency);
}

app('yandex_goods_prices')->service()
    ->categories($category_1, $category_2, $categories)
    ->currencies($currency_rur, $currencies)
    ->offers($offers, $offer_1, $offer_2)
    // ...

You can also see the implementation in the tests and read the official documentation.

Available offer types

  • AudioBook
  • Book
  • EventTicket
  • Music
  • Tour
  • Video
  • Other

To access a type with methods available to it, use the call:

app('yandex_goods_prices')->offer()->audioBook()
    
app('yandex_goods_prices')->offer()->book()
    
app('yandex_goods_prices')->offer()->eventTicket()
    
app('yandex_goods_prices')->offer()->music()
    
app('yandex_goods_prices')->offer()->tour()
    
app('yandex_goods_prices')->offer()->video()
    
app('yandex_goods_prices')->offer()->other()

License

This package is licensed under the MIT License.