Created
October 25, 2011 10:09
-
-
Save dfranciosi/1312143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if row[ProdFields::FOTO].to_s.downcase == 'ok' | |
# Assign product marketplaces | |
{ | |
'EU' => [ | |
[ProdFields::EU_MARKET, ProdFields::EU_SELECTION, ProdFields::EU_STOCK], | |
ProdFields::EU_PRODUCT_ORDER | |
], | |
'US' => [ | |
[ProdFields::US_MARKET, ProdFields::US_SELECTION, ProdFields::US_STOCK], | |
ProdFields::US_PRODUCT_ORDER | |
], | |
'JP' => [ | |
[ProdFields::JP_MARKET, ProdFields::JP_SELECTION, ProdFields::JP_STOCK], | |
ProdFields::JP_PRODUCT_ORDER | |
], | |
'ZH' => [ | |
[ProdFields::CN_MARKET, ProdFields::CN_SELECTION, ProdFields::CN_STOCK], | |
ProdFields::CN_PRODUCT_ORDER | |
] | |
}.each do |key, value| | |
errors = value[0].count do |id| | |
(row[id].to_i rescue 0) != 1 | |
end | |
if errors == 0 | |
mp_id = mplaces[key].id | |
MarketplacesProduct.create(:product_id => p_product.id, | |
:marketplace_id => mp_id, | |
:product_order => (row[value[1]].to_i rescue 0), | |
:sold_out => is_sold_out(p_product.stylegroup, mp_id) | |
) | |
if process_callback | |
process_callback.call "#{n - 1} rows processed so far" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment