Class: Spree::Billing::ProductsController
- Inherits:
-
BaseController
- Object
- Admin::ResourceController
- BaseController
- Spree::Billing::ProductsController
show all
- Defined in:
- app/controllers/spree/billing/products_controller.rb
Instance Method Summary
collapse
#collection_url, #current_vendor, #default_url_options, #edit_object_url, #handle_unauthorized_vendor, #page, #per_page, #required_vendor_user!, #set_locale, #switch_vendor, #vendors
#auth_action, #auth_entry, #auth_user, #authorize!, #authorize?, #authorize_admin, #authorize_role!, #redirect_unauthorized_access
Instance Method Details
#collection ⇒ Object
10
11
12
13
14
15
|
# File 'app/controllers/spree/billing/products_controller.rb', line 10
def collection
return @collection if defined?(@collection)
@search = scope.ransack(params[:q])
@collection = @search.result.page(page).per(per_page)
end
|
#find_resource ⇒ Object
25
26
27
|
# File 'app/controllers/spree/billing/products_controller.rb', line 25
def find_resource
scope.find_by(slug: params[:id])
end
|
#load_data ⇒ Object
17
18
19
20
21
22
|
# File 'app/controllers/spree/billing/products_controller.rb', line 17
def load_data
@option_types = OptionType.order(:name)
@tax_categories = TaxCategory.order(:name)
@shipping_categories = ShippingCategory.order(:name)
@businesses = Spree::Taxonomy.businesses.taxons.where('depth > ? ', 1).order('parent_id ASC').uniq
end
|
#location_after_save ⇒ Object
29
30
31
|
# File 'app/controllers/spree/billing/products_controller.rb', line 29
def location_after_save
edit_billing_product_url(@product)
end
|
#model_class ⇒ Object
47
48
49
|
# File 'app/controllers/spree/billing/products_controller.rb', line 47
def model_class
Spree::Product
end
|
#object_name ⇒ Object
51
52
53
|
# File 'app/controllers/spree/billing/products_controller.rb', line 51
def object_name
'product'
end
|
#scope ⇒ Object
6
7
8
|
# File 'app/controllers/spree/billing/products_controller.rb', line 6
def scope
current_vendor.products.where(subscribable: true)
end
|
#stock ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'app/controllers/spree/billing/products_controller.rb', line 37
def stock
@variants = @product.variants.includes(*variant_stock_includes)
@variants = [@product.master] if @variants.empty?
@stock_locations = StockLocation.accessible_by(current_ability)
return unless @stock_locations.empty?
flash[:error] = Spree.t(:stock_management_requires_a_stock_location)
redirect_to spree.admin_stock_locations_path
end
|
#variant_stock_includes ⇒ Object
33
34
35
|
# File 'app/controllers/spree/billing/products_controller.rb', line 33
def variant_stock_includes
[:images, { stock_items: :stock_location, option_values: :option_type }]
end
|