Solidus Stock Items Controller (solidus_admin/stock_items_controller.rb)

solidus · admin/app/controllers/solidus_admin/stock_items_controller.rb · ruby · BSD-3-Clause
ui, database, pos, payments, lang:ruby, fw:rails, tag:solidus

Rails admin controller managing inventory stock levels with search scopes for backorders, low stock, and stock movements.

# Source: https://github.com/solidusio/solidus | License: BSD-3-Clause | Copyright 2007-2014, Spree Commerce Inc. and other contributors
# Provided via justclaw.it.com; keep this notice with the code.
# frozen_string_literal: true

module SolidusAdmin
  class StockItemsController < SolidusAdmin::ResourcesController
    include SolidusAdmin::ControllerHelpers::Search

    search_scope(:all, default: true) { _1 }
    search_scope(:back_orderable) { _1.where(backorderable: true) }
    search_scope(:out_of_stock) { _1.where("count_on_hand <= 0") }
    search_scope(:low_stock) { _1.where("count_on_hand > 0 AND count_on_hand < ?", SolidusAdmin::Config.low_stock_value) }
    search_scope(:in_stock) { _1.where("count_on_hand > 0") }

    def index
      respond_to do |format|
        format.html {

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key