From 4dfbbd60d44a700d1fd2ebc75861b57d6559fd4b Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 31 Aug 2018 19:13:17 +0100 Subject: [PATCH] Fix occasional StaleObjectError on variant updates --- app/models/product_import/entry_processor.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/product_import/entry_processor.rb b/app/models/product_import/entry_processor.rb index 97f9cbe55c..14cfd67f2d 100644 --- a/app/models/product_import/entry_processor.rb +++ b/app/models/product_import/entry_processor.rb @@ -115,7 +115,13 @@ module ProductImport return unless entry.validates_as? 'existing_variant' - save_variant entry + begin + save_variant entry + rescue ActiveRecord::StaleObjectError + entry.product_object.reload + save_variant entry + end + @variants_updated += 1 end