Class: PriceChangeJob
- Inherits:
-
Struct
- Object
- Struct
- PriceChangeJob
- Defined in:
- lib/price_change_job.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record
1 2 3 |
# File 'lib/price_change_job.rb', line 1 def record @record end |
Instance Method Details
#perform ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/price_change_job.rb', line 2 def perform inactive_states = YAML.load Spree::Config.get(:order_price_sync_inactive_states_list) to_update = LineItem.joins(:order).where(:variant_id => record).where("orders.state not in (?)", inactive_states) to_update.each do |l| puts "Invoking with #{l.inspect}" if l.price != record.price puts "Price changed #{l.price}" item = LineItem.find(l.id) item.price = record.price puts item.save order = item.order order.update_totals order.save end end end |