| Line 8... |
Line 8... |
| 8 |
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
|
8 |
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
|
| 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, 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, updatedOn):
|
| 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.category_id = category_id
|
20 |
self.category_id = category_id
|
| 20 |
self.category = category
|
21 |
self.category = category
|
| 21 |
self.available_price = available_price
|
22 |
self.available_price = available_price
|
| 22 |
self.mrp = mrp
|
23 |
self.mrp = mrp
|
| 23 |
self.in_stock = in_stock
|
24 |
self.in_stock = in_stock
|
| Line 34... |
Line 35... |
| 34 |
l = []
|
35 |
l = []
|
| 35 |
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() } })
|
| 36 |
print items.count()
|
37 |
print items.count()
|
| 37 |
for item in items:
|
38 |
for item in items:
|
| 38 |
title = xstr(item['brand'])+" "+xstr(item['model_name'])
|
39 |
title = xstr(item['brand'])+" "+xstr(item['model_name'])
|
| 39 |
s_info = __SkuInfo(str(item['_id']),int(item['skuBundleId']),str(item['brand']),str(item['model_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']),str(item['brand']),str(item['model_name']),str(item['source_product_name']),int(item['category_id']),categoryMap.get(item['category_id']),float(item['available_price']),float(item['mrp']),item['in_stock'], \
|
| 40 |
int(item['source_id']),str(item['source']),title,str(item['thumbnail']), long(item['updatedOn']))
|
41 |
int(item['source_id']),str(item['source']),title,str(item['thumbnail']), long(item['updatedOn']))
|
| 41 |
l.append(s_info.__dict__)
|
42 |
l.append(s_info.__dict__)
|
| 42 |
solr.add(l)
|
43 |
solr.add(l)
|
| 43 |
|
44 |
|
| 44 |
def get_mongo_connection(host='localhost', port=27017):
|
45 |
def get_mongo_connection(host='localhost', port=27017):
|