Search by

itmosoft / laravel-product-feeds

adeelrao007

Product feed generation for Laravel applications, with configurable fields, CSV, XML and JSON exports, secure feed URLs, and scheduled regeneration hooks.

Package info

github.com/ITMOSOFT/laravel-product-feeds

pkg:composer/itmosoft/laravel-product-feeds

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-17 12:01 UTC

This package is auto-updated.

Last update: 2026-11-17 12:02:39 UTC


README

Generate reusable product feeds for external channels and integrations using CSV, XML, or JSON.

Requirements

  • PHP 8.3+
  • Laravel 12 or 13
  • PHP XMLWriter extension for XML output

Installation

composer require itmosoft/laravel-product-feeds
php artisan vendor:publish --tag=product-feeds-config
php artisan migrate

Laravel package discovery registers the service provider automatically.

Create a feed

A feed stores a mapping from output field names to product attribute paths. The plaintext token is returned only once when creating the feed; only its SHA-256 hash is stored.

use ItmoSoft\ProductFeeds\Models\ProductFeed;

[$feed, $plainToken] = ProductFeed::createWithToken([
    'name' => 'Google Merchant Feed',
    'format' => 'xml',
    'fields' => [
        'id' => 'id',
        'title' => 'name',
        'description' => 'description',
        'price' => 'price',
        'availability' => 'stock_status',
        'image_link' => 'primary_image_url',
    ],
    'filters' => [
        ['field' => 'price', 'operator' => 'greater_than', 'value' => 0],
        ['field' => 'availability', 'operator' => 'not_null'],
    ],
]);

// Store $plainToken securely. It cannot be retrieved later.

Generate a feed

Pass an iterable of arrays, objects, or Eloquent models. The package does not assume a specific product-catalog package or product model.

$products = Product::query()
    ->where('is_active', true)
    ->cursor();

$feed->generate($products);

The generated file is saved to the configured filesystem disk under product-feeds/{feed-id}.{format} by default. The model records its file path, item count, and generation timestamp.

Download endpoint

The package registers a token-protected download route by default:

GET /product-feeds/{token}

The route returns the most recently generated file. The token is compared by hash; the plaintext token is never stored. Disable the route or customize its prefix and middleware in config/product-feeds.php.

Supported formats

  • CSV
  • XML
  • JSON

Supported filter operators

  • equals
  • not_equals
  • not_null
  • contains
  • greater_than
  • greater_than_or_equal
  • less_than

All configured filters are combined using AND logic. Filters apply to mapped output fields, not directly to arbitrary database query expressions.

Scheduled generation

Use Laravel Scheduler and a queued job or application command to fetch products and call generate(). The package deliberately does not assume a product catalog schema or register a schedule automatically.

Security notes

  • Feed tokens are generated using a cryptographically secure random source.
  • Only SHA-256 token hashes are persisted.
  • The plaintext token is returned only during feed creation.
  • Treat feed URLs as secrets and rotate them by creating a replacement feed token through your application's administrative workflow.
  • The download endpoint returns 404 for inactive feeds or feeds without a generated file.

Scope boundaries

This package generates and serves feeds. It does not connect to Google Merchant Center, Meta Catalog, TikTok Shop, marketplaces, or supplier APIs; does not import products; and does not synchronize remote channel status. Implement channel-specific submission and scheduling in your application or future integration packages.

Testing

composer install
composer test

License

MIT.