I won't attempt to tackle the image conundrum (because our old ecommerce site is of the single-image variety, which makes it easy).
The other, though I can help you with. My models yield four tables (products, product_categories, product_site to tie it to a site, and product_attributes). I wrote in C# an exporter application from our old system (.NET) and made it output pipe-delimited files in the format of my models in django, whether that data was stored previously or not, just to keep it clean and readable. The C# app takes some information such as what ID the next imported product will start with, and uses it to build rows and save them. This may help, it may not...but below is my importprocess.pythat handles all of this, at least on the django side. It's not a perfect implementation, because it was only used once - to move data over. It runs in the shell, but it could be wrapped in a view as well. I've changed a few names and such to protect who we are...we are not yet switched over to the django site, several other projects have come up for me to work on. I will most certainly announce though once we do go live. *********importprocess.py from project.products.models import Product, Manufacturer, Warranty, Category, ProductAttribute, ProductAttributeChoice from django.contrib.sites.models import Site def import_products(): filename = "c:/import/products.txt" file = open(filename) while 1: lines = file.readlines(100000) if not lines: break for line in lines: raw_data = line.split('|') product = Product() #raw_data[0] #id left alone, db will handle #raw_data[1] #manufacturer prd_man_list = Manufacturer.objects.filter (id__exact=raw_data[1]) if prd_man_list: prd_man = prd_man_list[0] product.manufacturer = prd_man #raw_data[2] #vendor #not implemented previously, left out #raw_data[3] #dealer_price #not implemented previously, left out #raw_data[4] #dealer_price_updated #not implemented previously, left out #raw_data[5] #model product.model = raw_data[5] #raw_data[6] #slug product.slug = raw_data[6] #raw_data[7] #description product.description = raw_data[7] #raw_data[8] #package_contents #not implemented previously, left out #raw_data[9] #warranty if raw_data[9] != '': if int(raw_data[9]) > 0: warranty_list = Warranty.objects.filter (id__exact=raw_data[9]) if warranty_list: warranty = warranty_list[0] product.warranty = warranty else: warranty_list = Warranty.objects.filter(id__exact=15) if warranty_list: warranty = warranty_list[0] product.warranty = warranty else: warranty_list = Warranty.objects.filter(id__exact=15) if warranty_list: warranty = warranty_list[0] product.warranty = warranty #raw_data[10] #MAP product.map = raw_data[10] #raw_data[11] #on_site_price #not implemented previously, left out #raw_data[12] #in_cart_price product.in_cart_price = raw_data[12] #raw_data[13] #released #not implemented previously, left out #raw_data[14] #discontinued #not implemented previously, left out #raw_data[15] #length #not implemented previously, left out #raw_data[16] #width #not implemented previously, left out #raw_data[17] #height #not implemented previously, left out #raw_data[18] #weight product.weight = raw_data[18] #raw_data[19] #shipping_weight product.shipping_weight = raw_data[19] #raw_data[20] #shipping_length product.shipping_length = raw_data[20] #raw_data[21] #shipping_width product.shipping_width = raw_data[21] #raw_data[22] #shipping_height product.shipping_height = raw_data[22] #raw_data[23] #shipping_flat_cost #not implemented previously, left out #raw_data[24] #show_in_stock product.show_in_stock = raw_data[24] #raw_data[25] #spec_pdf product.spec_pdf = raw_data[25] #raw_data[26] #highlight_large product.highlight_large = raw_data[26] #raw_data[27] #highlight_medium product.highlight_medium = raw_data[27] #raw_data[28] #highlight_thumbnail product.highlight_thumbnail = raw_data[28] #raw_data[29] #active product.active = raw_data[29] #raw_data[30] #on_froogle product.on_froogle = raw_data[30] #raw_data[31] #show_map_on_froogle product.show_map_on_froogle = raw_data[31] #raw_data[32] #drop_ship product.drop_ship = raw_data[32] #raw_data[33] #may_be_ordered product.may_be_ordered = raw_data[33] product.save () def tie_products_to_site(): filename = "c:/import/products_sites.txt" file = open(filename) while 1: lines = file.readlines(100000) if not lines: break for line in lines: raw_data = line.split('|') #raw_data[0] #id #raw_data[1] #product_id product_list = Product.objects.filter(id__exact=raw_data[1]) if product_list: product = product_list[0] #raw_data[2] #site_id site_list = Site.objects.filter(id__exact=raw_data[2]) if site_list: site = site_list[0] if product: if site: product.sites.add(site) else: print "site %s not found for product %s" % (raw_data[2], raw_data[1]) else: print "product %s not found" % raw_data[1] def tie_products_to_categories(): filename = "c:/import/products_category.txt" file = open(filename) while 1: lines = file.readlines(100000) if not lines: break for line in lines: raw_data = line.split('|') #raw_data[0] #id #raw_data[1] #product_id product_list = Product.objects.filter(id__exact=raw_data[1]) if product_list: product = product_list[0] #raw_data[2] #category_id category_list = Category.objects.filter(id__exact=raw_data[2]) if category_list: category = category_list[0] if product: if category: product.categories.add(category) else: print "category %s not found for product %s" % (raw_data[2], raw_data[1]) else: print "product %s not found" % raw_data[1] def tie_attributes_to_products(): filename = "c:/import/products_attributes.txt" file = open(filename) while 1: lines = file.readlines(100000) if not lines: break for line in lines: raw_data = line.split('|') #raw_data[0] #id #raw_data[1] #product_id product_list = Product.objects.filter(id__exact=raw_data[1]) if product_list: product = product_list[0] #raw_data[2], #raw_data[3] productattributechoice_list = ProductAttributeChoice.objects.filter(id__exact=raw_data[2]) if productattributechoice_list: productattributechoice = productattributechoice_list[0] attribute = ProductAttribute() attribute.product = product attribute.product_attribute_choice = productattributechoice attribute.value = raw_data[3] attribute.save() def do_import(): import_products() tie_products_to_site() tie_products_to_categories() tie_attributes_to_products() On 7/18/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote: > > Hi there! > > I've been working on an ecommerce solution. So far everything works like > it should. There's just one "nice to have" feature left: bulk upload. > I've thought of using xls (microsoft office's excel files) to make it > easy on the client, because teaching them xml or yaml isn't the big > deal. After thinking about it, finding a xls parser module for python > might not be the problem, but how could I take on product images? How > can I bulk upload those? Ok, I can upload a tar or zip file and have it > unpacked automatically, but how do I automagically assign the images > with the product, having in mind that some might have 5 pics and others > might have 2 or none. > > Any ideas? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---