if ($canceled_qty >= $over_refill) { break; } } else { $logger->write(" > cancel failed, ID: {$order_id}"); } } } } $logger->write("Total canceled Qty = {$canceled_qty_total}"); } } $logger->write('2) AUTO REFILL'); //EXCLUDE PRODUCT MANUALLY $collection_id_for_exclusion = '1174'; $products_excluded = array_keys($class_s->retrieveProducts($collection_id_for_exclusion)); //Send email notification if missing quantity is > 0.2 * target stock $tolerance_email_notification = 0.2; $missing_qty_min_to_trigger_notification = 3; $stock_target_tolerance = ($missing_qty_min_to_trigger_notification - 1) / $tolerance_email_notification + 1; //collect the stars we need to grab for making auto refill $stars = array(); for ($s = 0; $s <= 3; $s++) { if (Product::$diohStopLevel[$s] > 0) { $stars[] = $s; } } //Check is all DIOH TARGET is set to 0 $total_qty = 0; if (count($stars) == 0) { $logger->write('All DIOH Target is 0, no depot refill needed!');
$invoice->recalculate(); } $logger->write("Task 5 - End"); $logger->write("Task 6 (DOOM TO KILL CHECKER) - Start"); if (SERVER_IS_LOCAL) { $logger->write("Skipped! Not to be run in Manobo Local"); } else { use_class('styles'); use_class('products_minierp'); use_class('products_articles'); $class_s = new styles(); $class_pm = new products_minierp(); $class_pa = new products_articles(); $style_id = 680; //COLLECTION: DOOMED TO BE KILLED $products = $class_s->retrieveProducts($style_id, false); $killed = array(); $logger->write('Total products to check: ' . count($products)); foreach ($products as $pid => $date_added) { //SET INACTIVE FOR DTK ARTICLES WHICH HAVE NO DEPOT STOCK $products_articles = $class_pa->retrieveList($pid); foreach ($products_articles as $pa) { $stock_article = $class_pm->stockRetrieve(WAREHOUSE_ID_PRODUCTS_HAMBURG, $pid, $pa['products_articles_id']); if ($stock_article == 0) { $class_pa->setActiveStatus($pa['products_articles_id'], 0); } } $stock = $class_pm->stockRetrieve(WAREHOUSE_ID_PRODUCTS_HAMBURG, $pid, '*'); if ($stock == 0) { //KILL PRODUCT AND REMOVE IT FROM DTK COLLECTION $username = '******';
/** * get products based on filter (family, main element, symbol, color, and brand) * @param Int $product_id Products ID * @return Array Array of products ID */ function getProductsCrossSelling($product_id) { use_class('products_brand'); use_class('styles_php4'); use_class('products_minierp'); use_class('products_family_php4'); $class_s = new styles(); $class_pb = new products_brand(); $class_pm = new products_minierp(); $max_products = 50; $max_products_by_family = 20; $max_products_by_main_element = 10; $max_products_by_symbol = 30; // $max_products_by_color = 5; // $max_products_by_brand = 5; $max_products_by_category = 40; $pids = array(); $p_data = $class_pm->retrieveDetail($product_id, 'p,cat'); //FAMILY $family_id = $p_data['p']['family_id']; $obj_family = new products_family(null, $product_id); $pid_family = $obj_family->retrieveMembers(); $pid_family_exclude_kill_prod = $class_pm->filterExcludeKilledProducts($pid_family); $pid_similar = $obj_family->getSimilarProducts($product_id, false, false); $pids = array_merge($pid_family_exclude_kill_prod, $pid_similar); $key = array_search($product_id, $pids); unset($pids[$key]); $pids = array_slice($pids, 0, 20); //MAIN ELEMENT $pid_family_filter = implode(",", $pids); if ($pid_family_filter == '') { if ($p_data['p']['products_brand_id'] == 14) { $pid_family_filters = "AND pue.products_id NOT IN ({$product_id}) AND p.products_brand_id = 14 "; } else { $pid_family_filters = "AND pue.products_id NOT IN ({$product_id})"; } } else { if ($p_data['p']['products_brand_id'] == 14) { $pid_family_filters = "AND pue.products_id NOT IN ({$pid_family_filter}, {$product_id}) AND p.products_brand_id = 14 "; } else { $pid_family_filters = "AND pue.products_id NOT IN ({$pid_family_filter}, {$product_id})"; } } $main_element_id = $class_pm->getMainElement($product_id); if ($main_element_id != NULL) { $pid_main_element = $class_pm->getProductsByMainElement($main_element_id, false, $pid_family_filters, "ORDER BY pl.sold_monthly_3 DESC LIMIT {$max_products_by_main_element}"); $pids = array_merge($pids, $pid_main_element); } //SYMBOL $symbol_id = $class_s->getProductStyle($product_id); $pid_main_element_filter = implode(",", $pids); if ($pid_main_element_filter == '') { if ($p_data['p']['products_brand_id'] == 14) { $pid_main_element_filters = "AND shp.products_id NOT IN ({$product_id}) AND p.products_brand_id = 14 "; } else { $pid_main_element_filters = "AND shp.products_id NOT IN ({$product_id})"; } } else { if ($p_data['p']['products_brand_id'] == 14) { $pid_main_element_filters = "AND shp.products_id NOT IN ({$pid_main_element_filter}, {$product_id}) AND p.products_brand_id = 14 "; } else { $pid_main_element_filters = "AND shp.products_id NOT IN ({$pid_main_element_filter}, {$product_id})"; } } if ($symbol_id['Symbol'] != '') { $pid_symbol = array_keys($class_s->retrieveProducts($symbol_id['Symbol'], false, $pid_main_element_filters, "ORDER BY pl.sold_monthly_3 DESC LIMIT {$max_products_by_symbol}")); $pids = array_merge($pids, $pid_symbol); } //COLOR // $color_id = $class_pm->loadColorPattern($product_id); // if ($color_id) { // $pids_symbol_filter = implode(",", $pids); // if ($pids_symbol_filter == '') { // $pid_symbol_filters = "AND ptcp.products_id NOT IN ($product_id)"; // } else { // $pid_symbol_filters = "AND ptcp.products_id NOT IN ($pids_symbol_filter, $product_id)"; // } // $pid_color = $class_pm->getProductsByColor( // $color_id[0], // false, // $pid_symbol_filters, // "ORDER BY pl.sold_monthly_3 DESC LIMIT $max_products_by_color"); // $pids = array_merge($pids, $pid_color); // } //BRAND // $brand_id = $p_data['p']['products_brand_id']; // if ($brand_id) { // $pids_color_filter = implode(",", $pids); // if ($pids_color_filter == '') { // $pid_color_filters = "AND p.products_id NOT IN ($product_id)"; // } else { // $pid_color_filters = "AND p.products_id NOT IN ($pids_color_filter, $product_id)"; // } // $pid_brand = $class_pb->getProducts( // $brand_id, // false, // $pid_color_filters, // "ORDER BY pl.sold_monthly_3 DESC LIMIT $max_products_by_brand"); // $pids = array_merge($pids, $pid_brand); // } //CATEGORY $cat_id = $p_data['categories_id']; $pids_color_filter = implode(",", $pids); if ($pids_color_filter == '') { if ($p_data['p']['products_brand_id'] == 14) { $pid_color_filters = "AND p.products_id NOT IN ({$product_id}) AND p.products_brand_id = 14 "; } else { $pid_color_filters = "AND p.products_id NOT IN ({$product_id})"; } } else { if ($p_data['p']['products_brand_id'] == 14) { $pid_color_filters = "AND p.products_id NOT IN ({$pids_color_filter}, {$product_id}) AND p.products_brand_id = 14 "; } else { $pid_color_filters = "AND p.products_id NOT IN ({$pids_color_filter}, {$product_id})"; } } $pid_cat = $class_pm->getProductsByCategory($cat_id, false, $pid_color_filters, "ORDER BY pl.sold_monthly_3 DESC LIMIT {$max_products_by_category}"); $pids = array_merge($pids, $pid_cat); //LIMIT ALL PRODUCTS BY 50 $pids = array_slice($pids, 0, $max_products); $pids_implode = implode(",", $pids); if ($p_data['p']['products_brand_id'] == 14) { $pids = $class_pb->getProducts($p_data['p']['products_brand_id'], false, "AND p.products_id IN ({$pids_implode})", "ORDER BY pl.sold_monthly_3 DESC LIMIT {$max_products}"); } return $pids; }
*/ global $db; require_once '../confy.php'; require_once '../functions.php'; require_once '../functions-2.php'; require_once DIR_WS_FUNCTIONS . 'html_output.php'; tep_db_connect(); use_class('styles'); use_class('Product'); $class_s = new styles(); $dest_path = 'OTTO-Online-' . date('ymd') . '/'; if (!is_dir($dest_path)) { mkdir($dest_path, 0750); } $styles_id = tep_db_prepare_input($_GET['styles_id']); $products = array_keys($class_s->retrieveProducts($styles_id)); foreach ($products as $pid) { $p = new Product($pid); $images = array(); $main_default = $p->getImageRaw(Product::IMAGE_TYPE_DEFAULT); $main_amazon = $p->getImageRaw(Product::IMAGE_TYPE_AMAZON); $images[] = is_null($main_amazon) || $main_amazon == '' ? $main_default : $main_amazon; $total_additional_image = $p->getAdditionalImageTotal(); for ($i = 0; $i < $total_additional_image; $i++) { $images[] = $p->getImageAdditionalRaw($i); } $image_counter = 0; foreach ($images as $image) { $image_counter++; $img_location = is_file($image) ? $image : DIR_WS_IMAGES . $image; $new_filename = $p->code . '-' . $image_counter . '.jpg';