Subversion Repositories SmartDukaan

Rev

Rev 3140 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3139 chandransh 1
#!/usr/bin/python
2
 
3
'''
4
Created on 01-Sep-2011
5
 
6
@author: ashish
7
'''
8
import sys
9
 
10
if __name__ == '__main__' and __package__ is None:
11
    import os
12
    sys.path.insert(0, os.getcwd())
13
 
14
from shop2020.clients.CatalogClient import CatalogClient
15
 
16
def get_title(item):
17
    title = item.brand
18
    if item.modelName:
19
        title = title + ' ' + item.modelName
20
    if item.modelNumber:
21
        title = title + ' ' + item.modelNumber
22
    return title
23
 
24
def get_hyphenated_name(item):
25
    productUrl = item.brand
26
    if item.modelName:
27
        productUrl = productUrl + "-" + item.modelName
28
    if item.modelNumber:
29
        productUrl = productUrl + '-' + item.modelNumber
30
    productUrl = productUrl.replace("/", "-")
31
    productUrl = productUrl.replace(" ", "-")
32
    productUrl = productUrl.replace("--", "-")
33
    productUrl = productUrl.lower()
34
    return productUrl
35
 
36
def get_url(item):
37
    url = "http://www.saholic.com/mobile-phones/"
38
    productUrl = get_hyphenated_name(item)
39
    productUrl = productUrl + "-" + str(item.catalogItemId)
40
    url = url + productUrl;
41
    url = url.replace("--", "-");
42
    return url;
43
 
44
def get_image_url(item):
45
    url = "http://static0.saholic.com/images/"
46
    url = url + str(item.catalogItemId) + "/"
47
    url = url + get_hyphenated_name(item) + "-default-0.jpg"
48
    return url
49
 
50
def main():
51
    catalog_client = CatalogClient().get_client()
52
    catalog_item_ids = [1000073, 1000079, 1000095, 1000100, 1000110, 1000111, 1000114, 1000120, 1000133, 1000135]
53
    item_details = []
54
    for catalog_item_id in catalog_item_ids:
55
        items = catalog_client.getItemsByCatalogId(catalog_item_id)
56
        item = items[0]
57
        item_details.append([catalog_item_id, get_title(item), get_url(item), item.sellingPrice, '1', '803028031', 'NA', 'UPC', 'Wireless', 'Description', '0', get_image_url(item), item.mrp, 'TRUE', '', item.brand, '', item.modelNumber]);
58
    print item_details
59
 
60
if __name__ == '__main__':
61
    main()