timothydc / laravel-lightspeed-ecom-product-feeds
Laravel Lightspeed 产品数据包的 Laravel 扩展包
v1.14.0
2022-10-25 14:11 UTC
Requires
- php: ^7.4|^8.0
- illuminate/support: ^7.0|^8.0|^9.0
- laravel/legacy-factories: ^1.0.5
- spatie/array-to-xml: ^2.10
- timothydc/laravel-lightspeed-ecom-api: ^1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^5.0|^6.0
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-09-25 18:13:57 UTC
README
安装
通过 Composer
$ composer require timothydc/laravel-lightspeed-ecom-product-feeds
您可以发布所有资源,也可以选择分别发布它们。
$ php artisan vendor:publish --tag="lightspeed-ecom-product-feed" $ php artisan vendor:publish --tag="lightspeed-ecom-product-feed:config" $ php artisan vendor:publish --tag="lightspeed-ecom-product-feed:migrations"
运行迁移以创建 product_feeds
表。
$ php artisan migrate
您可以选择通过任务调度器自动运行创建的数据包。也可以直接生成数据包或通过队列作业生成。更多配置选项请参阅 config/lightspeed-ecom-product-feed.php
。
return [ 'feed_disk' => env('LS_PRODUCT_FEEDS_FEED_DISK', 'public'), 'scheduled_tasks' => [ 'auto_run' => env('LS_PRODUCT_FEEDS_AUTO_RUN', true), 'use_queue' => env('LS_PRODUCT_FEEDS_USE_QUEUE', true), 'queue' => env('LS_PRODUCT_FEEDS_QUEUE', 'default') ], ];
自定义数据包映射
创建您自己的类,并让它实现 ProductPayloadMappingInterface
。或者查看 TimothyDC\LightspeedEcomProductFeed\Feeds\StandardFeed
获取一些 XML 数据结构灵感。
use TimothyDC\LightspeedEcomProductFeed\Interfaces\ProductPayloadMappingInterface; class CustomProductXml implements ProductPayloadMappingInterface { public function execute(string $baseUrl, array $product): array { return ['product_id' => $product['id']]; } }
此包还提供了一些模板数据包,例如:
- Sooqr (
TimothyDC\LightspeedEcomProductFeed\Feeds\SooqrFeed
)
可用命令
创建新的产品数据包,并回答提出的问题。当被要求时,输入有效的 cron 表达式。使用您的自定义类的全称(FQN)。
$ php artisan ecom-feed:create > Enter your custom mapping class: > Enter your cron interval: > Enter your webshop API key: > Enter your webshop API secret: > What language should your feed be in?
显示所有已创建的产品数据包列表。
$ php artisan ecom-feed:list
更新产品数据包。
$ php artisan ecom-feed:update {id}
显示产品数据包配置。
$ php artisan ecom-feed:show {id}
删除产品数据包。
$ php artisan ecom-feed:remove {id}
通过提供产品数据包 ID 生成 XML。
$ php artisan ecom-feed:generate {id}
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近发生了什么变化。
致谢
许可证
MIT。有关更多信息,请参阅 许可证文件。