Skip to content

Commit

Permalink
Make product fields information static
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Yorkley committed Aug 21, 2018
1 parent 78b1c51 commit d554b55
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/product_import_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def import
@filepath = save_uploaded_file(params[:file])
@importer = ProductImport::ProductImporter.new(File.new(@filepath), spree_current_user, params[:settings])
@original_filename = params[:file].try(:original_filename)
@non_updatable_fields = @importer.validator.non_updatable_fields
@non_updatable_fields = ProductImport::EntryValidator.non_updatable_fields

check_file_errors @importer
check_spreadsheet_has_data @importer
Expand Down
4 changes: 2 additions & 2 deletions app/models/product_import/entry_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(current_user, import_time, spreadsheet_data, editable_enterprises
@import_settings = import_settings
end

def non_updatable_fields
def self.non_updatable_fields
{
category: :primary_taxon_id,
variant_unit_name: :variant_unit_name,
Expand Down Expand Up @@ -219,7 +219,7 @@ def mark_as_existing_variant(entry, existing_variant)
end

def apply_product_field_warnings(entry, existing_variant)
non_updatable_fields.each do |display_name, attribute|
EntryValidator.non_updatable_fields.each do |display_name, attribute|
next if existing_variant.product.send(attribute) == entry.send(attribute)

entry.warnings.add display_name, I18n.t('admin.product_import.model.not_updatable')
Expand Down

0 comments on commit d554b55

Please sign in to comment.