$class_jc = new jng_sp_catalog();
use_class('products_articles');
$class_pa = new products_articles();
use_class('products_ean');
$class_ean = new products_ean();
$jng_sp_id = '1';
$products = $class_jc->retrieveCatalogForUpload($jng_sp_id);
$counter_p = 0;
$counter_a = 0;
foreach ($products as $p) {
    if ($p['products_ean'] == '') {
        $class_ean->attachToProduct($p['products_id']);
        $counter_p++;
    }
    $articles = $class_pa->retrieveList($p['products_id']);
    foreach ($articles as $a) {
        if ($a['length'] != $p['length']) {
            if ($a['products_ean'] == '') {
                $class_ean->attactToArticle($a['products_articles_id']);
                $counter_a++;
            }
        }
    }
    echo '.';
}
$content .= '<br />';
$content = "Total Products: {$counter_p}";
$content .= '<br />';
$content .= "Total Articles: {$counter_a}";
echo $content;
tep_db_close();
Ejemplo n.º 2
0
 /**
  * Handle POST/GET Action that related to products_articles
  */
 function processAction()
 {
     if (isset($_POST['me_action']) && $_POST['me_action'] == 'PRODUCTSARTICLES') {
         switch ($_POST['act']) {
             case 'ADDEANTOPRODUCT':
                 $products_id = tep_db_prepare_input($_POST['products_id']);
                 use_class('products_ean');
                 $class_ean = new products_ean();
                 $result = $class_ean->attachToProduct($products_id);
                 break;
             case 'ADDEANTOARTICLE':
                 $article_id = tep_db_prepare_input($_POST['article_id']);
                 use_class('products_ean');
                 $class_ean = new products_ean();
                 $ean_no = $class_ean->attactToArticle($article_id);
                 $result = "{$article_id},{$ean_no}";
                 break;
             case 'ADD':
                 $products_id = tep_db_prepare_input($_POST['products_id']);
                 $price = tep_db_prepare_input($_POST['new_price']);
                 $price_old = tep_db_prepare_input($_POST['new_price_old']);
                 $length = tep_db_prepare_input($_POST['new_length']);
                 $options = array();
                 $options['length'] = $length;
                 $prepared = true;
                 $products_articles_id = $this->add($products_id, $price, $price_old, $options, $prepared);
                 if ($products_articles_id == 0) {
                     $result .= '0';
                 } else {
                     //$result = '<tr><td>Other Length <sup class="red">new</sup></td><td>'.$length.'cm = '.$price.' EUR</td>';
                     $result .= '<tr>';
                     $result .= '<td class="green">New</td>';
                     $result .= '<td class="notice">Unset</td>';
                     $result .= '<td>' . $length . '</td>';
                     //$result .= '<td>'.$price.'</td>';
                     //$result .= '<td>'.$price_old.'</td>';
                     $result .= '<td colspan="2"><a href="">Refresh Page</a> for action links</td>';
                     $result .= '</tr>';
                 }
                 break;
             case 'UPDATE':
                 $options = array();
                 $options['length'] = $_POST['new_length'];
                 $result = $this->update($_POST['products_articles_id'], $_POST['new_price'], $_POST['new_price_old'], $options);
                 break;
             case 'REMOVE':
                 $result = $this->remove($_POST['products_articles_id']);
                 break;
             case 'ARTICLEACTIVATION':
                 $paid = tep_db_prepare_input($_POST['paid']);
                 $status = tep_db_prepare_input($_POST['status']);
                 $this->setActiveStatus($paid, $status);
                 $result = array();
                 $result['paid'] = $paid;
                 $result['status'] = $status;
                 $result['success'] = '1';
                 ajaxReturn($result);
                 exit;
                 break;
         }
         echo utf8_encode($result);
         exit;
     }
 }
Ejemplo n.º 3
0
 function saveLength($products_id, $def_length, $add_length)
 {
     use_class('products_articles');
     use_class('products_ean');
     $class_pa = new products_articles();
     $class_ean = new products_ean();
     $sda = array('products_length' => $def_length);
     $product = $this->retrieveDetail($products_id, 'cat,pnc');
     if (!is_array($product['pnc'])) {
         $sda['products_id'] = $products_id;
         tep_db_perform('products_non_configurator', $sda);
     } else {
         tep_db_perform('products_non_configurator', $sda, 'update', "products_id={$products_id}");
     }
     $sda = array('length' => $def_length);
     tep_db_perform('jng_sp_catalog', $sda, 'update', "products_id={$products_id}");
     $p_ean = $class_ean->getEAN($products_id);
     if ($p_ean == '') {
         $class_ean->attachToProduct($products_id);
     }
     if (is_array($add_length) && count($add_length) > 0) {
         foreach ($add_length as $l) {
             $paid = $class_pa->add($products_id, 0, 0, array('length' => $l), true);
             $class_ean->attactToArticle($paid);
         }
     }
 }