コード例 #1
0
             if ($x == $nav_pos) {
                 $nav[$x] = $fieldValue;
             }
             $nav[$x] = $nav[$x] == '' ? '0' : $nav[$x];
         }
         $field_id = 'nav' . $nav_pos;
         $fieldName = 'navigation2';
         $fieldValue = implode(',', $nav);
     }
 }
 if ($fieldName == 'probrand') {
     $pq = tep_db_query("SELECT products_id FROM jng_sp_catalog WHERE jng_sp_catalog_id={$catalog_id}");
     $r = tep_db_fetch_array($pq);
     $products_id = $r['products_id'];
     $brand_id = $fieldValue == 'N' ? '0' : $fieldValue;
     $class_pb->updateProductBrand($products_id, $brand_id);
     $fieldName = 'use_logo';
     $fieldValue = $fieldValue == 'N' ? '0' : '1';
 }
 $sda[$fieldName] = $fieldValue;
 $sda['last_modified'] = date('Y-m-d H:i:s');
 if ($fieldName == 'active_status' && $fieldValue == '1') {
     $sda['active_date'] = date('Y-m-d H:i:s');
 }
 $class_jc->updateField($catalog_id, $sda);
 if (is_null($field_id)) {
     switch ($fieldName) {
         case 'name':
             $field_id = 'status_name';
             break;
         case 'description':
コード例 #2
0
#  Created : Mar 18, 2011 2:11:13 PM    #
#########################################
use_class('logger');
use_class('products_search');
use_class('products_brand');
$class_ps = new products_search($session_userinfo);
$class_pb = new products_brand();
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'UPDATEBRAND') {
        $pids = tep_db_prepare_input($_POST['pids']);
        $new_brand_id = tep_db_prepare_input($_POST['new_brand_id']);
        $new_brand_name = tep_db_prepare_input($_POST['new_brand_name']);
        $n_request = count(explode(',', $pids));
        $n_updated = 0;
        if ($pids != "" && $n_request > 0) {
            $n_updated = $class_pb->updateProductBrand($pids, $new_brand_id);
        }
        $result = array();
        $result['total_request'] = $n_request;
        $result['total_updated'] = $n_updated;
        $result['new_brand_name'] = $new_brand_name;
        ajaxReturn($result);
    } elseif ($_POST['me_action'] == 'UPDATEPROMONAME') {
        $pids = tep_db_prepare_input($_POST['pids']);
        $new_promoname = tep_db_prepare_input(utf8_decode($_POST['new_promoname']));
        $n_updated = count(explode(',', $pids));
        if ($pids != "" && $n_updated > 0) {
            tep_db_query("UPDATE products_description SET products_promo_name='{$new_promoname}' WHERE products_id IN ({$pids}) AND language_id=2");
            tep_db_query("UPDATE jng_sp_catalog SET promo_name='{$new_promoname}', image_uploaded='0' WHERE jng_sp_id=5 AND products_id IN ({$pids})");
        } else {
            $n_updated = 0;
コード例 #3
0
if (isset($_POST['me_action'])) {
    $class_pm->drawAttributesPostAction();
    if ($_POST['me_action'] == 'SAVENAME') {
        $products_id = tep_db_prepare_input($_POST['products_id']);
        $prodname = tep_db_prepare_input($_POST['prodname']);
        $colors = tep_db_prepare_input($_POST['colors']);
        $sda = array();
        $sda['products_name'] = $prodname;
        $result = tep_db_perform('products_description', $sda, 'update', "products_id={$products_id} AND language_id=2");
        saveColors($products_id, $colors);
        echo utf8_encode("UPDATED");
        exit;
    } elseif ($_POST['me_action'] == 'SAVEBRAND') {
        $products_id = tep_db_prepare_input($_POST['products_id']);
        $brand_id = tep_db_prepare_input($_POST['brand_id']);
        $class_pb->updateProductBrand($products_id, $brand_id);
        echo utf8_encode("UPDATED");
        exit;
    } elseif ($_POST['me_action'] == 'LOADLENGTHS') {
        $products_id = tep_db_prepare_input($_POST['products_id']);
        $result = drawLengthsForm($products_id);
        echo utf8_encode($result);
        exit;
    } elseif ($_POST['me_action'] == 'SAVELENGTHS') {
        use_class('products_ean');
        $class_ean = new products_ean();
        $products_id = tep_db_prepare_input($_POST['products_id']);
        $def_length = tep_db_prepare_input($_POST['def_length']);
        $add_length = tep_db_prepare_input($_POST['add_length']);
        $upd_length = tep_db_prepare_input($_POST['upd_length']);
        $class_pm->saveLength($products_id, $def_length, $add_length);
コード例 #4
0
 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);
             }
         }
     }
 }