mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-01 21:47:16 +00:00
Fix migrate tax categories to line items migration
This is bringing 67186f8ca7 from spree v2.2
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
# This migration comes from spree (originally 20130802022321)
|
||||
class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
|
||||
def change
|
||||
Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
|
||||
line_items.each do |line_item|
|
||||
Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
|
||||
line_items.each do |line_item|
|
||||
next if line_item.variant.nil?
|
||||
next if line_item.variant.product.nil?
|
||||
next if line_item.product.nil?
|
||||
next unless line_item.product.tax_category.present?
|
||||
line_item.update_column(:tax_category_id, line_item.product.tax_category.id)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user