Sha256: ca8a2be2e0e081f93807ba11fa8a828d8e8aeb77a4136f0544770c7e107fa8a2

Contents?: true

Size: 516 Bytes

Versions: 5

Compression:

Stored size: 516 Bytes

Contents

class MoveFeaturedAttributeOfProducts < ActiveRecord::Migration
  def change
    Cama::Site.all.each do |site|
      ptype = site.post_types.where(slug: 'commerce').first
      if ptype.present?
        ptype.posts.filter_by_field('ecommerce_featured', value: '1').each do |post|
          post.update_column(:is_feature, true)
        end
        field = ptype.get_field_object('ecommerce_featured')
        field.destroy if field.present?
        ptype.set_option('has_featured', true)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
camaleon_ecommerce-2.0.1 db/migrate/20160504162311_move_featured_attribute_of_products.rb
camaleon_ecommerce-2.0.0 db/migrate/20160504162311_move_featured_attribute_of_products.rb
camaleon_ecommerce-1.2.1 db/migrate/20160504162311_move_featured_attribute_of_products.rb
camaleon_ecommerce-1.2 db/migrate/20160504162311_move_featured_attribute_of_products.rb
camaleon_ecommerce-1.1 db/migrate/20160504162311_move_featured_attribute_of_products.rb