Skip to content

Instantly share code, notes, and snippets.

@indrode
Last active August 29, 2015 14:03
Show Gist options
  • Save indrode/1dbe8143fb1afab194dc to your computer and use it in GitHub Desktop.
Save indrode/1dbe8143fb1afab194dc to your computer and use it in GitHub Desktop.
Remap products via XMLs
def remap_kontor_za!(filename)
arr = read_ids_from_file(filename)
arr.each do |id|
album = KontorZaAlbum.find_by_id(id)
if album
c = ContentManager.new(album)
attrs = c.attributes
ContentManager.update_product_from_overwrite_mapping_attributes(album, attrs)
print '.'.green
else
print "[#{id}]".red
end
end
true
end
def generate_attributes_hash(filename)
hash = {}
arr = read_ids_from_file(filename)
arr.each do |id|
album = KontorZaAlbum.find_by_id(id)
hash["#{id}"] = album.released_on.to_s
end
hash
end
# then, run this in ZA
# hash - generated attributes hash from above (may have to store hash in a file)
def fix_kontor_za!(hash)
hash.each do |id, released_on|
KontorZaAlbum.find(id.to_i).update_attributes(released_on: released_on)
print '.'.green
end
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment