Ejemplo n.º 1
0
def update_brand(name, name_e, des_e):

    res = dc.execute("SELECT * FROM brands WHERE name = '%s'" % name)
    dc.execute(
        "UPDATE brands SET name = '%s', description = '%s' WHERE id = %d" %
        (name_e, des_e, res[0][0]))
    return res
Ejemplo n.º 2
0
def add_product_to_alias_merchant(product_id, merchant_alias_id, user_id=35, source='mass'):

	delete_product_from_alias_merchant_by_product_id(product_id)

	insert_product = "INSERT INTO product_merchant_alias (product_id, merchant_alias_id, user_id, created_at, source) \
	VALUES \
	(%d, %d, %d, '0000-00-00 00:00:00', '%s')" % (product_id, merchant_alias_id, user_id, source)
	
	dc.execute(insert_product)

	rows = dc.execute("SELECT * FROM product_merchant_alias WHERE product_id = %d" % product_id)
	product_merchant_alias_id = rows[0][0]

	return product_merchant_alias_id
Ejemplo n.º 3
0
def create_alias_merchant(name, merchant_code, user_id=35):
	
	delete_alias_merchant_by_merchant_code(merchant_code)

	insert_alias_merchant = "INSERT INTO merchant_alias (name, merchant_code, user_id, created_at) \
	VALUES \
	('%s', '%s', %d, '0000-00-00 00:00:00')" % (name, merchant_code, user_id)
	
	dc.execute(insert_alias_merchant)

	rows = dc.execute("SELECT * FROM merchant_alias WHERE merchant_code = '%s'" % merchant_code)
	alias_id = rows[0][0]

	return alias_id
Ejemplo n.º 4
0
def delete_collection_by_category_id(category_id):
    rows = dc.execute("SELECT * FROM collections WHERE category_id = '%s'" %
                      category_id)
    if len(rows) == 0:
        return
    collection_id = rows[0][0]
    delete_collection_by_collection_id(collection_id)
Ejemplo n.º 5
0
def delete_collection_by_collection_id(collection_id):
    dc.execute(
        "DELETE FROM translates where languagable_id=%d and languagable_type='Collection'"
        % collection_id)
    dc.execute("DELETE FROM apps_collections WHERE collection_id = %d" %
               collection_id)
    dc.execute("DELETE FROM collections WHERE id = %d" % collection_id)
    dc.execute("DELETE FROM product_collections WHERE collection_id = '%s'" %
               collection_id)
Ejemplo n.º 6
0
def create_collection(parent_id, pkey, name, slug, is_category, category_id,
                      pds_collection):

    delete_collection_by_category_id(category_id)

    insert_collections = "INSERT INTO collections (parent_id,pkey,attachment_id,name,slug,is_category,collection_type,category_id,created_at,updated_at,deleted_at,pds_collection) \
	VALUES \
	(%d, %d, NULL, '%s', '%s', '%s', 'default', '%s', '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL, '%s')" % (
        parent_id, pkey, name, slug, is_category, category_id, pds_collection)

    dc.execute(insert_collections)

    rows = dc.execute("SELECT * FROM collections WHERE category_id = '%s'" %
                      category_id)
    colId = rows[0][0]

    insert_translation = "INSERT INTO translates (locale, languagable_id,languagable_type,text,title,name,description,key_feature,body,unit_type,caption,advantage) \
	VALUES \
	('en_US', %d, 'Collection', NULL, NULL, '%s', NULL, NULL, NULL, NULL, NULL, NULL)" % (
        colId, name)
    dc.execute(insert_translation)

    insert_app_collections = "INSERT INTO apps_collections (collection_id, app_id, `order`) \
	VALUES (%d, 1, NULL)" % colId
    dc.execute(insert_app_collections)

    return colId
Ejemplo n.º 7
0
def delete_product_from_alias_merchant_by_product_id(product_id):
	rows = dc.execute("SELECT * FROM product_merchant_alias WHERE product_id = %d" % product_id)
	if len(rows) == 0:
		return
	product_merchant_alias_id = rows[0][0]
	delete_product_from_alias_merchant_by_id(product_merchant_alias_id)
Ejemplo n.º 8
0
def delete_product_from_alias_merchant_by_id(product_merchant_alias_id):
	dc.execute("DELETE FROM product_merchant_alias WHERE id = %d" % product_merchant_alias_id)
Ejemplo n.º 9
0
def delete_alias_merchant_by_merchant_code(merchant_code):
	rows = dc.execute("SELECT * FROM merchant_alias WHERE merchant_code = '%s'" % merchant_code)
	if len(rows) == 0:
		return
	alias_id = rows[0][0]
	delete_alias_merchant_by_id(alias_id)
Ejemplo n.º 10
0
def delete_alias_merchant_by_id(alias_id):
	dc.execute("DELETE FROM merchant_alias WHERE id = %d" % alias_id)
Ejemplo n.º 11
0
def get_alias_merchant():
	rows = dc.execute("SELECT id FROM merchant_alias WHERE deleted_at is null")
	if len(rows) == 0:
		return
	alias_id = rows[0][0]
	return alias_id
Ejemplo n.º 12
0
def delete_brand_by_brand_id(brand_id):
    dc.execute("DELETE FROM brands where id=%d " % brand_id)