Sha256: 7dc5f4fe852eb7d5691e2575538da6e9c5c2f2df18332ab624f02fbf1a4e3c7b

Contents?: true

Size: 347 Bytes

Versions: 3

Compression:

Stored size: 347 Bytes

Contents

Spree::Variant.class_eval do
  has_and_belongs_to_many  :assemblies, :class_name => "Spree::Product",
        :join_table => "spree_assemblies_parts",
        :foreign_key => "part_id", :association_foreign_key => "assembly_id"

  def assemblies_for(products)
    assemblies.where(id: products)
  end

  def part?
    assemblies.exists?
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
solidus_product_bundle-1.0.1 app/models/spree/variant_decorator.rb
solidus_product_bundle-1.0.0 app/models/spree/variant_decorator.rb
solidus_product_assembly-1.0.0 app/models/spree/variant_decorator.rb