Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Related products extension for Spree Commerce.
Ruby HTML Other
Latest commit 75e39e0 @alepore alepore Deface: don't manually require override files
as this can cause problems for precompiling

Related Products

Build Status Code Climate

This extension provides a generic way for you to define different types of relationships between your products, by defining a RelationType for each type of relationship you'd like to maintain.

You can manage RelationTypes via the admin configuration menu, and you can maintain product relationships via Related Products tab on the edit product UI.

Possible uses

  • Accessories
  • Cross Sells
  • Up Sells
  • Compatible Products
  • Replacement Products
  • Warranty & Support Products

Relation Types

When you create a RelationType you can access that set of related products by referencing the relation_type name, see below for an example:

rt = Spree::RelationType.create(name: 'Accessories', applies_to: 'Spree::Product')
 => #<Spree::RelationType id: 4, name: "Accessories" ...>
product = Spree::Product.last
 => #<Spree::Product id: 1060500592 ...>
 => []

Since respond_to? will not work in this case, you can test whether a relation_type method exists with has_related_products?(method):

# => true

if product.has_related_products?('accessories')
  # Display an accessories box..

You can access all related products regardless of RelationType by:

 => []

Discounts You can optionally specify a discount amount to be applied if a customer purchases both products.

Note: In order for the coupon to be automatically applied, you must create a promotion leaving the code value empty, and adding an Action of type : RelatedProductDiscount (blank codes are required for coupons to be automatically applied).


Add to Gemfile:

gem 'spree_related_products', github: 'spree-contrib/spree_related_products', branch: 'master'


$ bundle && bundle exec rails g spree_related_products:install


See corresponding guidelines

Copyright (c) 2010-2015 Brian Quinn and contributors, released under the New BSD License

Something went wrong with that request. Please try again.