Skip to content

Instantly share code, notes, and snippets.

@dfranciosi
Created October 25, 2011 10:09
Show Gist options
  • Save dfranciosi/1312143 to your computer and use it in GitHub Desktop.
Save dfranciosi/1312143 to your computer and use it in GitHub Desktop.
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