Monday, July 17, 2017

Spree Commerce Customization

Spree Commerce Customization

Spree Commerce Customization

  1. Create an image with 116x50 pixels named “spree_50.png” and put it at app/assets/images/logo/.

  2. Using a new file to overwrite the original one.

    • Create a new file app/models/spree/app_configuration.rb.

    • copy the content of
      (user)/.rvm/gems/ruby02.X.X/gems/spree_core/app/model/spree/app_configuration.rb“`

    • Modify the default preference:

      preference :logo, :string, default: 'logo/spree_50.png'

      change spree_50.pngto xxx.png

  3. Decorator design pattern

    Add a decorative file:
    app/models/spree/app_configuration_decorator.rb

    then, add xxx.png as your logo image.

Spree::AppConfiguration.class_eval do
  preference :logo, :string, default: 'logo/xxx.png'
end

The decorator design pattern is a better solution for changing the default logo for Spree site.

Deployment

bundle exec rake railties:install:migrations
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake spree_sample:load

Demo Site

The demo site:
- Demoshop
- Admin page, login as: admin@test.com/spree123

The code base is here

No comments:

Post a Comment