Subversion Repositories SmartDukaan

Rev

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

Rev 13974 Rev 13985
Line 9... Line 9...
9
xstr = lambda s: s or ""
9
xstr = lambda s: s or ""
10
 
10
 
11
class __SkuInfo:
11
class __SkuInfo:
12
    
12
    
13
    def __init__(self, id, skuBundleId, brand, model_name, source_product_name, category_id, category, available_price, mrp, in_stock, \
13
    def __init__(self, id, skuBundleId, brand, model_name, source_product_name, category_id, category, available_price, mrp, in_stock, \
14
                 source_id, store, title, thumbnail, updatedOn):
14
                 source_id, store, title, thumbnail, priceUpdatedOn):
15
        self.id = id
15
        self.id = id
16
        self.skuBundleId = skuBundleId
16
        self.skuBundleId = skuBundleId
17
        self.brand = brand
17
        self.brand = brand
18
        self.model_name = model_name
18
        self.model_name = model_name
19
        self.source_product_name = source_product_name
19
        self.source_product_name = source_product_name
Line 24... Line 24...
24
        self.in_stock = in_stock
24
        self.in_stock = in_stock
25
        self.source_id = source_id
25
        self.source_id = source_id
26
        self.store = store
26
        self.store = store
27
        self.title= title
27
        self.title= title
28
        self.thumbnail = thumbnail
28
        self.thumbnail = thumbnail
29
        self.updatedOn = updatedOn
29
        self.priceUpdatedOn = priceUpdatedOn
30
        
30
        
31
        
31
        
32
solr = pysolr.Solr("http://104.200.25.40:8080/solr/", timeout=10)
32
solr = pysolr.Solr("http://104.200.25.40:8080/solr/", timeout=10)
33
 
33
 
34
def pushData():
34
def pushData():
Line 36... Line 36...
36
    items = get_mongo_connection().Catalog.MasterData.find({'source_id' : { "$in": SOURCE_MAP.values() } })
36
    items = get_mongo_connection().Catalog.MasterData.find({'source_id' : { "$in": SOURCE_MAP.values() } })
37
    print items.count()
37
    print items.count()
38
    for item in items:
38
    for item in items:
39
        title = xstr(item['brand'])+" "+xstr(item['model_name'])
39
        title = xstr(item['brand'])+" "+xstr(item['model_name'])
40
        s_info = __SkuInfo(str(item['_id']),int(item['skuBundleId']),(item['brand']),(item['model_name']),(item['source_product_name']),int(item['category_id']),categoryMap.get(item['category_id']),float(item['available_price']),float(item['mrp']),item['in_stock'], \
40
        s_info = __SkuInfo(str(item['_id']),int(item['skuBundleId']),(item['brand']),(item['model_name']),(item['source_product_name']),int(item['category_id']),categoryMap.get(item['category_id']),float(item['available_price']),float(item['mrp']),item['in_stock'], \
41
                        int(item['source_id']),(item['source']),title,(item['thumbnail']), long(item['updatedOn']))
41
                        int(item['source_id']),(item['source']),title,(item['thumbnail']), long(item['priceUpdatedOn']))
42
        l.append(s_info.__dict__)
42
        l.append(s_info.__dict__)
43
    solr.add(l)
43
    solr.add(l)
44
 
44
 
45
def get_mongo_connection(host='localhost', port=27017):
45
def get_mongo_connection(host='localhost', port=27017):
46
    global con
46
    global con