Skip to content

Commit

Permalink
Remove multiple taxons on products functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Yorkley committed Aug 7, 2023
1 parent b731e83 commit 66f7874
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
21 changes: 0 additions & 21 deletions app/models/spree/classification.rb

This file was deleted.

15 changes: 0 additions & 15 deletions app/models/spree/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class Product < ApplicationRecord

has_many :product_properties, dependent: :destroy
has_many :properties, through: :product_properties
has_many :classifications, dependent: :delete_all
has_many :taxons, through: :classifications
has_many :variants, -> { order("spree_variants.position ASC") }, class_name: 'Spree::Variant',
dependent: :destroy

Expand Down Expand Up @@ -78,10 +76,7 @@ class Product < ApplicationRecord
# these values are persisted on the product's variant
attr_accessor :price, :display_as, :unit_value, :unit_description, :tax_category_id

before_save :add_primary_taxon_to_taxons

after_create :ensure_standard_variant
after_save :remove_previous_primary_taxon_from_taxons
after_save :update_units

scope :with_properties, ->(*property_ids) {
Expand Down Expand Up @@ -290,16 +285,6 @@ def touch_distributors
Enterprise.distributing_products(id).each(&:touch)
end

def add_primary_taxon_to_taxons
taxons << primary_taxon unless taxons.include? primary_taxon
end

def remove_previous_primary_taxon_from_taxons
return unless saved_change_to_primary_taxon_id? && primary_taxon_id_before_last_save

taxons.destroy(primary_taxon_id_before_last_save)
end

def ensure_standard_variant
return unless variants.empty?

Expand Down

0 comments on commit 66f7874

Please sign in to comment.