Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Added `Product#archived` and `#not_archived` scopes

Damian Legawiec8027aa8fc895
diff --git a/core/app/models/concerns/spree/product_scopes.rb b/core/app/models/concerns/spree/product_scopes.rb
index a4e852b6cc..28a6596f90 100644
--- a/core/app/models/concerns/spree/product_scopes.rb
+++ b/core/app/models/concerns/spree/product_scopes.rb
@@ -246,7 +246,7 @@ module Spree
def self.not_discontinued(only_not_discontinued = true)
if only_not_discontinued != '0' && only_not_discontinued
- where.not(status: 'archived')
+ not_archived
else
all
end
diff --git a/core/app/models/spree/product.rb b/core/app/models/spree/product.rb
index 0a6555e49c..b125c66e1a 100644
--- a/core/app/models/spree/product.rb
+++ b/core/app/models/spree/product.rb
@@ -152,6 +152,9 @@ module Spree
validate :discontinue_on_must_be_later_than_make_active_at, if: -> { make_active_at && discontinue_on }
scope :for_store, ->(store) { joins(:store_products).where(StoreProduct.table_name => { store_id: store.id }) }
+ scope :draft, -> { where(status: 'draft') }
+ scope :archived, -> { where(status: 'archived') }
+ scope :not_archived, -> { where.not(status: 'archived') }
attr_accessor :option_values_hash