timothydc/laravel-lightspeed-ecom-product-feeds

Laravel package for Lightspeed product feeds

v1.14.0 2022-10-25 14:11 UTC

README

Latest Version on Packagist Total Downloads Github Tests Action Tests Github Tests Action Styling

Installation

Via Composer

$ composer require timothydc/laravel-lightspeed-ecom-product-feeds

You can publish all resources, or you may choose to publish them separately:

$ 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"

Run your migrations to create the product_feeds table.

$ php artisan migrate

You can choose to automatically run the created feeds via the task scheduler. It is also possible to generate the feeds directly or via a queue job. See config/lightspeed-ecom-product-feed.php for more configuration options.

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')
    ],
];

Custom feed mapping

Create your own class and let it implement ProductPayloadMappingInterface. Or take a look at TimothyDC\LightspeedEcomProductFeed\Feeds\StandardFeed for some XML data structure inspiration.

use TimothyDC\LightspeedEcomProductFeed\Interfaces\ProductPayloadMappingInterface;

class CustomProductXml implements ProductPayloadMappingInterface
{
    public function execute(string $baseUrl, array $product): array
    {
        return ['product_id' => $product['id']];
    }
}

This package also offers some template feeds for:

  • Sooqr (TimothyDC\LightspeedEcomProductFeed\Feeds\SooqrFeed)

Available commands

Create a new product feed and answer the presented questions. Enter a valid cron expression when asked. Use a FQN for your custom class.

$ 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?

Show a list of all the currently created product feeds.

$ php artisan ecom-feed:list

Update a product feed.

$ php artisan ecom-feed:update {id}

Show a product feed configuration.

$ php artisan ecom-feed:show {id}

Remove a product feed.

$ php artisan ecom-feed:remove {id}

Generate an XML by providing a product feed ID.

$ php artisan ecom-feed:generate {id}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Credits

License

MIT. Please see the license file for more information.