$product_ids[] = 32320; $product_ids[] = 32319; $product_ids[] = 32318; $product_ids[] = 44258; $product_ids[] = 32316; $product_ids[] = 32317; $product_ids[] = 32314; $product_ids[] = 32315; //var_dump($product_ids);die(); $added_to_catalog = 0; $activated = 0; $deactivated = 0; foreach ($product_ids as $product_id) { $check_query = tep_db_query("SELECT jng_sp_catalog_id, active_status FROM jng_sp_catalog WHERE jng_sp_id=2 AND products_id={$product_id}"); if (tep_db_num_rows($check_query) == 0) { $insert_id = $class_jc->addProduct('2', $product_id); if ($insert_id > 0) { $added_to_catalog++; } } else { $cat = tep_db_fetch_array($check_query); if ($cat['active_status'] == '0') { $class_jc->activateProduct($cat['jng_sp_catalog_id']); $activated++; } else { $class_jc->deactivateProduct($cat['jng_sp_catalog_id']); $deactivated++; } } } echo "Success add {$added_to_catalog} to OTTO product_catalog";
use_class('products_articles'); $class_pa = new products_articles(); //SP SETTING salesPartnerCombo(); $url_link_path = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (isset($_GET['id'])) { $product_id = tep_db_prepare_input($_GET['id']); } elseif (isset($_POST['product_id'])) { $product_id = tep_db_prepare_input($_POST['product_id']); } //SUBMIT ACTION if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'ADDTOCATALOGUE') { $suppliers_products_id = tep_db_prepare_input($_POST['suppliers_products_id']); //sp_addProductToCatalog($jng_sp_id, $product_id, $suppliers_products_id); $class_jc->addProduct($jng_sp_id, $product_id, $suppliers_products_id); header("Location: ?open=sp-product&id={$product_id}"); exit; } elseif ($_POST['me_action'] == 'UPDATECATALOG') { $field_id = null; $catalog_id = tep_db_prepare_input($_POST['jng_sp_catalog_id']); $pid_query = tep_db_query("SELECT products_id FROM jng_sp_catalog WHERE jng_sp_catalog_id={$catalog_id}"); if (tep_db_num_rows($pid_query) > 0) { $pid_result = tep_db_fetch_array($pid_query); $pid = $pid_result['products_id']; $sda = array(); if (isset($_POST['fName']) && isset($_POST['fValue'])) { $fieldName = tep_db_prepare_input($_POST['fName']); $fieldValue = tep_db_prepare_input($_POST['fValue']); $fieldValue = utf8_decode($fieldValue); if (strpos($fieldValue, 'CRYSTALLIZED?') !== false) {
<?php use_class('jng_sp'); $class_sp = new jng_sp(); use_class('jng_sp_catalog'); $class_jc = new jng_sp_catalog(); //SP SETTING salesPartnerCombo(); //SUBMIT ACTION if (isset($_POST['me_action']) && $_POST['me_action'] == 'IMPORTTOCATALOGUE') { $products = explode(',', tep_db_prepare_input($_POST['products'])); $products = implode(',', $products); $new_ids = $class_jc->addProduct($jng_sp_id, $products); $product_total = count($new_ids); $msgtype = $product_total > 0 ? 'green' : 'red'; $messagebox->add("{$product_total} Products have been added to Catalog", $msgtype); } //START TEMPLATE $content = ''; $content .= '<div class="float-box"><form name="" action="?open=sp-products-import" method="post">'; $content .= '<input type="hidden" name="me_action" value="IMPORTTOCATALOGUE" />'; $content .= '<div>Please type in Product ID seperated by comma:</div>'; $content .= '<div style="margin-top:5px;"><input type="text" name="products" value="" style="width:600px;"/></div>'; $content .= '<div style="margin-top:5px;">'; $content .= '<input type="submit" name="submit" value="Import Products" />'; $content .= '<input type="button" name="cancel" value="Back to Catalog" class="red" onclick="location.href=\'?open=sp-products-finalize\';" />'; $content .= '</div>'; $content .= '</form></div>'; $title = "{$sp_title} Add Multiple Products to Catalog";
tep_db_perform('products_non_configurator', $data); } //APPLY PRODUCTS LINKING $dbqpl = tep_db_query("SELECT links_id, type FROM products_linking WHERE products_id={$products_id}"); while ($r = tep_db_fetch_array($dbqpl)) { $links_id = $r['links_id']; $type = $r['type']; $class_pl->add($pid, $type, $links_id, true); } //APPLY NAVID's $dbq = tep_db_query("SELECT jng_sp_id, navigation, navigation2, navigation3 FROM jng_sp_catalog WHERE products_id={$products_id} ORDER BY jng_sp_id"); while ($r = tep_db_fetch_array($dbq)) { $nav = $r['navigation']; $nav2 = $r['navigation2']; $nav3 = $r['navigation3']; $class_jc->addProduct($r['jng_sp_id'], $pid); $p_cat = $class_jc->retrieveCatalog($r['jng_sp_id'], "jc.products_id = '{$pid}'"); saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation', $nav); saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation2', $nav2); saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation3', $nav3); } } } $draft = new design_draft(null, $products_id); $draft->detailCompleted($products_id, $session_userinfo['username']); echo utf8_encode('UPDATED'); exit; } elseif ($_POST['me_action'] == 'UPDATECATALOG') { $dt = array(); $catalog_id = tep_db_prepare_input($_POST['jcid']); $field_name = tep_db_prepare_input($_POST['fieldName']);
} $sp_detail = $class_sp->retrieveDetail($jng_sp_id); $sp_code = $sp_detail['package_prefix']; $sp_name = $sp_detail['name']; $header = array(); $header['img'] = 'Product'; $header['nm w300'] = 'Info'; $header['ps w150'] = 'Pieces Sold'; $header['st w100'] = 'Stock'; $header['act w150'] = 'Add/Remove'; if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'ADDALLTOZADE') { $pids = explode(',', tep_db_prepare_input($_POST['products'])); $total_catalog = 0; foreach ($pids as $pid) { $catalog_ids = $class_jc->addProduct($jng_sp_id, $pid); if (count($catalog_ids) > 0) { $total_catalog++; //SPECIAL RULE FOR BUYVIP, ACTIVATE PRODUCTS DIRECTLY //AND SAVE PRICE WITH FACTOR 4 AND 6 WITH DISCOUNT ACTIVE if ($jng_sp_id == '7') { $default_discount = 0.5; foreach ($catalog_ids as $cid) { $class_jc->activateProduct($cid); } $p = new Product($pid); $price_uvp = $p->getPriceUVP(); $pnd = $p->getPriceSellingDefaultB2B($price_uvp, $jng_sp_id); $pd = round((1 - $default_discount) * $pnd, 2); $p->updatePriceSellingB2B($jng_sp_id, $pnd, $pd, true); }
$result['jcid'] = $jcid; $result['info-added'] = $info_added; $result['info-updated'] = $info_updated; $result['info-deactivated'] = $info_deactivated; ajaxReturn($result); } elseif ($_POST['me_action'] == 'ADD' || $_POST['me_action'] == 'UPDATE') { $amvd_id = 5; $pid = tep_db_prepare_input($_POST['pid']); $navigation = tep_db_prepare_input($_POST['n']); $info_added = tep_db_prepare_input($_POST['ia']); $info_updated = tep_db_prepare_input($_POST['iu']); $info_deactivated = tep_db_prepare_input($_POST['id']); $data = array(); $data['navigation'] = $navigation; if ($_POST['me_action'] == 'ADD') { $insert_id = $class_jc->addProduct($amvd_id, $pid); $jcid = $insert_id[0]; $info_added++; } else { $jcid = tep_db_prepare_input($_POST['jcid']); $data['price_uploaded'] = '0'; $data['active_status'] = '1'; $info_updated++; } //Update AM.VD specific data $class_jc->updateField($jcid, $data); $result = array(); $result['pid'] = $pid; $result['info-added'] = $info_added; $result['info-updated'] = $info_updated; $result['info-deactivated'] = $info_deactivated;
function copyFromProducts($products_id_to_copied, $products_id_to_applied, $options = '*', $elements_id_to_exclude = '', $skip_same_add_length_composition = false) { use_class('products_articles'); $class_pa = new products_articles(); $have_element_to_exclude = false; if ($elements_id_to_exclude != '' && !is_array($elements_id_to_exclude)) { $elements_id_to_exclude = explode(',', $elements_id_to_exclude); $have_element_to_exclude = true; } $product = $this->retrieveDetail($products_id_to_copied, 'p,pd,pnc,cat'); $product_to_applied = $this->retrieveDetail($products_id_to_copied, 'cat'); $categories_is_same = $product['categories_id'] == $product_to_applied['categories_id']; $articles = $class_pa->retrieveList($products_id_to_copied); $articles_to_applied = $class_pa->retrieveList($products_id_to_applied); $add_length = array(); $add_length_to_applied = array(); if (isset($articles) && is_array($articles) && count($articles) > 0) { foreach ($articles as $a) { $add_length[] = $a['length']; } } if (isset($articles_to_applied) && is_array($articles_to_applied) && count($articles_to_applied) > 0) { foreach ($articles_to_applied as $ata) { $add_length_to_applied[] = $ata['length']; } } if (!is_array($products_id_to_applied)) { $products_id_to_applied = explode(',', $products_id_to_applied); } if ($options != '*') { $options = explode(',', $options); } //START UPDATE PRODUCT DETAIL TO ALL PRODUCTS WHICH PRODUCT DETAIL IS NOT FILLED foreach ($products_id_to_applied as $pid) { if ($options == '*' || in_array('cp', $options)) { //APPLY COLOR PATTERN $cps = $this->loadColorPattern($products_id_to_copied); if (count($cps) > 0) { saveColors($pid, implode(',', $cps)); } } if ($options == '*' || in_array('b', $options)) { //APPLY BRAND use_class('products_brand'); $class_pb = new products_brand(); $class_pb->updateProductBrand($pid, $product['p']['products_brand_id']); } if (($options == '*' || in_array('l', $options)) && $categories_is_same) { //APPLY LENGTH $def_length = $product['pnc']['products_length']; $this->saveLength($pid, $def_length, $add_length); } if ($options == '*' || in_array('eu', $options)) { //TODO: CHECK HOW TO ALSO COPY ELEMENTS IF OTHER PRODUCTS STILL DOESN'T HAVE ANY //APPLY ELEMENT USED & QTY $el_used = $this->retrieveElementsUsage($products_id_to_copied); if (count($el_used) > 0) { $elids = array(); $elqtys = array(); foreach ($el_used as $elid => $el_data) { if ($have_element_to_exclude) { $check_key = array_search($elid, $elements_id_to_exclude); if ($check_key !== false) { continue; } } $elids[] = $elid; $elqtys[] = $el_data['quantity']; } $this->addElementToProducts($pid, $elids, $elqtys); } //APPLY OVERRIDE ELEMENTS (IF EXISTS) AND HAVE SAME ADDITIONAL LENGTH COMPOSITION if (count($add_length) > 0 && $categories_is_same) { $have_same_add_length_composition = true; if (count($add_length) == count($add_length_to_applied)) { foreach ($add_length as $al) { if (!in_array($al, $add_length_to_applied)) { $have_same_add_length_composition = false; break; } } } else { $have_same_add_length_composition = false; } if ($have_same_add_length_composition || $skip_same_add_length_composition) { foreach ($add_length as $length) { $dbq_o = tep_db_query("SELECT * FROM products_articles WHERE products_id = {$products_id_to_copied} AND length = {$length}"); $dbq_c = tep_db_query("SELECT * FROM products_articles WHERE products_id = {$pid} AND length = {$length}"); if (tep_db_num_rows($dbq_o) > 0 && tep_db_num_rows($dbq_c) > 0) { $r_o = tep_db_fetch_array($dbq_o); $r_c = tep_db_fetch_array($dbq_c); $products_articles_id = $r_c['products_articles_id']; $dbq_ovr = tep_db_query("SELECT * FROM products_articles_use_elements WHERE products_articles_id = {$r_o['products_articles_id']}"); while ($r_ovr = tep_db_fetch_array($dbq_ovr)) { $ovr_elid = $r_ovr['elements_id']; $dbq_pue_o = tep_db_query("SELECT * FROM products_use_elements WHERE products_use_elements_id = {$r_ovr['products_use_elements_id']}"); $r_pue_o = tep_db_fetch_array($dbq_pue_o); $dbq_pue_c = tep_db_query("SELECT * FROM products_use_elements WHERE products_id = {$pid} AND elements_id = {$r_pue_o['elements_id']}"); $r_pue_c = tep_db_fetch_array($dbq_pue_c); $products_use_elements_id = $r_pue_c['products_use_elements_id']; $ovr_data = array(); if ($have_element_to_exclude) { $check_key = array_search($r_ovr['elements_id'], $elements_id_to_exclude); if ($check_key !== false) { continue; } } $ovr_data['elements_id'] = $r_ovr['elements_id']; $ovr_data['quantity'] = $r_ovr['quantity']; $ovr_data['products_articles_id'] = $products_articles_id; $ovr_data['products_use_elements_id'] = $products_use_elements_id; $class_pa->overrideElement($products_articles_id, $products_use_elements_id, $ovr_data); } } } } } } if ($options == '*' || in_array('mp', $options)) { //APPLY MANUAL PI $dbqmp = tep_db_query("SELECT * FROM products_non_configurator pnc WHERE pnc.products_id={$products_id_to_copied}"); $mpi = tep_db_fetch_array($dbqmp); saveManualPI($pid, $mpi['products_instruction']); } if ($options == '*' || in_array('pl', $options)) { //APPLY PRODUCTS LINKING use_class('products_linking'); $class_pl = new products_linking(); $dbqpl = tep_db_query("SELECT * FROM products_linking WHERE products_id={$products_id_to_copied}"); while ($r = tep_db_fetch_array($dbqpl)) { $links_id = $r['links_id']; $type = $r['type']; $class_pl->add($pid, $type, $links_id, true); } } if ($options == '*' || in_array('ni', $options)) { //APPLY NAVID's use_class('jng_sp_catalog'); $class_jc = new jng_sp_catalog(); $dbq = tep_db_query("SELECT jng_sp_id, navigation, navigation2, navigation3 FROM jng_sp_catalog WHERE products_id={$products_id_to_copied} ORDER BY jng_sp_id"); while ($r = tep_db_fetch_array($dbq)) { $nav = $r['navigation']; $nav2 = $r['navigation2']; $nav3 = $r['navigation3']; $class_jc->addProduct($r['jng_sp_id'], $pid); $p_cat = $class_jc->retrieveCatalog($r['jng_sp_id'], "jc.products_id = '{$pid}'"); saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation', $nav); saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation2', $nav2); saveCatalog($p_cat[0]['jng_sp_catalog_id'], 'navigation3', $nav3); } } } }
} if ($att_topics != null) { removeProducts($pid, $att_colls, $att_symbols); foreach ($att_topics_array as $att_topics_id) { $class_s->addProduct($att_topics_id, $pid, $username); } } elseif ($att_topics == null) { removeProducts($pid, $att_colls, $att_symbols); } } } foreach ($products_to_update as $pid) { $class_pm->updateDetail($pid, $gender, $agegroup); if ($addtoamvd == '1') { if ($amvdcatid == '0') { $catalog_id = $class_jc->addProduct('5', $pid); $amvdcatid = $catalog_id[0]; } if ($amvdprice_new > 0) { $sda = array('price_new' => $amvdprice_new); $class_jc->updateField($amvdcatid, $sda); } } $class_pm->saveDescription($pid, $languages_id, $pname, $pdesc, $pkeys, $pshortname, null, null, $topicname, $colname, null, null); $pda['name'] = $pname; $pda['description'] = $pdesc; $pda['keywords'] = $pkeys; $pda['status_price'] = '1'; //$pda['products_selling_points'] = $pspoint; $pda['short_name'] = $pshortname; tep_db_perform('jng_sp_catalog', $pda, 'update', "products_id={$pid}");
$navtrans['38585756'] = '200911240012'; $navtrans['38585757'] = '200911240012'; $navtrans['38585757'] = '200911240012'; $new_sp_id = '2'; $copy_counter = 0; $active_counter = 0; $update_counter = 0; foreach ($nm_cat as $c) { $check_query = tep_db_query("SELECT jng_sp_catalog_id, active_status FROM jng_sp_catalog WHERE jng_sp_id={$new_sp_id} AND products_id={$c['products_id']}"); if (tep_db_num_rows($check_query) > 0) { $check_result = tep_db_fetch_array($check_query); $catalog_id = $check_result['jng_sp_catalog_id']; $active_status = $check_result['active_status']; } else { $copy_counter++; $cat_ids = $class_jc->addProduct($new_sp_id, $c['products_id']); $catalog_id = $cat_ids[0]; $active_status = '0'; } $sda = array(); if (array_key_exists($c['navigation'], $navtrans)) { if ($active_status == '0') { $class_jc->activateProduct($catalog_id); $active_counter++; } $sda['navigation'] = $navtrans[$c['navigation']]; } $sda['status_price'] = '1'; $sda['navigation3'] = 'female'; $class_jc->updateField($catalog_id, $sda); $update_counter++;