/** * Activate products in J&G website and optinally in other SP or create a sample order * @param Array $products_id Array of Products ID to be activated * @param Boolean $activate_in_sp Set to true to activate also to SP where the data is already prepared * @param Boolean $create_sample Set to true to auto create a sample order (as depot order) for all products */ function activateProducts($products_id, $activate_in_sp = true, $create_sample = false) { //Just in case $products_id is sent as string: if (!is_array($products_id)) { $products_id = explode(',', $products_id); } //ACTIVATE IN SP if ($activate_in_sp) { use_class('jng_sp_catalog'); $class_jc = new jng_sp_catalog(); $class_jc->activateProducts($products_id); } //CREATE SAMPLE ORDER if ($create_sample) { use_class('depot_orders'); use_class('products_ean'); $class_do = new depot_orders(); $class_ean = new products_ean(); foreach ($products_id as $pid) { $ean = $class_ean->getEAN($pid); $so_qty = '2'; //changed from '1' to '2' (prepared 1 for HH and 1 for Design Team Bali) for ($i = 1; $i <= $so_qty; $i++) { $class_do->newOrder(SEGMENT_ID_HAMBURG, $pid, '0', $ean, '1', null, null, null, 'CSO - New Products'); } } } //ACTIVATE PRODUCTS $sda = array(); if ($create_sample) { $sda['sample_created'] = '1'; } $sda['products_status'] = '1'; //JNG Website active status $sda['active_status'] = '1'; //General active status $sda['products_date_added'] = date('Y-m-d H:i:s'); $products_filter = implode(',', $products_id); tep_db_perform('products', $sda, 'update', "products_id IN ({$products_filter})"); }