<< | Index | >>
1. Pickup gag, ean, and allo ids Attach:pickup_gag_ean_allo_ids.rb.20110722.txt
ruby pickup_gag_ean_allo_ids.rb > gag_ena_allo_ids.csv
2. Pickup actual allo ids Attach:pickup_actual_allo_ids.rb.20110722.txt
ruby pickup_actual_allo_ids.rb > actual_allo_ids.csv
3. Pickup actual gag, ean, and allo ids Attach:pickup_actual_gag_ean_allo_ids.rb.20110722.txt
ruby pickup_actual_gag_ean_allo_ids.rb > actual_gag_ean_allo_ids.csv
Review
Experiment
def update_products2(values)
p values
values.each { |value|
key = value[:old_uid]
product = @products[key]
#value.delete(:uid)
product.update(value)
begin
@products.store(product.uid, product)
@products.delete(key)
rescue MissingDataException
@errors << product
end
} if values
end
def update_stock(gid, updates)
#@prevalence.executeTransaction(BBMB::Transaction.new(UpdateStockCommand.new(gid, updates)))
@prevalence.executeTransaction(BBMB::Transaction.new(UpdateStockCommand2.new(gid, updates)))
end
class UpdateStockCommand2
def initialize(gid, values)
@values = values
@gid = gid
end
def execute(app)
reseller = app.resellers[@gid]
reseller.update_products2(@values)
end
end
def update_products2(values)
stock.adjust(product_key, searchable)
stock.update_products2(values)
end
Run
masa@masa ~/ywesee/bbmb.ch $ bin/admin
ch.bbmb.globopharm> update_stock('1', [{:old_id => '946005', :uid => '123456', :article_number => '123456'}])
-> 0
Result (Check the searching of product by using a customer id)
Confirmation
Before update
ch.bbmb.globopharm> resellers['1'].product('53000002').uid
-> undefined method `uid' for nil:NilClass
ch.bbmb.globopharm> resellers['1'].product('946005').uid
-> 946005
ch.bbmb.globopharm> resellers['1'].product('946005').article_descr
-> Tysabri
After update
ch.bbmb.globopharm> resellers['1'].product('946005').uid
-> undefined method `uid' for nil:NilClass
ch.bbmb.globopharm> resellers['1'].product('53000002').uid
-> 53000002
ch.bbmb.globopharm> resellers['1'].product('53000002').article_descr
-> Tysabri
src/util/bbmbapp.rb
def replace_article_ids_gag_to_alloga(map_file = nil, reseller_gid = '1')
unless map_file
return 'set the path to the mapping file'
end
count = 0
File.readlines(map_file).each do |line|
ids = line.chomp.split(/;/)
gag_id = ids[0]
ean_code = ids[1]
alloga_id = ids[2]
if resellers[reseller_gid].product(gag_id) and alloga_id
updates = [{:old_uid => gag_id, :uid => alloga_id, :article_number => alloga_id, :article_ean13 => ean_code}]
update_stock(reseller_gid, updates)
count += 1
end
end
count
end
Run
masa@masa ~/ywesee/bbmb.ch $ bin/admin ch.bbmb.globopharm> replace_article_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_ids.csv' -> 284
Note
Experiment
USER_MAP = {
0 => :customer_id,
1 => :customer_ean13,
2 => :group_short,
3 => :organisation,
4 => :drtitle,
5 => :address1,
7 => :plz,
8 => :location,
9 => :phone_business,
10 => :fax,
11 => :email,
}
Run
masa@masa ~/ywesee/bbmb.ch $ bin/admin ch.bbmb.globopharm> replace_user_ids_gag_to_alloga '/home/masa/work/new_data/gagallkd_new.csv' -> 169 ch.bbmb.globopharm> update
Result
Confirmation
ARTICLE_MAP = {
1 => :article_number,
2 => :article_ean13,
3 => :article_descr,
8 => :article_price,
}
Run
masa@masa ~/ywesee/bbmb.ch $ bin/admin ch.bbmb.globopharm> replace_article_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_ids.csv' ch.bbmb.globopharm> update
Log
1. restore log files
masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ rm *.* masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ cp ~/work/mnemonic_local_update_all_kund_bak/*.* .
2. Run bin/bbmbd
3. Switch update method for stock
def update_stock(gid, updates)
@prevalence.executeTransaction(BBMB::Transaction.new(UpdateStockCommand.new(gid, updates)))
#@prevalence.executeTransaction(BBMB::Transaction.new(UpdateStockCommand2.new(gid, updates)))
end
4. Replace new ids of user and stock
ch.bbmb.globopharm> replace_customer_ids_gag_to_alloga '/home/masa/work/new_data/gagallkd_new.csv' -> 169 ch.bbmb.globopharm> replace_article_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_ids.csv' -> 284
5. Switch update method for stock
def update_stock(gid, updates)
#@prevalence.executeTransaction(BBMB::Transaction.new(UpdateStockCommand.new(gid, updates)))
@prevalence.executeTransaction(BBMB::Transaction.new(UpdateStockCommand2.new(gid, updates)))
end
6. Restart bin/bbmbd
7. Replace new user and stock files on the ftp server
8. Update
ch.bbmb.globopharm> update
Note
this should be resolved next week)