Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced processor #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Each ProductDatasheet record has 4 integer fields that give a basic description
* `:failed_records =>` sum of all records that had a 'false' return when saved
* `:failed_queries =>` number of rows that matched no Product or Variant records

Choosing processor
==================

You can choose original ProductDatasheet model to handle uploaded spreadsheet or you can choose ProductDatasheetAdvanced which use processor from [spree-import-products](https://github.com/joshmcarthur/spree-import-products)

Installation
============

Expand Down
5 changes: 3 additions & 2 deletions app/controllers/admin/product_datasheets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def collection
end

def create
@product_datasheet = ProductDatasheet.create(params[:product_datasheet])
datasheet_class = Object.const_get(params[:product_datasheet][:processor])
@product_datasheet = datasheet_class.create(params[:product_datasheet])
if @product_datasheet.xls.original_filename.end_with?(".xls") and @product_datasheet.save
if defined? Delayed::Job
Delayed::Job.enqueue(@product_datasheet)
Expand All @@ -49,7 +50,7 @@ def create
flash.notice = I18n.t("notice_messages.product_datasheet_saved")
redirect_to admin_product_datasheets_path
else
@product_datasheets = ProductDatasheet.not_deleted
@product_datasheets = datasheet_class.not_deleted
render :template => 'admin/product_datasheets/index', :action => :new
end
end
Expand Down
Loading