Skip to content

Instantly share code, notes, and snippets.

@Willianvdv
Last active January 2, 2016 09:09
Show Gist options
  • Save Willianvdv/8280899 to your computer and use it in GitHub Desktop.
Save Willianvdv/8280899 to your computer and use it in GitHub Desktop.
Extendable products controller
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