def update_tags(): shop = Shopify() store_products = get_all_products(shopify.Product) for product in store_products: mylist = [] if type(product.tags) is list: for tag in product.tags: tag = tag.replace(' ', '') mylist.append(tag.lower()) elif ',' in product.tags: for tag in product.tags.split(','): tag = tag.replace(' ', '') mylist.append(tag.lower()) else: tags = tags.replace(' ', '') mylist.append(product.tags.lower()) i = 0 count = 0 for tag in mylist: if 'MONTH' in tag: mylist[i] = tag.replace('MONTH', 'm') count += 1 elif 'month' in tag: mylist[i] = tag.replace('month', 'm') count += 1 i += 1 if count > 0: product.tags = mylist shop.update_tags(product)
def update_vendors_and_titles(): shop = Shopify() store_products = get_all_products(shopify.Product) for store in store_products: if "' " in store.title: store.title = store.title.replace("' ", ' ') shop.edit_product_vendor_and_title(store)
def update_variant_images(): shop = Shopify() store_products = get_all_products(shopify.Product) source_products = save_products_in_db.get_source_products() for store in store_products: for source in source_products: if store.handle == source['handle'] and store.handle == 'american-eagle-long-sleeves-pique-polo-shirt': shop.create_image_of_variants(source, store)
def update_stock(): store_products = get_all_products(shopify.Product) all_source_products = save_products_in_db.get_source_products() shop = Shopify() for store_product in store_products: for source_products in all_source_products: if source_products['handle'] == store_product.handle and check_changes(store_product, source_products): shop.update_variant(store_product, source_products)
def update_variant_by_handle(): shop = Shopify() store_products = get_all_products(shopify.Product) source_products = save_products_in_db.get_source_products() for product in store_products: if product.handle == 'mustang-cotton-stretch-ankle-socks': for source in source_products: if source['handle'] == 'mustang-cotton-stretch-ankle-socks': shop.create_image_of_variants(source, product)
def update_title(): shop = Shopify() store_products = get_all_products(shopify.Product) with open('products_export.csv') as file: csv_reader = csv.reader(file, delimiter=',') for line in csv_reader: if line[1] != '' and line[0] != 'Handle': for product in store_products: if product.handle == line[0]: shop.edit_product_title(product, line[1])
def delete_bad_products(): store_products = get_all_products(shopify.Product) shop = Shopify() with open('delete_products.csv') as file: csv_reader = csv.reader(file, delimiter=',') prev = '' handles = [] for line in csv_reader: if prev != line[8] and line[7].lower() == 'no': handle = line[8].split("/products/") handles.append(handle[1]) prev = line[8] for store_product in store_products: if store_product.handle in handles: shop.delete_product(store_product)
def update_options(): shop = Shopify() store_products = get_all_products(shopify.Product) for product in store_products: temp = 0 for variant in product.variants: x = check_size(variant.option1) y = check_size(variant.option2) z = check_size(variant.option3) if x != variant.option1 or y != variant.option2 or z != variant.option3: variant.option1 = x variant.option2 = y variant.option3 = z temp += 1 if temp > 0: shop.update_variant_titles(product)
def update_handles(): shop = Shopify() for product in get_store_products_from_db(): handle = product['title'].lower() for option in product['options']: if option['name'] == 'Color': for value in option['values']: handle = handle + "-{}".format(value.lower()) handle = handle.replace(' ', '-').replace(' ', '-').replace(' ', '-').replace('/', '-').replace("'", '-') handle = handle.replace(',', '-').replace('.', '-').replace('--', '-').replace('+', '')
def update_tags_with_sizes(): shop = Shopify() store_products = get_all_products(shopify.Product) for product in store_products: mylist = [] if type(product.tags) is list: for tag in product.tags: mylist.append(tag) elif ',' in product.tags: for tag in product.tags.split(','): mylist.append(tag) else: mylist.append(product.tags) product.tags = mylist count = 0 for option in product.options: if option.name == "Length": if product.tags != make_tags(product.tags, option.values): product.tags = make_tags(product.tags, option.values) count += 1 if count > 0: shop.update_tags(product)