Title / Description
Code p_new = product if r1.nil? puts "!! #{item_id} no product found in ERP" return "" end if r1["Vintage"].to_i > 1000 p_new.title = r1["Vintage"] + " " + r1["LongTitle"] else p_new.title = r1["LongTitle"] end vol = (r1["Volume"].to_f*1000).to_i if (vol < 700 or vol > 799) and vol > 1 p_new.title = p_new.title + " (" + vol.to_s + " ml)" end if p_new.handle?.nil? or "" == p_new.handle p_new.handle = (r1["LongTitle"]+"-"+r1["Vintage"]+"-"+r1["ItemID"]).downcase.gsub(/[^a-z0-9]/," ").strip.gsub(" ","-") end vendor_re = /.*\s?-\s(.*)|.*(Domaine.*)|(.*)/ p_new.vendor = r1["LongTitle"].match(vendor_re).to_a[1..3].join() if r1["Reference3"] != "" p_new.vendor = r1["Reference3"] puts p_new.vendor end p_new.product_type = r1["ItemType"].gsub("00_","").capitalize country_s = r1["Country"].capitalize country_s = "USA" if country_s.downcase == "usa" country_s = "United Kingdom" if country_s.downcase == "uk" tags = [] tags.push "appellation-" + r1["Appellation"].gsub("_AOC","").gsub("_"," ").capitalize tags.push "country-" + country_s tags.push p_new.product_type tags.push "region-" + r1["Region"].capitalize tags.push "size-#{vol}ml" if vol > 10 tags.push "vintage-#{r1["Vintage"]}" tags.push "wine" # if not asso / cigar if not r1["ZhName"].match(/\p{Han}/).nil? tags.push "zh-#{r1["ZhName"]}" end score_h = 0 r1["Score"].split(",").each do |s| tags.push "score-#{s}" score = s.match(/\d+/).to_s.to_i score_h = score if score > score_h end if score_h >= 99 tags.push "score-A" elsif score_h >= 95 and score_h <= 98 tags.push "score-B" elsif score_h >= 90 and score_h <= 94 tags.push "score-C" elsif score_h < 90 and score_h >= 60 tags.push "score-D" end p_new.tags = tags.join(", ") if p_new.new? v_new = Variant.new else v_new = p_new.variants.first end v_new.price = r1["Price2"].to_i v_new.compare_at_price = r1["Price2"] == r1["Price3"] ? 0 : r1["Price3"].to_i v_new.sku = r1["ItemID"] v_new.gram = vol * 2 if vol > 1 #v_new.inventory_quantity = r1["AvaQty"].to_i #v_new.inventory_quantity = 0 if v_new.price == 0 v_new.inventory_management = "shopify" v_new.taxable = false v_new.weight = (vol * 2.0 / 1000) if vol > 1
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code