Class: Spree::Api::V2::ProductsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/products_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



7
8
9
# File 'app/controllers/spree/api/v2/products_controller.rb', line 7

def index
  render_collection products.includes :variants, :master, :taxons, :option_types, master: :images
end

#showObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/spree/api/v2/products_controller.rb', line 11

def show
  if params[:price_id]
    render_instance Spree::Price.find(params[:price_id]).product
  elsif params[:variant_id]
    render_instance Spree::Variant.find(params[:variant_id]).product
  elsif params[:image_id]
    render_instance Spree::Image.variants.find(params[:image_id]).viewable.product
  else
    render_instance products.find(params[:id])
  end
end