Open harssh opened 11 years ago
yep same problem... I've changed the migration to make it pass, not including the columns causing the problem... The code can be improved.
class MigrateDataForProducts < ActiveRecord::Migration def up Spree::Product.transaction do Spree::Product.find_each do |product| producttemp = product.untranslated_attributes.reject!{ |k| k == "count_on_hand"} producttemp = producttemp.reject!{ |k| k == "on_demand"} product.update_attributes!(producttemp, :without_protection => true) end end end
def down end end
yep +1 !!
in product.rb
def on_demand=(new_on_demand)
raise 'cannot set on_demand of product with variants' if has_variants? && Spree::Config[:track_inventory_levels]
master.on_demand = on_demand
self[:on_demand] = new_on_demand
end
I would suggest changing db/{datetime}_add_translation_product.rb :
class AddTranslationToProduct < ActiveRecord::Migration
def up
Spree::Config[:track_inventory_levels] = false
Spree::Product.create_translation_table! :name => :string, :description => :text, :meta_description => :string, :meta_keywords => :string
Spree::Config[:track_inventory_levels] = true
end
def down
Spree::Product.drop_translation_table!
end
end
Could anyone give a try please ? I will fix it once confirmed ! thanks
@sbounmy I had to add the track inventory thing also on MigrateDataForProduct migration to make it work.
class MigrateDataForProducts < ActiveRecord::Migration
def up
Spree::Product.transaction do
Spree::Product.find_each do |product|
Spree::Config[:track_inventory_levels] = false
product.update_attributes!(product.untranslated_attributes, :without_protection => true)
Spree::Config[:track_inventory_levels] = true
end
end
end
def down
end
end
rails g spree_multi_lingual:install append app/assets/javascripts/store/all.js append app/assets/javascripts/admin/all.js insert app/assets/stylesheets/store/all.css insert app/assets/stylesheets/admin/all.css run bundle exec rake railties:install:migrations FROM=spree_multi_lingual from "." Would you like to run the migrations now? [Y/n] Y run bundle exec rake db:migrate from "." == MigrateDataForProducts: migrating ========================================= rake aborted!
An error has occurred, this and all later migrations canceled:
cannot set on_demand of product with variants
anybody with solution or same issue here..........