Last active
          August 29, 2015 14:03 
        
      - 
      
 - 
        
Save indrode/1dbe8143fb1afab194dc to your computer and use it in GitHub Desktop.  
    Remap products via XMLs
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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