public
Description: Spree is a complete open source e-commerce solution for Ruby on Rails.
Home | Edit | New

Developers' Tricks and Tips

Intro

This page is a collection of tips and tricks from Spree developers which might be helpful to others.

There is a section of the guides with this name, but think of that as the polished version of this page. So this page is very much for the whole community to share and discuss tips. The guide will regularly be updated with the best ideas from here.

These are some notes on how you should customize your Spree application so as to minimize the amount of trouble you will have when upgrading to future releases.

Never modify your application’s boot.rb or environment.rb

Put the custom configuration logic for your application inside of a custom initializer instead.

ex. config/initializers/myapp.rb


ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.default_charset = “utf-8”

Upload scripts

Manually adding products can be a bit tedious when you have a large number to add. Here’s a collection of code which might be helpful. Some of these might include some site customizations, so remove any lines which contain attributes/objects you don’t recognise.

  • paulcc’s product family and variant script
    • Reads a CSV file and assembles products and variants from it
    • “product families” share most fields but may differ in master price and “format”, eg we want to have “Widget – small” and “Widget – big” listed as two products, not as variants; such families are defined by a complete row plus zero or more lines where the product name is missing
    • the basic code for adding variants is here, but I only use it for adding colour variants: currently, if there’s multiple entries in the Colour field, then create one variant for each option.
    • Image file names are checked and then uploaded and attached to the current product
    • Taxon info comes from a column, and “foo, bar, wibble” means create or add this product to a taxon “wibble” which has ancestors “bar” and “foo”, ie you don’t have to declare taxon str in advance, it creates it on the fly…
    • Some support for converting nominated columns into product properties
    • There’s a few other data manipulations
    • No prizes for guessing which site this comes from; if you have questions, please contact paulcc on github.
Last edited by paulcc, Sun Jun 28 01:18:25 -0700 2009
Home | Edit | New
Versions: