Sha256: d7a163a63b1eb02103765063e69f4a6ba9257514ab3d292ae8cc0ba5dbe2ba5b

Contents?: true

Size: 599 Bytes

Versions: 4

Compression:

Stored size: 599 Bytes

Contents

class Plugins::Ecommerce::ProductVariation < ActiveRecord::Base
  self.table_name='plugins_ecommerce_product_variations'
  belongs_to :product, class_name: "CamaleonCms::Post"
  before_destroy :verify_related_orders

  # return all attribute values assigned to this product
  def attribute_values
    Plugins::Ecommerce::Attribute.only_value.where(id: self.attribute_ids.to_s.split(','))
  end

  private
  def verify_related_orders
    errors.add(:base, I18n.t('plugins.ecommerce.message.not_deletable_product_variations')) if Plugins::Ecommerce::ProductItem.where(variation_id: id).any?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
camaleon_ecommerce-2.0.4 app/models/plugins/ecommerce/product_variation.rb
camaleon_ecommerce-2.0.3 app/models/plugins/ecommerce/product_variation.rb
camaleon_ecommerce-2.0.2 app/models/plugins/ecommerce/product_variation.rb
camaleon_ecommerce-2.0.1 app/models/plugins/ecommerce/product_variation.rb