/** * Display data in new columns * * @param $column Current column * * @return Data for the column */ function lhg_db_custom_columns($column) { global $post; $oos = '<font color="red"><b>out of stock</b></font>'; //echo "COL: $column"; switch (substr($column, 0, 8)) { case 'shop-ID-': //for which shop ID are we showing information? $shopid = substr($column, 8); //check if shop_article_id is defined $number = lhg_db_does_article_id_exist($post->ID, $shopid); if ($number > 1) { $metaData = "ERROR: too many results"; break; } $shop_article_id = lhg_db_get_shop_article_id($post->ID, $shopid); if ($number == 1) { $metaData = lhg_db_get_price($post->ID, $shopid); $id = lhg_db_get_id($post->ID, $shopid); $difftime = time() - lhg_db_get_time($post->ID, $shopid); $stime = number_format($difftime / (60 * 60 * 24), 0); if ($stime == 0) { $timestring = "today"; } if ($stime == 1) { $timestring = "yesterday"; } if ($stime > 1) { $timestring = $stime . " days ago"; } if ($shop_article_id == "NOT_AVAILABLE") { echo '<div class="inline-edit-group"> Not available<br>checked ' . $timestring . '<br> <a href="admin.php?page=lhg_pricedb_update&mode=update&sid=' . $shopid . '&id=' . $id . '&pid=' . $post->ID . '"> update</a></div>'; } else { if ($metaData == "") { $metaData = "(no price found)"; } echo '<div class="inline-edit-group"> ' . $shop_article_id . '<br>' . $metaData . '<br> <a href="admin.php?page=lhg_pricedb_update&mode=update&sid=' . $shopid . '&id=' . $id . '&pid=' . $post->ID . '"> update</a></div>'; } break; } if ($number == 0) { $metaData = "not in DB"; echo '<div class="inline-edit-group"> <a href="admin.php?page=lhg_pricedb_update&mode=create&sid=' . $shopid . '&pid=' . $post->ID . '"> create</a></div>'; echo '<div class="inline-edit-group"> (<a href="admin.php?page=lhg_pricedb_update&mode=notavail&sid=' . $shopid . '&pid=' . $post->ID . '">Not available</a>)</div>'; break; } break; case 'metade': $metaData = get_post_meta($post->ID, 'price-amazon.de', true); break; } if ($metaData == "out of stock") { $metaData = $oos; } if ($metaData == "") { $metaData = "not found"; } //Redcoon // if (substr($column,0,8) == "shop-ID-") echo $metaData; }
function lhg_sanity_redcoon() { #echo "Searching for SID 1"; $sid = 1; global $lhg_price_db; $sql = "SELECT lhg_article_id FROM `lhgprices` WHERE `shop_id` = 1 AND `shop_article_id` != 'NOT_AVAILABLE'"; $results = $lhg_price_db->get_results($sql); #print "<br>Results: "; #var_dump($results); #return $result; foreach ($results as $result) { $print_me = 0; $sql = "SELECT shop_article_id FROM `lhgprices` WHERE `shop_id` = 1 AND `lhg_article_id` = " . $result->lhg_article_id; $shop_article_id = $lhg_price_db->get_var($sql); $sql = "SELECT permalink_de FROM `lhgtransverse_posts` WHERE `postid_de` = " . $result->lhg_article_id; $shop_article_url_de = $lhg_price_db->get_var($sql); $sql = "SELECT permalink_com FROM `lhgtransverse_posts` WHERE `postid_com` = " . $result->lhg_article_id; $shop_article_url_com = $lhg_price_db->get_var($sql); #print "<br>Res: "; var_dump($result); if ($shop_article_url_de != "") { $output = '<br>ID_de: <a href="' . $shop_article_url_de . '">' . $result->lhg_article_id . "</a>"; } if ($shop_article_url_de == "") { $output = '<br>ID_de: ' . $result->lhg_article_id; } $sql = "SELECT postid_com FROM `lhgtransverse_posts` WHERE `postid_de` = " . $result->lhg_article_id; $pid_com = $lhg_price_db->get_var($sql); if ($shop_article_url_com != "") { $output .= ' -> ID_com: <a href="' . $shop_article_url_com . '">' . $pid_com . "</a>"; } if ($shop_article_url_com == "") { $output .= ' -> ID_com: ' . $pid_com; } if ($pid_com != 0) { #check if available $output .= "-> check if already available (it:"; $sql = "SELECT id FROM `lhgprices` WHERE `lhg_article_id` = " . $pid_com . " AND shop_id = 5"; $price_id_it = $lhg_price_db->get_var($sql); if ($price_id_it != "") { $output .= " {$price_id_it}) "; } if ($price_id_it == "") { $output .= " none) "; } if ($price_id_it == "") { $print_me = 1; } $output .= " (nl:"; $sql = "SELECT id FROM `lhgprices` WHERE `lhg_article_id` = " . $pid_com . " AND shop_id = 15"; $price_id_nl = $lhg_price_db->get_var($sql); if ($price_id_nl != "") { $output .= " {$price_id_nl}) "; } if ($price_id_nl == "") { $output .= " none) "; } if ($price_id_nl == "") { $print_me = 1; } #create entry if ($price_id_it == "") { $output .= "<br> -> create entry IT "; $shop_id = 5; $post_id = $pid_com; $result = lhg_db_create_entry($post_id, $shop_id, $shop_article_id); $output .= ".. done"; //get newly created lhg_db_id $lhg_db_id = lhg_db_get_id($post_id, $shop_id); lhg_refresh_database_entry($lhg_db_id, $shop_id); $print_me = 1; } if ($price_id_nl == "") { $output .= "<br> -> create entry NL "; $shop_id = 15; $post_id = $pid_com; $result = lhg_db_create_entry($post_id, $shop_id, $shop_article_id); $output .= ".. done"; //get newly created lhg_db_id $lhg_db_id = lhg_db_get_id($post_id, $shop_id); lhg_refresh_database_entry($lhg_db_id, $shop_id); $print_me = 1; } } else { $output .= "-> Product not found in COM DB"; $print_me = 1; } if ($print_me == 1) { print $output; } } }