Skip to content

Instantly share code, notes, and snippets.

@mimosz
Created April 20, 2012 06:23
Show Gist options
  • Save mimosz/2426559 to your computer and use it in GitHub Desktop.
Save mimosz/2426559 to your computer and use it in GitHub Desktop.
Ruby:SKU转码
# SKU转码
user = User.all[0]
user.items_sync
user.skus_sync
skus_data = {
'AWLT932900100L' => 6946401914277,
}
counter = 0
puts skus_data.count
user.items.each do |item|
item.skus.each do |sku|
outer_id = sku.outer_id.to_s
if skus_data.keys.include?(outer_id)
options = { # 基础参数
session: user.session,
method: 'taobao.item.sku.update',
num_iid: sku.num_iid,
properties: sku.properties,
# quantity: skus_data[outer_id],
outer_id: skus_data[outer_id],
}
# puts options
# puts Topsdk.get_with(options)
skus_data.delete(outer_id)
counter += 1
end
end
end
puts counter
puts skus_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment