Class: Spree::Admin::ProductsController
Instance Method Summary
collapse
belongs_to, create, #create, destroy, #edit, #new, new_action, update, #update_positions
Instance Method Details
#clone ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/spree/admin/products_controller.rb', line 43
def clone
@new = @product.duplicate
if @new.save
flash[:success] = Spree.t('notice_messages.product_cloned')
else
flash[:success] = Spree.t('notice_messages.product_not_cloned')
end
redirect_to edit_admin_product_url(@new)
end
|
#destroy ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/spree/admin/products_controller.rb', line 31
def destroy
@product = Product.find_by_permalink!(params[:id])
@product.destroy
flash[:success] = Spree.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
|
#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
|
#stock ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/spree/admin/products_controller.rb', line 55
def stock
@variants = @product.variants
@variants = [@product.master] if @variants.empty?
@stock_locations = StockLocation.accessible_by(current_ability, :read)
if @stock_locations.empty?
flash[:error] = Spree.t(:stock_management_requires_a_stock_location)
redirect_to admin_stock_locations_path
end
end
|
#update ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/spree/admin/products_controller.rb', line 21
def update
if params[:product][:taxon_ids].present?
params[:product][:taxon_ids] = params[:product][:taxon_ids].split(',')
end
if params[:product][:option_type_ids].present?
params[:product][:option_type_ids] = params[:product][:option_type_ids].split(',')
end
super
end
|