Class: Spree::Admin::ZonedController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/zoned_controller.rb

Instance Method Summary collapse

Instance Method Details

#reorderObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/spree/admin/zoned_controller.rb', line 14

def reorder
  country = session[:zoned] && session[:zoned][:prd_country]
  return if !country || country.to_i >= 0
  country = country.to_i
  params[:positions].each do |id, index|
    zp = Spree::Zoned::Product.find_or_create_by_spree_product_id_and_spree_country_id(id, country)
    zp.orderno = index.to_i unless !zp.orderno.nil? && zp.orderno < 0
    zp.save
  end
  respond_to do |format|
    format.html { redirect_to admin_products_url }
    format.js  { render :text => 'Ok' }
  end
end

#setcountryObject



5
6
7
8
9
10
11
12
# File 'app/controllers/spree/admin/zoned_controller.rb', line 5

def setcountry
  respond_to do |format|
    format.js do
      session[:zoned] ||= {}
      session[:zoned][:prd_country] = params[%s{sel-prd-country}]
    end
  end
end