Subversion Repositories SmartDukaan

Rev

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

Rev 14497 Rev 14499
Line 699... Line 699...
699
    else:
699
    else:
700
        collection.insert(data)
700
        collection.insert(data)
701
        get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
701
        get_mongo_connection().Catalog.MasterData.update({'_id':data['sku']},{"$set":{'updatedOn':to_java_date(datetime.now())}},multi=False)
702
        return {1:"Data added successfully"}
702
        return {1:"Data added successfully"}
703
 
703
 
704
def searchCollection(class_name, sku, skuBundleId, offset, limit):
704
def searchCollection(class_name, sku, skuBundleId):
705
    data = []
705
    data = []
706
    collection = get_mongo_connection().Catalog[class_name]
706
    collection = get_mongo_connection().Catalog[class_name]
-
 
707
    if sku is not None:
707
    cursor = collection.find({'sku':sku})
708
        cursor = collection.find({'sku':sku})
708
    for val in cursor:
709
        for val in cursor:
709
        master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
710
            master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
710
        if len(master) > 0:
711
            if len(master) > 0:
711
            val['brand'] = master[0]['brand']
712
                val['brand'] = master[0]['brand']
712
            val['source_product_name'] = master[0]['source_product_name']
713
                val['source_product_name'] = master[0]['source_product_name']
713
            val['skuBundleId'] = master[0]['skuBundleId']
714
                val['skuBundleId'] = master[0]['skuBundleId']
714
        else:
715
            else:
715
            val['brand'] = ""
716
                val['brand'] = ""
716
            val['source_product_name'] = ""
717
                val['source_product_name'] = ""
717
            val['skuBundleId'] = ""
718
                val['skuBundleId'] = ""
718
        data.append(val)
719
            data.append(val)
-
 
720
        return data
-
 
721
    else:
-
 
722
        skuIds = get_mongo_connection().MasterData.find({'skuBundleId':skuBundleId}).distinct('_id')
-
 
723
        for sku in skuIds:
-
 
724
            cursor = collection.find({'sku':sku})
-
 
725
            for val in cursor:
-
 
726
                master = list(get_mongo_connection().Catalog.MasterData.find({'_id':val['sku']}))
-
 
727
                if len(master) > 0:
-
 
728
                    val['brand'] = master[0]['brand']
-
 
729
                    val['source_product_name'] = master[0]['source_product_name']
-
 
730
                    val['skuBundleId'] = master[0]['skuBundleId']
-
 
731
                else:
-
 
732
                    val['brand'] = ""
-
 
733
                    val['source_product_name'] = ""
-
 
734
                    val['skuBundleId'] = ""
-
 
735
                data.append(val)
719
    return data
736
        return data
-
 
737
        
720
    
738
    
721
 
739
 
722
 
740
 
723
 
741
 
724
def main():
742
def main():