PHPackages                             vitalybaev/google-merchant-feed - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. vitalybaev/google-merchant-feed

ActiveLibrary[API Development](/categories/api)

vitalybaev/google-merchant-feed
===============================

PHP package for creating Google Merchant products feed

v2.6.0(3y ago)911.0M↓42.4%33[13 issues](https://github.com/vitalybaev/php-google-merchant-feed/issues)[4 PRs](https://github.com/vitalybaev/php-google-merchant-feed/pulls)4MITPHPPHP &gt;=5.5

Since May 29Pushed 1y ago6 watchersCompare

[ Source](https://github.com/vitalybaev/php-google-merchant-feed)[ Packagist](https://packagist.org/packages/vitalybaev/google-merchant-feed)[ RSS](/packages/vitalybaev-google-merchant-feed/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (23)Used By (4)

Google Merchant feed generator for PHP
======================================

[](#google-merchant-feed-generator-for-php)

[![Build Status](https://camo.githubusercontent.com/859204c9fce8fd6afe54b80a76b21d068320406c23162dc5d1f485639ffb26f5/68747470733a2f2f7472617669732d63692e6f72672f766974616c79626165762f7068702d676f6f676c652d6d65726368616e742d666565642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vitalybaev/php-google-merchant-feed)

Installation
------------

[](#installation)

Install the package through [Composer](http://getcomposer.org/).

Run the Composer require command from the Terminal:

```
composer require vitalybaev/google-merchant-feed

```

Example
-------

[](#example)

```
use Vitalybaev\GoogleMerchant\Feed;
use Vitalybaev\GoogleMerchant\Product;
use Vitalybaev\GoogleMerchant\Product\Shipping;
use Vitalybaev\GoogleMerchant\Product\Availability\Availability;

// Create feed object
$feed = new Feed("My awesome store", "https://example.com", "My awesome description");

// Put products to the feed ($products - some data from database for example)
foreach ($products as $product) {
    $item = new Product();

    // Set common product properties
    $item->setId($product->id);
    $item->setTitle($product->title);
    $item->setDescription($product->description);
    $item->setLink($product->getUrl());
    $item->setImage($product->getImage());
    if ($product->isAvailable()) {
        $item->setAvailability(Availability::IN_STOCK);
    } else {
        $item->setAvailability(Availability::OUT_OF_STOCK);
    }
    $item->setPrice("{$product->price} USD");
    $item->setGoogleCategory($product->category_name);
    $item->setBrand($product->brand->name);
    $item->setGtin($product->barcode);
    $item->setCondition('new');

    // Some additional properties
    $item->setColor($product->color);
    $item->setSize($product->size);

    // Shipping info
    $shipping = new Shipping();
    $shipping->setCountry('US');
    $shipping->setRegion('CA, NSW, 03');
    $shipping->setPostalCode('94043');
    $shipping->setLocationId('21137');
    $shipping->setService('UPS Express');
    $shipping->setPrice('1300 USD');
    $item->setShipping($shipping);

    // Set a custom shipping label and weight (optional)
    $item->setShippingLabel('ups-ground');
    $item->setShippingWeight('2.14');

    // Set a custom label (optional)
    $item->setCustomLabel('Some Label 1', 0);
    $item->setCustomLabel('Some Label 2', 1);

    // Add this product to the feed
    $feed->addProduct($item);
}

// Here we get complete XML of the feed, that we could write to file or send directly
$feedXml = $feed->build();
```

Working with attributes
-----------------------

[](#working-with-attributes)

`Product` class provides several methods for managing various attributes. But it doesn't cover all Google Merchant attributes. In case of nonexistent methods you should use one of the following:

1. `$product->setAttribute($attributeName, $attributeValue, $isCData = false)` - sets attribute. Replaces old attribute if it existed.
2. `$product->addAttribute($attributeName, $attributeValue, $isCData = false)` - adds one more attribute's value. For example feed can have multiple `additional_image_link` attributes.

TO-DO
-----

[](#to-do)

- Cover all Google Merchant feed properties
- More tests
- Your feedback?

License
-------

[](#license)

```
The MIT License

Copyright (c) 2016 Vitaly Baev. vitalybaev.ru

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance24

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 65.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Recently: every ~116 days

Total

22

Last Release

1289d ago

Major Versions

v0.9.0 → v1.0.02017-05-29

v1.2.0 → v2.0.02019-07-27

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/724423?v=4)[Vitaly Baev](/maintainers/vitalybaev)[@vitalybaev](https://github.com/vitalybaev)

---

Top Contributors

[![vitalybaev](https://avatars.githubusercontent.com/u/724423?v=4)](https://github.com/vitalybaev "vitalybaev (19 commits)")[![michelmelo](https://avatars.githubusercontent.com/u/159223?v=4)](https://github.com/michelmelo "michelmelo (2 commits)")[![ololower](https://avatars.githubusercontent.com/u/9454679?v=4)](https://github.com/ololower "ololower (2 commits)")[![krylov123](https://avatars.githubusercontent.com/u/5936254?v=4)](https://github.com/krylov123 "krylov123 (1 commits)")[![andezdev](https://avatars.githubusercontent.com/u/35426566?v=4)](https://github.com/andezdev "andezdev (1 commits)")[![incredimike](https://avatars.githubusercontent.com/u/125589?v=4)](https://github.com/incredimike "incredimike (1 commits)")[![tegansnyder](https://avatars.githubusercontent.com/u/1200195?v=4)](https://github.com/tegansnyder "tegansnyder (1 commits)")[![toniop99](https://avatars.githubusercontent.com/u/35426566?v=4)](https://github.com/toniop99 "toniop99 (1 commits)")[![jakeday](https://avatars.githubusercontent.com/u/554899?v=4)](https://github.com/jakeday "jakeday (1 commits)")

---

Tags

google-merchantphpgooglefeedmerchant

### Embed Badge

![Health badge](/badges/vitalybaev-google-merchant-feed/health.svg)

```
[![Health](https://phpackages.com/badges/vitalybaev-google-merchant-feed/health.svg)](https://phpackages.com/packages/vitalybaev-google-merchant-feed)
```

###  Alternatives

[google/apiclient

Client library for Google APIs

9.8k205.9M1.1k](/packages/google-apiclient)[google/apiclient-services

Client library for Google APIs

1.3k195.1M62](/packages/google-apiclient-services)[google/gax

Google API Core for PHP

267116.3M567](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

175117.7M73](/packages/google-common-protos)[laminas/laminas-feed

provides functionality for creating and consuming RSS and Atom feeds

16751.3M62](/packages/laminas-laminas-feed)[google-gemini-php/client

Gemini API is a supercharged PHP API client that allows you to interact with the Gemini API

4101.5M38](/packages/google-gemini-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
