Subversion Repositories SmartDukaan

Rev

Rev 1633 | Rev 1833 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1633 Rev 1810
Line 14... Line 14...
14
from shop2020.model.v1.catalog.impl import DataService
14
from shop2020.model.v1.catalog.impl import DataService
15
from shop2020.model.v1.catalog.impl.DataService import Item, EntityIDGenerator,\
15
from shop2020.model.v1.catalog.impl.DataService import Item, EntityIDGenerator,\
16
    ItemChangeLog, Vendor, VendorItemPricing, VendorItemMapping
16
    ItemChangeLog, Vendor, VendorItemPricing, VendorItemMapping
17
from elixir import *
17
from elixir import *
18
 
18
 
19
def load_item_data(filename, vendorId, category, full_update, dry_run, product_group):
19
def load_item_data(filename, vendorId, category, full_update, dry_run, supplied_product_group):
20
    DataService.initialize('catalog')
20
    DataService.initialize('catalog')
21
    
21
    
22
    vendor = Vendor.get_by(id=vendorId)
22
    vendor = Vendor.get_by(id=vendorId)
23
    if vendor is None:
23
    if vendor is None:
24
        raise Exception("No vendor found for the id: " + str(vendorId))
24
        raise Exception("No vendor found for the id: " + str(vendorId))
Line 35... Line 35...
35
 
35
 
36
    for rownum in range(1, num_rows):
36
    for rownum in range(1, num_rows):
37
        #print sheet.row_values(rownum)
37
        #print sheet.row_values(rownum)
38
        catalog_item_id, category_id = [None, None]
38
        catalog_item_id, category_id = [None, None]
39
        
39
        
-
 
40
        if supplied_product_group != '':
-
 
41
            our_brand, our_model_number, our_color,\
40
        #hotspot_category, brand, model_number, color, model_name, mrp, mop, dp, xfer_price, weight, start_date, deal_text, deal_value, comments, catalog_item_id, category_id = sheet.row_values(rownum)[0:17]
42
            brand, model_number, model_name, color,\
-
 
43
            dp, mrp, mop, sp,\
41
        our_brand, our_model_number, our_color, brand, model_number, model_name, color, dp, mrp, mop, sp, comments, hotspot_category, unused_feature, xfer_price, weight, start_date, deal_text, deal_value = sheet.row_values(rownum)[0:19]
44
            comments, hotspot_category, unused_feature, xfer_price, weight, start_date, deal_text, deal_value = sheet.row_values(rownum)[0:19]
-
 
45
            product_group = supplied_product_group
-
 
46
        else:
-
 
47
            our_brand, our_model_number, our_color,\
-
 
48
            product_group, brand, model_number, model_name, color,\
-
 
49
            dp, mrp, mop, sp,\
42
        #product_group, brand, model_number, color, xfer_price, mop, mrp, catalog_item_id, category_id = sheet.row_values(rownum)[0:9]
50
            comments, hotspot_category, unused_feature, xfer_price, weight, start_date, deal_text, deal_value = sheet.row_values(rownum)[0:20]
-
 
51
 
43
        if isinstance(model_number, float):
52
        if isinstance(model_number, float):
44
            model_number = str(int(model_number))
53
            model_number = str(int(model_number))
-
 
54
        
-
 
55
        if our_brand == '':
-
 
56
            our_brand = brand
-
 
57
        if our_model_number == '':
-
 
58
            our_model_number = model_number
-
 
59
        if our_color == '':
-
 
60
            our_color = color
-
 
61
        
45
        if sp == '':
62
        if sp == '':
46
            sp = mop 
63
            sp = mop 
47
        item = None
64
        item = None
48
        vendor_item_pricing = None
65
        vendor_item_pricing = None
49
        
66
        
Line 55... Line 72...
55
        if item is None:
72
        if item is None:
56
            #print "[ADDING:]{0} {1} {2} {3} to our catalogue.".format(product_group, brand, model_number, color)
73
            #print "[ADDING:]{0} {1} {2} {3} to our catalogue.".format(product_group, brand, model_number, color)
57
            new_items.append(rownum)
74
            new_items.append(rownum)
58
            item = Item()
75
            item = Item()
59
            item.product_group = product_group
76
            item.product_group = product_group
60
            item.brand = brand
77
            item.brand = our_brand
61
            item.model_number = model_number
78
            item.model_number = our_model_number
62
            item.color = color
79
            item.color = our_color
63
            item.status = status.IN_PROCESS
80
            item.status = status.IN_PROCESS
64
            item.addedOn = updatedOn
81
            item.addedOn = updatedOn
65
            item.hotspotCategory = category
82
            item.hotspotCategory = category
66
            
83
            
67
            if category == 'Handsets':
84
            if category == 'Handsets':
Line 81... Line 98...
81
                item.catalog_item_id = int(catalog_item_id)
98
                item.catalog_item_id = int(catalog_item_id)
82
                item.category = int(category_id)
99
                item.category = int(category_id)
83
                item.status = status.ACTIVE
100
                item.status = status.ACTIVE
84
            else:
101
            else:
85
                # Check if a similar item already exists in our database
102
                # Check if a similar item already exists in our database
86
                similar_item = Item.query.filter_by(product_group=product_group, brand = brand, model_number=model_number, hotspotCategory=category).first()
103
                similar_item = Item.query.filter_by(product_group=product_group, brand = our_brand, model_number=our_model_number, hotspotCategory=category).first()
87
                print "[SIMILAR ITEM FOUND:] FOR {0} {1} {2} {3}".format(product_group, brand, model_number, color)
104
                print "[SIMILAR ITEM FOUND:] FOR {0} {1} {2} {3}".format(product_group, brand, model_number, color)
88
                             
105
                             
89
                if similar_item is None or similar_item.catalog_item_id is None:
106
                if similar_item is None or similar_item.catalog_item_id is None:
90
                    # If there is no similar item in the database from before,
107
                    # If there is no similar item in the database from before,
91
                    # use the entity_id_generator
108
                    # use the entity_id_generator