Solidus Product Feed

CircleCI

An extension that provides an RSS feed for products. Google Merchant Feed attributes are also implemented. An RSS link is automatically appended to the <head> tag in the layouts/spree_application file.

Installation

Add the gem to your Gemfile:

gem 'solidus_product_feed'

Install the gem:

$ bundle install

You're done! You can now see your RSS feed at /products.rss.

Usage

The feed ships with sensible defaults for your products, but customization is very easy.

Headers

You can easily change the feed's headers by putting the following in your Rails initializer:

SolidusProductFeed.configure do |config|
  config.title = 'My Awesome Store'
  config.link = 'https://www.awesomestore.com'
  config.description = 'Find out about new products on https://www.awesomestore.com first!'
  config.language = 'en-us'
end

Note that you can also pass a Proc for each of these options. The Proc will be passed the view context as its only argument, so that you can use all your helpers:

SolidusProductFeed.configure do |config|
  config.title = -> (view) { view.current_store.name }
  config.link = -> (view) { "http://#{view.current_store.url}" }
  config.description = -> (view) { "Find out about new products on http://#{view.current_store.url} first!" }
  config.language = -> (view) { view.lang_from_store(current_store.language) }
end

Item schema

If you need to alter the XML schema of a product (e.g. to add/remove a tag), you can do it by subclassing Spree::FeedProduct in your app and overriding the schema method:

module AwesomeStore
  class FeedProduct < Spree::FeedProduct
    def schema
      super.merge('g:brand' => 'Awesome Store Inc.')
    end
  end
end

Then set your custom class in an initializer:

SolidusProductFeed.configure do |config|
  config.feed_product_class = 'AwesomeStore::FeedProduct'
end

If you want to change the value of an existing tag, you can also simply override the corresponding tag method (link, price etc.). Check the source code for more details.

Testing

Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.

$ bundle exec rake test app
$ bundle exec rspec spec