Last active
January 2, 2016 09:09
-
-
Save Willianvdv/8280899 to your computer and use it in GitHub Desktop.
Extendable products controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spree | |
module Admin | |
class ProductController < Spree::Admin::ResourceController | |
include ActiveSupport::Callbacks | |
define_callbacks :load_collection | |
set_callback :load_collection, :after, :paginate_collection | |
def index | |
respond_with(@collection) | |
end | |
private | |
def collection | |
return @collection if @collection.present? | |
run_callbacks :load_collection do | |
@collection = super | |
end | |
@collection | |
end | |
def paginate_collection | |
@collection = @collection.page(params[:page]).per(Spree::Config[:admin_products_per_page]) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment