=>get price rules from db for etsy store and sku_type=b2b =>get price rules from db for etsys tore and sku type=b2c =>make an sku list from tables (leemarpet_fbm_new,notions_sd300_fbm_new, Essential_fbm,buy_season_bonanza_new,KW01_bonanza,morris_bonanza, all_price_approval_new,all_price_approval_NM01_new,all_price_PET_b2b, product_master_catalog,prouct_master_catalog_NM01) FOR checking if sku is b2b or b2c. =>create function get_cp1 => which fetches prices for sku by applying the rules. =>create function get_cp2=> fetches prices for sku by applying the rules. =>create function get_hw1 => which fetches prices for sku by applying the rules. =>create function get_hw2=> fetches prices for sku by applying the rules. =>if store1==ec, then call function get_cp1 =>if store2==ec, then call function get_cp1 =>if store3==ec, then call function get_cp2 =>if store4==ec, then call function get_cp2 =>if store1==HW, then call function get_hw1 =>if store2==hw, then call function get_hw1 =>if store3==hw, then call function get_hw2 =>if store4==hw, then call function get_hw2 =>create function for sending mail if any error occurs in listing id =>function =>to get token =>using token and api to get listing id fron etsy =>create file named etsy_before_push with fields like, listing id, sku, inventory and price. =>create file named etsy_after_push with fields like, listing id, sku, inventory and price. =>store listing ids in file named etsy_today_local.csv =>Check time, for the script, if 1 hour is about to end, then we regenerate the new tokn =>For each listing id, =>get response(column) from etsy_listing_structure =>if no response found, then we skip that listing id. =>if any error found, then we send email with error details. =>if product array found, we calc count of items presnt in product array (whether listing id has multiple sku list or single sku item) =>if count is 0, then we send error email and break from the loop. =>if multiple sku then save the sku in array and for each sku, we fetch inventory from 4p_inventory table and price we save from the product array(api) =>next we check if sku is b2c =>if store3 or store 4 is ec, and if the sku is found in cp_ec2 array, then we use the calculated price. =>if store3 or store 4 is hw, and if sku is found in cp_hw2 array, then we use the calculated price. =>if sku is b2b =>if store1 or store2 is ec or hw then we use calculated price else =>if sku doesnt belong to b2b or b2c, then we store it in blank_sku if calculated price is 0 then we set the price from the etsy website itself. next we check if prev qty and new qty are diff and prev price and new price are diff, then we update the flag to 1, write the sku, with qty and price in the after push file. for multilisting sku, we check, if sum of the qty(multiple products qty) is 0, then we set this listing id to be deactivated. If single listing sku, then get its inv from 4p_inventory table. and take the price from the website. we check if b2b or b2c sku and use the new calc price accordingly. update the sku, new price, new qty in after push file. if new price=0,t hen we take the existing price from the etsy website. next if prev qty and new qty are differenct OR if old price != new price, next if flag_qty==1, then we deactivate the listing id if skus, price or qty needs to be updated, then we update the listing id using api Lastly using api, we get the list of expired listing id for the particular store. And update the values in etsy_expired_products table. send email with before push file, after push file and list of expired listing id (if any)