|Johann Boutet 47663aae75 Fix bug with translations.||6 years ago|
|app||6 years ago|
|bin||6 years ago|
|config||6 years ago|
|db/migrate||6 years ago|
|docs||6 years ago|
|lib||6 years ago|
|spec||6 years ago|
|.gitignore||6 years ago|
|.rspec||6 years ago|
|Gemfile||6 years ago|
|LICENSE||6 years ago|
|README.md||6 years ago|
|Rakefile||6 years ago|
|spree_featured.gemspec||6 years ago|
This Spree extension allows you to mark some products as featured, for example to display them on the homepage.
It integrates with Spree admin backend to allow you to change the featured state of each product both on the products listing page and the product edit form.
Add spree_featured to your Gemfile:
gem 'spree_featured', github: 'johannboutet/spree_featured', branch: '3-0-stable'
Bundle your dependencies and run the installation generator:
bundle bundle exec rails g spree_featured:install
This will add a
featured column to all products that defaults t
On the products listing page, a Featured column is added before the actions column. It shows a switch reflecting the featured state of the product.
When a switch is toggled, an Ajax request is sent to the Spree Api to update the corresponding product.
If the current admin user doesn’t have an Api key associated with his account, the switch toggle event simply submits the form to the normal update route. Therefore, the user is redirected to the product edit page. To avoid being redirected every time you change a switch, make sure the admin user you are using has an Api key.
A checkbox is also added to the product edit page, under the Description text area.
This extension adds a
only_featured search scope to the Product model so that you can retrieve featured products easily.
# home_controller_decorator.rb module Spree HomeController.class_eval do def index @products = Product.only_featured end end end
First bundle your dependencies, then run
rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using
bundle bundle exec rake
When testing your applications integration with this extension you may use it’s factories. Simply add this require statement to your spec_helper:
Copyright © 2015 Johann Boutet, released under the New BSD License