Esempio n. 1
0
            
            
            if not null_price:
                product.save()
            else:
                products_not_added.append(product.sku)
#             has_valid_prices = True
#             attributes = []
    #         print "saved " + str(product)
#             print "saved product "+ str(product.sku)
            
                
            for datas in similar_rows:
                if(not null_price):
                    attribute = Attribute(product=product)
                    attribute.name = datas[3].string.encode('ascii', 'ignore') 
                    attribute.price = decimal.Decimal(get_price(datas))
                    if attribute.price == 0:
                        try:
                            p = Product.objects.filter(sku=datas[1].string[1:]).get()
                            attribute.price = p.price
                        except:
    #                         has_valid_prices = False
#                             print "attribute had no previous price, sku = " + datas[1].string[1:]
                            products_not_added.append(datas[1].string[1:])
                            null_price = True
                            
                    attribute.sku = datas[1].string[1:]
                    attribute.description = datas[5].string
                    attribute.short_description = datas[11].string
    #                 attributes.append(attribute)