andrey-helldar / yandex-goods-prices
该包已被废弃,不再维护。未建议替代包。
适用于在线商店的简单Yandex标记生成器。
v1.6.1
2020-12-30 19:50 UTC
Requires
- php: >=7.1.3|^8.0
- ext-dom: *
- andrey-helldar/xml-core: ^1.0
- illuminate/validation: ^5.6|^6.0|^7.0|^8.0
- symfony/http-kernel: ^4.0|^5.0
Requires (Dev)
- orchestra/testbench: ^3.8|^4.0
- phpunit/phpunit: ^7.5|^8.0|^9.0
Suggests
- symfony/thanks: Give thanks (in the form of a GitHub) to your fellow PHP package maintainers
README
安装
要获取Laravel Yandex Goods Prices包的最新版本,只需使用 Composer 引入项目
composer require andrey-helldar/yandex-goods-prices
当然,您也可以手动更新require块并运行 composer update
,如果选择这样做
{ "require": { "andrey-helldar/yandex-goods-prices": "^1.0" } }
如果您不使用自动发现,请将 ServiceProvider
添加到 config/app.php
文件中的 providers 数组
Helldar\Yandex\GoodsPrices\ServiceProvider::class,
您还可以发布配置文件以更改实现(即接口到特定类)
php artisan vendor:publish --provider="Helldar\Yandex\GoodsPrices\ServiceProvider"
使用
$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();
保存为
<?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>
您还可以使用数组为 categories()
、currencies()
和 offers
方法
$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) // ...
可用的报价类型
- 有声书
- 书籍
- 活动门票
- 音乐
- 旅游
- 视频
- 其他
要访问具有可用方法的类型,请使用调用
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()
许可证
此包根据 MIT许可证 授权。