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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Remove Product & Variant dead methods (#13680)
Damian Legawiec049872c4ee84
diff --git a/spree/core/app/models/spree/product.rb b/spree/core/app/models/spree/product.rbindex 97a7da45af..9d4a243cc4 100644--- a/spree/core/app/models/spree/product.rb+++ b/spree/core/app/models/spree/product.rb@@ -479,13 +479,6 @@ module SpreeProducts::Duplicator.call(product: self)end- # use deleted? rather than checking the attribute directly. this- # allows extensions to override deleted? if they want to provide- # their own definition.- def deleted?- !!deleted_at- end-# determine if product is available.# deleted products and products with status different than active# are not available@@ -513,14 +506,6 @@ module Spreevariants_including_master.any?(&:backordered?)end- # split variants list into hash which shows mapping of opt value onto matching variants- # eg categorise_variants_from_option(color) => {"red" -> [...], "blue" -> [...]}- def categorise_variants_from_option(opt_type)- return {} unless option_types.include?(opt_type)-- variants.active.group_by { |v| v.option_values.detect { |o| o.option_type == opt_type } }- end-def self.like_any(fields, values)conditions = fields.product(values).map do |(field, value)|arel_table[field].matches("%#{value}%")@@ -537,13 +522,8 @@ module Spreevariants.active(current_currency).joins(:option_value_variants)end- def empty_option_values?- options.empty? || options.any? do |opt|- opt.option_type.option_values.empty?- end- end-def property(property_name)+ Spree::Deprecation.warn("Product properties are deprecated and will be removed in Spree 6.0. Please use Metafields instead")if product_properties.loaded?product_properties.detect { |property| property.property.name == property_name }.try(:value)else@@ -552,6 +532,7 @@ module Spreeenddef set_property(property_name, property_value, property_presentation = property_name)+ Spree::Deprecation.warn("Product properties are deprecated and will be removed in Spree 6.0. Please use Metafields instead")property_name = property_name.to_s.parameterizeApplicationRecord.transaction do# Manual first_or_create to work around Mobility bug@@ -576,6 +557,7 @@ module Spreeenddef remove_property(property_name)+ Spree::Deprecation.warn("Product properties are deprecated and will be removed in Spree 6.0. Please use Metafields instead")product_properties.joins(:property).find_by(spree_properties: { name: property_name.parameterize })&.destroyenddiff --git a/spree/core/app/models/spree/variant.rb b/spree/core/app/models/spree/variant.rbindex 1394996570..dbbe670b82 100644--- a/spree/core/app/models/spree/variant.rb+++ b/spree/core/app/models/spree/variant.rb@@ -279,14 +279,6 @@ module Spreeis_master? ? name + ' - Master' : name + ' - ' + options_textend- # use deleted? rather than checking the attribute directly. this- # allows extensions to override deleted? if they want to provide- # their own definition.- # @return [Boolean] true if the variant is deleted.- def deleted?- !!deleted_at- end-# Returns true if the variant has images.# Uses loaded association when available, otherwise falls back to counter cache.# @return [Boolean]@@ -530,18 +522,6 @@ module Spree@compare_at_price ||= price_in(cost_currency).try(:compare_at_amount)end- # Returns the name and sku of the variant.- # @return [String] the name and sku of the variant- def name_and_sku- "#{name} - #{sku}"- end-- # Returns the sku and options text of the variant.- # @return [String] the sku and options text of the variant- def sku_and_options_text- "#{sku} #{options_text}".strip- end-# Returns true if the variant is in stock.# @return [Boolean] true if the variant is in stockdef in_stock?