Esempio n. 1
0
    if variant_id:
        product_id = variant_id
    return urljoin(PRODUCT_URL_BASE, 
            "/".join((LANG,
            product.get('cat_link_rewrite', ''),
            "{}-{}.html".format(product_id,
                product.get('link_rewrite')))))

customer_email = {}
b64 = lambda s: b64encode(s.encode('UTF-8'))
with Feed('customer', os.path.join(OUTPUT_DIRECTORY, 'customers.xml'), 'CUSTOMERS') as f:
    for customer in Customer.select(Customer, GenderLang.name,
                                    Address.postcode, Address.phone,
                                    Address.phone_mobile,
                                    peewee.fn.min(Address.id_address).alias('min_id')).join(GenderLang) \
            .join(Address, on=(Customer.id_customer ==
                Address.id_customer)) \
            .where(GenderLang.id_lang == LANG_ID) \
            .group_by(Address.id_customer) \
            .dicts():
        el = Element("CUSTOMER")
        i = SubElement(el, "FIRST_NAME")
        i.text = customer['firstname']
        i = SubElement(el, "LAST_NAME")
        i.text = customer['lastname']
        i = SubElement(el, "CUSTOMER_ID")
        #i.text = str(customer['id_customer'])
        i.text = b64(str(customer['email']))
        i = SubElement(el, "EMAIL")
        i.text = customer['email']
        phone = customer.get('phone_mobile') or customer.get('phone')