Compare commits

..
2 Commits
Author SHA1 Message Date
Joel Male a0d2837bd7 chore: bump version to 5.1.1 2026-04-11 08:32:33 +10:00
Joel Male 13d90a0f08 chore: update readme 2026-04-11 08:32:05 +10:00
3 changed files with 68 additions and 17 deletions
+67 -16
View File
@@ -1,33 +1,84 @@
Laravel Google Shopping Feed ![Laravel Google Shopping Feed](docs/laravel-google-shopping-feed.png)
==============
A simple package to easily create an XML feed for Google Merchant Center to parse and retrieve your products on a frequent basis. [![Latest Version on Packagist](https://img.shields.io/packagist/v/wearepixel/laravel-google-shopping-feed.svg)](https://packagist.org/packages/wearepixel/laravel-google-shopping-feed)
[![Tests](https://img.shields.io/github/actions/workflow/status/wearepixel/laravel-google-shopping-feed/tests.yml?label=tests)](https://github.com/wearepixel/laravel-google-shopping-feed/actions/workflows/tests.yml)
[![PHP Version](https://img.shields.io/packagist/php-v/wearepixel/laravel-google-shopping-feed.svg)](https://packagist.org/packages/wearepixel/laravel-google-shopping-feed)
[![Total Downloads](https://img.shields.io/packagist/dt/wearepixel/laravel-google-shopping-feed.svg)](https://packagist.org/packages/wearepixel/laravel-google-shopping-feed)
[![License](https://img.shields.io/packagist/l/wearepixel/laravel-google-shopping-feed.svg)](https://packagist.org/packages/wearepixel/laravel-google-shopping-feed)
We recommend adding this to an API controller and generating it on the fly each time so you can be sure your products are always up to date within your merchant center. A simple package to easily create an XML feed for Google Merchant Center to parse and retrieve your products.
We recommend adding this to an API controller and generating it on the fly so your feed is always up to date.
## Requirements
- PHP 8.4+
- Laravel 10, 11, or 12
## Installation ## Installation
``` ```bash
composer require wearepixel/laravel-google-shopping-feed composer require wearepixel/laravel-google-shopping-feed
``` ```
## Example ## Usage
```php ```php
use Wearepixel\LaravelGoogleShoppingFeed\LaravelGoogleShoppingFeed; use Wearepixel\LaravelGoogleShoppingFeed\LaravelGoogleShoppingFeed;
$feed = LaravelGoogleShopping::init( $feed = LaravelGoogleShoppingFeed::init(
'Product Feed', title: 'My Store',
'App product Feed', description: 'My store product feed',
'https://mystore.com' link: 'https://mystore.com',
); );
$feed->addItem([ $feed->addItem([
'id' => 'item_001', 'id' => 'item_001',
'title' => 'Blue Nikes', 'title' => 'Blue Nikes',
'link' => 'https://mystore.com/products/blue-nikes', 'link' => 'https://mystore.com/products/blue-nikes',
'g:image_link' => 'https://mystore.com/images/blue-nikes-001.jpg', 'g:price' => '29.99 AUD',
'g:price' => 29.99, 'g:image_link' => 'https://mystore.com/images/blue-nikes-001.jpg',
]); ]);
return $feed->generate(); return $feed->generate();
``` ```
### Required item fields
| Field | Description |
| -------------- | ------------------------------------------------ |
| `id` | Unique product identifier |
| `title` | Product name |
| `link` | URL to the product page |
| `g:price` | Price including currency code (e.g. `29.99 AUD`) |
| `g:image_link` | URL to the main product image |
Any additional fields supported by the [Google Product Data Specification](https://support.google.com/merchants/answer/7052112) can be passed alongside the required fields.
### Methods
**`LaravelGoogleShoppingFeed::init(string $title, string $description, string $link): static`**
Creates a new feed instance with channel metadata.
**`$feed->addItem(array $item): void`**
Adds a product to the feed. Throws `MissingRequiredFieldException` if any required field is absent.
**`$feed->toXml(): string`**
Returns the feed as an XML string.
**`$feed->generate(): Response`**
Returns an HTTP response with the XML content and `application/rss+xml` content type. Suitable for returning directly from a controller.
## Testing
```bash
composer test
```
## License
MIT
+1 -1
View File
@@ -6,7 +6,7 @@
"laravel", "laravel",
"google-shopping-feed" "google-shopping-feed"
], ],
"version": "5.1.0", "version": "5.1.1",
"homepage": "https://github.com/wearepixel/laravel-google-shopping-feed", "homepage": "https://github.com/wearepixel/laravel-google-shopping-feed",
"license": "MIT", "license": "MIT",
"authors": [ "authors": [
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB