Class: Spree::Admin::ProductsController
Instance Method Summary
collapse
belongs_to, create, #create, destroy, #edit, #new, new_action, update, #update_positions
included
#current_ability, included, #redirect_back_or_default, #store_location, #try_spree_current_user, #unauthorized
Instance Method Details
#clone ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/spree/admin/products_controller.rb', line 49
def clone
@new = @product.duplicate
if @new.save
flash.notice = I18n.t('notice_messages.product_cloned')
else
flash.notice = I18n.t('notice_messages.product_not_cloned')
end
respond_with(@new) { |format| format.html { redirect_to edit_admin_product_url(@new) } }
end
|
#destroy ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/spree/admin/products_controller.rb', line 37
def destroy
@product = Product.find_by_permalink!(params[:id])
@product.delete
flash.notice = I18n.t('notice_messages.product_deleted')
respond_with(@product) do |format|
format.html { redirect_to collection_url }
format.js { render_js_for_destroy }
end
end
|
#index ⇒ Object
16
17
18
19
|
# File 'app/controllers/spree/admin/products_controller.rb', line 16
def index
session[:return_to] = request.url
respond_with(@collection)
end
|
#search ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'app/controllers/spree/admin/products_controller.rb', line 21
def search
if params[:ids]
@products = Spree::Product.where(:id => params[:ids].split(","))
else
search_params = { :name_cont => params[:q], :sku_cont => params[:q] }
@products = Spree::Product.ransack(search_params.merge(:m => 'or')).result
end
end
|
#show ⇒ Object
11
12
13
14
|
# File 'app/controllers/spree/admin/products_controller.rb', line 11
def show
session[:return_to] ||= request.referer
redirect_to( :action => :edit )
end
|
#update ⇒ Object
30
31
32
33
34
35
|
# File 'app/controllers/spree/admin/products_controller.rb', line 30
def update
if params[:product][:taxon_ids].present?
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(',')
end
super
end
|