diff --git a/admin/app/components/solidus_admin/products/index/component.rb b/admin/app/components/solidus_admin/products/index/component.rb index b8a3648e17d..df52184f00e 100644 --- a/admin/app/components/solidus_admin/products/index/component.rb +++ b/admin/app/components/solidus_admin/products/index/component.rb @@ -62,6 +62,10 @@ def filters def scopes [ { name: :all, label: t('.scopes.all'), default: true }, + { name: :in_stock, label: t('.scopes.in_stock') }, + { name: :out_of_stock, label: t('.scopes.out_of_stock') }, + { name: :available, label: t('.scopes.available') }, + { name: :discontinued, label: t('.scopes.discontinued') }, { name: :deleted, label: t('.scopes.deleted') }, ] end diff --git a/admin/app/components/solidus_admin/products/index/component.yml b/admin/app/components/solidus_admin/products/index/component.yml index eec0674346d..8ae8270bd25 100644 --- a/admin/app/components/solidus_admin/products/index/component.yml +++ b/admin/app/components/solidus_admin/products/index/component.yml @@ -9,4 +9,8 @@ en: with_deleted: Include deleted scopes: all: All + available: Available + discontinued: Discontinued + in_stock: In stock + out_of_stock: Out of stock deleted: Deleted diff --git a/admin/app/controllers/solidus_admin/products_controller.rb b/admin/app/controllers/solidus_admin/products_controller.rb index c82a5ebd1a8..997282b05d0 100644 --- a/admin/app/controllers/solidus_admin/products_controller.rb +++ b/admin/app/controllers/solidus_admin/products_controller.rb @@ -6,6 +6,10 @@ class ProductsController < SolidusAdmin::BaseController search_scope(:all, default: true) search_scope(:deleted) { _1.with_discarded.discarded } + search_scope(:discontinued) { _1.where(discontinue_on: ...Time.current) } + search_scope(:available) { _1.available } + search_scope(:in_stock) { _1.where(id: Spree::Variant.in_stock.distinct.select(:product_id)) } + search_scope(:out_of_stock) { _1.where.not(id: Spree::Variant.in_stock.distinct.select(:product_id)) } def index products = apply_search_to(