Jump to content
ecartz

Import/Export Module System 1.0 Support

Recommended Posts

Problem

 

i have installed everything according to the readme file, and run also the SQL file

 

i can see the import and export links

but there is no link for

 

Admin -> Catalog -> Easy Populate <- missing

 

also how do i export something out of it

 

Anton

Share this post


Link to post
Share on other sites

Great start at rationalizing the easypopulate file handing!

 

Instructions file could definitely use some work though.

Share this post


Link to post
Share on other sites

:( I have upload and followed all instruction and am having serveral problems:

 

1. Cannot see export options on export.php. Can see import options.

2. Cannot export anything due to this error = Fatal error: Call to a member function on a non-object /home/wwwaccu/public_html/admin/includes/classes/file_layout.php on line 53 these are the contents of the downloaded file using netscape. IE just gives an error saying the file cannot be found.

 

So PLEASE help!!!


"There is no disgrace in not knowing, the only disgrace is not to be willing to learn." ...Benjamin Franklin

Share this post


Link to post
Share on other sites

I have solved the problem with seeing the links on the export page. However I am not able to upload or download a file. The file is uploaded to the temp directory but the contents are never read.


"There is no disgrace in not knowing, the only disgrace is not to be willing to learn." ...Benjamin Franklin

Share this post


Link to post
Share on other sites

The install is missing

And edit file admin/includes/boxes/modules.php by adding this line:

                                  '<a href="' . tep_href_link(FILENAME_MODULES, 'set=file_layouts', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_FILE_LAYOUTS . '</a><br>' .

After:  

                                  '<a href="' . tep_href_link(FILENAME_MODULES, 'set=shipping', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_SHIPPING . '</a><br>' .

Then the modules need to be installed.

 

Hth,

Matt


Always back up before making changes.

Share this post


Link to post
Share on other sites

Hi All

 

Total Newbie, but researching as fast as I can :)

 

Will the Imp/Exp module work for orders?

 

I'm trying to find a way to imp/exp order data as tab-delimited spreadsheets.

 

Thanks very much :)

Share this post


Link to post
Share on other sites
Will the Imp/Exp module work for orders?
No, not yet. Right now, it just does what Easy Populate does. Someone would have to write an additional module to include orders. There is a contribution for orders somewhere though. I think that it is about a month old.

 

Hth,

Matt


Always back up before making changes.

Share this post


Link to post
Share on other sites

That was the problem it works like a charm now! Thank you!

 

The install is missing

CODE 

And edit file admin/includes/boxes/modules.php by adding this line:

 

                                  '<a href="' . tep_href_link(FILENAME_MODULES, 'set=file_layouts', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_FILE_LAYOUTS . '</a><br>' .

 

After: 

 

                                  '<a href="' . tep_href_link(FILENAME_MODULES, 'set=shipping', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_SHIPPING . '</a><br>' .

 

Then the modules need to be installed.

 

Hth,

Matt

:)

"There is no disgrace in not knowing, the only disgrace is not to be willing to learn." ...Benjamin Franklin

Share this post


Link to post
Share on other sites

Hi, I was wandering if someone can help. I am new to PHP, but can 'read' it. I am running an 2.2 OSC shop and have installed this contrib.

 

However, when I try to download a file all it contains are error messages.

 

One error message is:

<br />

<b>Warning</b>: implode(): Bad arguments. in <b>/mydomain.com/admin/includes/modules/file_layouts/full.php</b> on line <b>142</b><br />

 

but, most of them are repeats of the below

<b>Warning</b>: Invalid argument supplied for foreach() in <b>/mydomain.com/admin/includes/modules/file_layouts/full.php</b> on line <b>274</b><br />

 

Just to avoid confusion, I overtyped the error message with mydomain.com.

 

One thing to note is that my hosting company recently turned off global variables setting in php.ini. They will not turn it back on for security reasons. I, therefore installed the Register Globals contrib and got the site working again. I was wandering if this was the prob here.

I have noticed on the lines it refers to that they use global variable names instead of using the get method:

variables and access them via their global names rather than via the $_GET (or $HTTP_GET_VARS).

However, I don't know enough about PHP to rewrite this. Can anyone confirm that this is the prob and if so give me some tips on how to re-write this contrib?

 

vv

Share this post


Link to post
Share on other sites

I am having the same error in my downloaded file and I have registered globals on and I have the correct file permissions and I have created the catalog/temp folder just to make sure that none of that was the problem ....

 

my error (repeaded over and over again)

 

<b>Warning</b>: Invalid argument supplied for foreach() in <b>/home/mysite/public_html/admin/includes/modules/file_layouts/full.php</b> on line <b>274</b><br />


"There is no disgrace in not knowing, the only disgrace is not to be willing to learn." ...Benjamin Franklin

Share this post


Link to post
Share on other sites

Hope, well I suppose it's a relief that isn't the problem, but sadly still leaves this contrib not working. Let me know if you find a solution to this one.

 

Matt, any response/suggestions?

 

The first error message is located in:

echo implode($separator, $filelayout) . $this->endofrow;

The repeating ones are located in:

foreach( $filelayout as $key => $value ){

 

Any help would be greatly appreciated.

 

Anton

Share this post


Link to post
Share on other sites

It would appear that $filelayout is empty.. none of the downloads work except the Download Model/Category tab-delimited .txt file to edit that partially works. It has no headers but does have the model number appear, which is better than nothing. Any ideas? Any one?

Share this post


Link to post
Share on other sites

Anton, I am still sitting here with a non working contrib, wonder if anybody out there has any ideas at allllllll! :(

Edited by carolinagirl

"There is no disgrace in not knowing, the only disgrace is not to be willing to learn." ...Benjamin Franklin

Share this post


Link to post
Share on other sites

I went back and reviewed the manual once more and tried the download to tmp directory option and the "full" export text file was empty and the category text file containted only

 

0EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

EOREOR

 

I do have products in the database and categories.


"There is no disgrace in not knowing, the only disgrace is not to be willing to learn." ...Benjamin Franklin

Share this post


Link to post
Share on other sites

I uploaded a new copy of the contribution that might resolve people's problems. At least the files worked for me.

 

Updating should only require copying the files over. The ones that changed are

 

admin/export.php

admin/includes/ie_configure.php

admin/includes/file_layouts/category.php

admin/includes/file_layouts/froogle.php

admin/includes/file_layouts/full.php

admin/includes/file_layouts/priceqty.php

 

Cheers,

Matt


Always back up before making changes.

Share this post


Link to post
Share on other sites

Ok, I was able to install the contrib and all and got my file exported and edited and imported to the temp dir, but when i choose that file and hit the "Insert into DB" button, nothing seems to appear in my catalog section.

 

Any ideas?

Share this post


Link to post
Share on other sites

Add

//elari check default language_id from configuration table DEFAULT_LANGUAGE
 $epdlanguage_query = tep_db_query("select languages_id, name from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_LANGUAGE . "'");
 if (tep_db_num_rows($epdlanguage_query)) {
   $epdlanguage = tep_db_fetch_array($epdlanguage_query);
   $epdlanguage_id   = $epdlanguage['languages_id'];
   $epdlanguage_name = $epdlanguage['name'];
 } else {
   echo 'Strange but there is no default language to work... That may not happen, just in case... ';
 }

 $langcode = ep_get_languages();

to the walk function of admin/includes/functions/easypopulate.php around line 64.

 

Around line 34 change

    if ($HTTP_POST_VARS['split'] == '1') {

to

    if ($HTTP_GET_VARS['split'] == '1') {

 

84 of admin/import.php change

} elseif ($HTTP_POST_VARS['split'] == '0') {

to

} elseif (($HTTP_GET_VARS['split'] == '0') || isset($HTTP_POST_VARS['localfile'])) {

Hth,

Matt


Always back up before making changes.

Share this post


Link to post
Share on other sites

Ok, I got the first code in, but I could not find the coding to replace in any of the documents.

 

The Docs look like this:

 

admin/includes/functions/easypopulate.php

 

<?php

/* Export module brought to you buy

ukrainianshop.net

 

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

  Copyright © 2002-4 osCommerce

  Copyright © 2002-3 Tim Wasson

  Copyright © 2004 eCartz.com, Inc.

 

  Released under the GNU General Public License

*/

 

 

function ep_get_languages() {

  $languages_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " order by sort_order");

  // start array at one, the rest of the code expects it that way

  $ll =1;

  while ($ep_languages = tep_db_fetch_array($languages_query)) {

    //will be used to return language_id en language code to report in product_name_code instead of product_name_id

    $ep_languages_array[$ll++] = array(

          'id' => $ep_languages['languages_id'],

          'code' => $ep_languages['code']

          );

  }

  return $ep_languages_array;

};

 

function tep_get_tax_class_rate($tax_class_id) {

  $tax_multiplier = 0;

  $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " WHERE  tax_class_id = '" . $tax_class_id . "' GROUP BY tax_priority");

  if (tep_db_num_rows($tax_query)) {

    while ($tax = tep_db_fetch_array($tax_query)) {

      $tax_multiplier += $tax['tax_rate'];

    }

  }

  return $tax_multiplier;

};

 

function tep_get_tax_title_class_id($tax_class_title) {

  $classes_query = tep_db_query("select tax_class_id from " . TABLE_TAX_CLASS . " WHERE tax_class_title = '" . $tax_class_title . "'" );

  $tax_class_array = tep_db_fetch_array($classes_query);

  $tax_class_id = $tax_class_array['tax_class_id'];

  return $tax_class_id ;

}

 

function print_el( $item2 ) {

  echo " | " . substr(strip_tags($item2), 0, 10);

}

 

function print_el1( $item2 ) {

  echo sprintf("| %'.4s ", substr(strip_tags($item2), 0, 80));

}

 

function walk( $item1 ) {

  global $filelayout, $filelayout_count, $modelsize;

  global $active, $inactive, $langcode, $default_these, $deleteit, $zero_qty_inactive;

  global $epdlanguage_id, $price_with_tax, $replace_quotes;

  global $default_images, $default_image_manufacturer, $default_image_product, $default_image_category;

  global $separator, $max_categories;

// first we clean up the row of data

//elari check default language_id from configuration table DEFAULT_LANGUAGE

$epdlanguage_query = tep_db_query("select languages_id, name from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_LANGUAGE . "'");

if (tep_db_num_rows($epdlanguage_query)) {

  $epdlanguage = tep_db_fetch_array($epdlanguage_query);

  $epdlanguage_id  = $epdlanguage['languages_id'];

  $epdlanguage_name = $epdlanguage['name'];

} else {

  echo 'Strange but there is no default language to work... That may not happen, just in case... ';

}

 

$langcode = ep_get_languages();

  // chop blanks from each end

  $item1 = ltrim(rtrim($item1));

 

  // blow it into an array, splitting on the tabs

  $items = explode($separator, $item1);

 

  // make sure all non-set things are set to '';

  // and strip the quotes from the start and end of the stings.

  // escape any special chars for the database.

  foreach( $filelayout as $key=> $value){

    $i = $filelayout[$key];

    if (isset($items[$i]) == false) {

      $items[$i]='';

    } else {

      // Check to see if either of the magic_quotes are turned on or off;

      // And apply filtering accordingly.

      if (function_exists('ini_get')) {

        //echo "Getting ready to check magic quotes<br>";

        if (ini_get('magic_quotes_runtime') == 1){

          // The magic_quotes_runtime are on, so lets account for them

          // check if the last character is a quote;

          // if it is, chop off the quotes.

          if (substr($items[$i],-1) == '"'){

            $items[$i] = substr($items[$i],2,strlen($items[$i])-4);

          }

          // now any remaining doubled double quotes should be converted to one doublequote

          $items[$i] = str_replace('\"\"',""",$items[$i]);

          if ($replace_quotes){

            $items[$i] = str_replace('\"',""",$items[$i]);

            $items[$i] = str_replace("\'","'",$items[$i]);

          }

        } else { // no magic_quotes are on

          // check if the last character is a quote;

          // if it is, chop off the 1st and last character of the string.

          if (substr($items[$i],-1) == '"'){

            $items[$i] = substr($items[$i],1,strlen($items[$i])-2);

          }

          // now any remaining doubled double quotes should be converted to one doublequote

          $items[$i] = str_replace('""',""",$items[$i]);

          if ($replace_quotes){

            $items[$i] = str_replace('"',""",$items[$i]);

            $items[$i] = str_replace("'","'",$items[$i]);

          }

        }

      }

    }

  }

/*

  if ( $items['v_status'] == $deleteit ){

    // they want to delete this product.

    echo "Deleting product " . $items['v_products_model'] . " from the database<br>";

    // Get the ID

 

    // kill in the products_to_categories

 

    // Kill in the products table

 

    return; // we're done deleteing!

  }

*/

  // now do a query to get the record's current contents

  $sql = "SELECT

    p.products_id as v_products_id,

    p.products_model as v_products_model,

    p.products_image as v_products_image,

    p.products_price as v_products_price,

    p.products_weight as v_products_weight,

    p.products_date_added as v_date_avail,

    p.products_tax_class_id as v_tax_class_id,

    p.products_quantity as v_products_quantity,

    p.manufacturers_id as v_manufacturers_id,

    c.categories_id as v_categories_id

    FROM

    ".TABLE_PRODUCTS." as p,

    ".TABLE_CATEGORIES." as c,

    ".TABLE_PRODUCTS_TO_CATEGORIES." as p2c

    WHERE

    p.products_id = p2c.products_id AND

    p.products_model = '" . $items[$filelayout['v_products_model']] . "' AND

    p2c.categories_id = c.categories_id

    ";

 

  $result = tep_db_query($sql);

  $row =  tep_db_fetch_array($result);

 

 

  while ($row){

    // OK, since we got a row, the item already exists.

    // Let's get all the data we need and fill in all the fields that need to be defaulted to the current values

    // for each language, get the description and set the vals

    foreach ($langcode as $key => $lang){

      //echo "Inside defaulting loop";

      //echo "key is $key<br>";

      //echo "langid is " . $lang['id'] . "<br>";

//      $sql2 = "SELECT products_name, products_description

//        FROM ".TABLE_PRODUCTS_DESCRIPTION."

//        WHERE

//          products_id = " . $row['v_products_id'] . " AND

//          language_id = '" . $lang['id'] . "'

//        ";

      $sql2 = "SELECT *

        FROM ".TABLE_PRODUCTS_DESCRIPTION."

        WHERE

          products_id = " . $row['v_products_id'] . " AND

          language_id = '" . $lang['id'] . "'

        ";

      $result2 = tep_db_query($sql2);

      $row2 =  tep_db_fetch_array($result2);

                        // Need to report from ......_name_1 not ..._name_0

      $row['v_products_name_' . $lang['id']]    = $row2['products_name'];

      $row['v_products_description_' . $lang['id']]  = $row2['products_description'];

      $row['v_products_url_' . $lang['id']]    = $row2['products_url'];

 

      // support for Linda's Header Controller 2.0 here

      if(isset($filelayout['v_products_head_title_tag_' . $lang['id'] ])){

        $row['v_products_head_title_tag_' . $lang['id']]  = $row2['products_head_title_tag'];

        $row['v_products_head_desc_tag_' . $lang['id']]  = $row2['products_head_desc_tag'];

        $row['v_products_head_keywords_tag_' . $lang['id']]  = $row2['products_head_keywords_tag'];

      }

      // end support for Header Controller 2.0

    }

 

    // start with v_categories_id

    // Get the category description

    // set the appropriate variable name

    // if parent_id is not null, then follow it up.

    $thecategory_id = $row['v_categories_id'];

 

    for( $categorylevel=1; $categorylevel<$max_categories+1; $categorylevel++){

      if ($thecategory_id){

        $sql2 = "SELECT categories_name

          FROM ".TABLE_CATEGORIES_DESCRIPTION."

          WHERE

            categories_id = " . $thecategory_id . " AND

            language_id = " . $epdlanguage_id ;

 

        $result2 = tep_db_query($sql2);

        $row2 =  tep_db_fetch_array($result2);

        // only set it if we found something

        $temprow['v_categories_name_' . $categorylevel] = $row2['categories_name'];

        // now get the parent ID if there was one

        $sql3 = "SELECT parent_id

          FROM ".TABLE_CATEGORIES."

          WHERE

            categories_id = " . $thecategory_id;

        $result3 = tep_db_query($sql3);

        $row3 =  tep_db_fetch_array($result3);

        $theparent_id = $row3['parent_id'];

        if ($theparent_id != ''){

          // there was a parent ID, lets set thecategoryid to get the next level

          $thecategory_id = $theparent_id;

        } else {

          // we have found the top level category for this item,

          $thecategory_id = false;

        }

      } else {

          $temprow['v_categories_name_' . $categorylevel] = '';

      }

    }

    // temprow has the old style low to high level categories.

    $newlevel = 1;

    // let's turn them into high to low level categories

    for( $categorylevel=$max_categories+1; $categorylevel>0; $categorylevel--){

      if ($temprow['v_categories_name_' . $categorylevel] != ''){

        $row['v_categories_name_' . $newlevel++] = $temprow['v_categories_name_' . $categorylevel];

      }

    }

 

    if ($row['v_manufacturers_id'] != ''){

      $sql2 = "SELECT manufacturers_name

        FROM ".TABLE_MANUFACTURERS."

        WHERE

        manufacturers_id = " . $row['v_manufacturers_id']

        ;

      $result2 = tep_db_query($sql2);

      $row2 =  tep_db_fetch_array($result2);

      $row['v_manufacturers_name'] = $row2['manufacturers_name'];

    }

 

    //elari -

    //We check the value of tax class and title instead of the id

    //Then we add the tax to price if $price_with_tax is set to true

    $row_tax_multiplier = tep_get_tax_class_rate($row['v_tax_class_id']);

    $row['v_tax_class_title'] = tep_get_tax_class_title($row['v_tax_class_id']);

    if ($price_with_tax){

      $row['v_products_price'] = $row['v_products_price'] + round($row['v_products_price']* $row_tax_multiplier / 100,2);

    }

 

    // now create the internal variables that will be used

    // the $$thisvar is on purpose: it creates a variable named what ever was in $thisvar and sets the value

    foreach ($default_these as $thisvar){

      $$thisvar  = $row[$thisvar];

    }

 

    $row =  tep_db_fetch_array($result);

  }

 

// this is an important loop.  What it does is go thru all the fields in the incoming file and set the internal vars.

// Internal vars not set here are either set in the loop above for existing records, or not set at all (null values)

// the array values are handled separatly, although they will set variables in this loop, we won't use them.

  foreach( $filelayout as $key => $value ){

    $$key = $items[ $value ];

  }

 

// so how to handle these?  we shouldn't built the array unless it's been giving to us.

// The assumption is that if you give us names and descriptions, then you give us name and description for all applicable languages

  foreach ($langcode as $lang){

//echo "Langid is " . $lang['id'] . "<br>";

    $l_id = $lang['id'];

    if (isset($filelayout['v_products_name_' . $l_id ])){

//we set dynamically the language values

      $v_products_name[$l_id]  = $items[$filelayout['v_products_name_' . $l_id]];

      $v_products_description[$l_id]  = $items[$filelayout['v_products_description_' . $l_id ]];

      $v_products_url[$l_id]    = $items[$filelayout['v_products_url_' . $l_id ]];

// support for Linda's Header Controller 2.0 here

      if(isset($filelayout['v_products_head_title_tag_' . $l_id])){

        $v_products_head_title_tag[$l_id]  = $items[$filelayout['v_products_head_title_tag_' . $l_id]];

        $v_products_head_desc_tag[$l_id]  = $items[$filelayout['v_products_head_desc_tag_' . $l_id]];

        $v_products_head_keywords_tag[$l_id]  = $items[$filelayout['v_products_head_keywords_tag_' . $l_id]];

      }

// end support for Header Controller 2.0

    }

  }

//elari... we get the tax_clas_id from the tax_title

//on screen will still be displayed the tax_class_title instead of the id....

  if ( isset( $v_tax_class_title) ){

    $v_tax_class_id          = tep_get_tax_title_class_id($v_tax_class_title);

  }

//we check the tax rate of this tax_class_id

  $row_tax_multiplier = tep_get_tax_class_rate($v_tax_class_id);

 

//And we recalculate price without the included tax...

//Since it seems display is made before, the displayed price will still include tax

//This is same problem for the tax_clas_id that display tax_class_title

  if ($price_with_tax){

    $v_products_price        = round( $v_products_price / (1 + ( $row_tax_multiplier * $price_with_tax/100) ), 2);

  }

 

// if they give us one category, they give us all 6 categories

  unset ($v_categories_name); // default to not set.

  if ( isset( $filelayout['v_categories_name_1'] ) ){

    $newlevel = 1;

    for( $categorylevel=6; $categorylevel>0; $categorylevel--){

      if ( $items[$filelayout['v_categories_name_' . $categorylevel]] != ''){

        $v_categories_name[$newlevel++] = $items[$filelayout['v_categories_name_' . $categorylevel]];

      }

    }

    while( $newlevel < $max_categories+1){

      $v_categories_name[$newlevel++] = ''; // default the remaining items to nothing

    }

  }

 

  if (ltrim(rtrim($v_products_quantity)) == '') {

    $v_products_quantity = 1;

  }

  if ($v_date_avail == '') {

    $v_date_avail = "CURRENT_TIMESTAMP";

  } else {

// we put the quotes around it here because we can't put them into the query, because sometimes

//  we will use the "current_timestamp", which can't have quotes around it.

    $v_date_avail = '"' . $v_date_avail . '"';

  }

 

  if ($v_date_added == '') {

    $v_date_added = "CURRENT_TIMESTAMP";

  } else {

// we put the quotes around it here because we can't put them into the query, because sometimes

// we will use the "current_timestamp", which can't have quotes around it.

    $v_date_added = '"' . $v_date_added . '"';

  }

 

 

// default the stock if they spec'd it or if it's blank

  $v_db_status = '1'; // default to active

  if ($v_status == $inactive){

// they told us to deactivate this item

    $v_db_status = '0';

  }

  if ($zero_qty_inactive && $v_products_quantity == 0) {

// if they said that zero qty products should be deactivated, let's deactivate if the qty is zero

    $v_db_status = '0';

  }

 

  if ($v_manufacturer_id==''){

    $v_manufacturer_id="NULL";

  }

 

  if (trim($v_products_image)==''){

    $v_products_image = $default_image_product;

  }

 

  if (strlen($v_products_model) > $modelsize ){

    echo "<font color='red'>" . strlen($v_products_model) . $v_products_model . "... ERROR! - Too many characters in the model number.<br>

      12 is the maximum on a standard OSC install.<br>

      Your maximum product_model length is set to $modelsize<br>

      You can either shorten your model numbers or increase the size of the field in the database.</font>";

    die();

  }

 

// OK, we need to convert the manufacturer's name into id's for the database

  if ( isset($v_manufacturers_name) && $v_manufacturers_name != '' ){

    $sql = "SELECT man.manufacturers_id

      FROM ".TABLE_MANUFACTURERS." as man

      WHERE

        man.manufacturers_name = '" . $v_manufacturers_name . "'";

    $result = tep_db_query($sql);

    $row =  tep_db_fetch_array($result);

    if ( $row != '' ){

      foreach( $row as $item ){

        $v_manufacturer_id = $item;

      }

    } else {

// to add, we need to put stuff in categories and categories_description

      $sql = "SELECT MAX( manufacturers_id) max FROM ".TABLE_MANUFACTURERS;

      $result = tep_db_query($sql);

      $row =  tep_db_fetch_array($result);

      $max_mfg_id = $row['max']+1;

// default the id if there are no manufacturers yet

      if (!is_numeric($max_mfg_id) ){

        $max_mfg_id=1;

      }

 

// Comment this query out if you have an older 2.2 codebase

      $sql = "INSERT INTO ".TABLE_MANUFACTURERS."(

                manufacturers_id,

                manufacturers_name,

                manufacturers_image,

                date_added,

                last_modified

              ) VALUES (

                $max_mfg_id,

                '$v_manufacturers_name',

                '$default_image_manufacturer',

                CURRENT_TIMESTAMP,

                CURRENT_TIMESTAMP

              )";

      $result = tep_db_query($sql);

      $v_manufacturer_id = $max_mfg_id;

    }

  }

  // if the categories names are set then try to update them

  if ( isset($v_categories_name_1)){

    // start from the highest possible category and work our way down from the parent

    $v_categories_id = 0;

    $theparent_id = 0;

    for ( $categorylevel=$max_categories+1; $categorylevel>0; $categorylevel-- ){

      $thiscategoryname = $v_categories_name[$categorylevel];

      if ( $thiscategoryname != ''){

        // we found a category name in this field

 

        // now the subcategory

        $sql = "SELECT c.categories_id

                FROM

                ".TABLE_CATEGORIES." as c,

                ".TABLE_CATEGORIES_DESCRIPTION." as cd

                WHERE

                  c.categories_id = cd.categories_id AND

                  cd.language_id = $epdlanguage_id AND

                  c.parent_id = " . $theparent_id . " AND

                  cd.categories_name = '" . $thiscategoryname . "'";

        $result = tep_db_query($sql);

        $row =  tep_db_fetch_array($result);

        if ( $row != '' ){

          foreach( $row as $item ){

            $thiscategoryid = $item;

          }

        } else {

          // to add, we need to put stuff in categories and categories_description

          $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES;

          $result = tep_db_query($sql);

          $row =  tep_db_fetch_array($result);

          $max_category_id = $row['max']+1;

          if (!is_numeric($max_category_id) ){

            $max_category_id=1;

          }

          $sql = "INSERT INTO ".TABLE_CATEGORIES."(

                    categories_id,

                    categories_image,

                    parent_id,

                    sort_order,

                    date_added,

                    last_modified

                  ) VALUES (

                    $max_category_id,

                    '$default_image_category',

                    $theparent_id,

                    0,

                    CURRENT_TIMESTAMP,

                    CURRENT_TIMESTAMP

                  )";

          $result = tep_db_query($sql);

          $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION."(

                    categories_id,

                    language_id,

                    categories_name

                  ) VALUES (

                    $max_category_id,

                    '$epdlanguage_id',

                    '$thiscategoryname'

                  )";

          $result = tep_db_query($sql);

          $thiscategoryid = $max_category_id;

        }

        // the current catid is the next level's parent

        $theparent_id = $thiscategoryid;

        $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later

      }

    }

  }

 

  if ($v_products_model != "") {

    //  products_model exists!

    array_walk($items, 'print_el');

 

    // First we check to see if this is a product in the current db.

    $result = tep_db_query("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE (products_model = '". $v_products_model . "')");

 

    if (tep_db_num_rows($result) == 0)  {

      //  insert into products

 

      $sql = "SELECT MAX( products_id) max FROM ".TABLE_PRODUCTS;

      $result = tep_db_query($sql);

      $row =  tep_db_fetch_array($result);

      $max_product_id = $row['max']+1;

      if (!is_numeric($max_product_id) ){

        $max_product_id=1;

      }

      $v_products_id = $max_product_id;

      echo "<font color='green'> !New Product!</font><br>";

 

      $query = "INSERT INTO ".TABLE_PRODUCTS." (

                  products_image,

                  products_model,

                  products_price,

                  products_status,

                  products_last_modified,

                  products_date_added,

                  products_date_available,

                  products_tax_class_id,

                  products_weight,

                  products_quantity,

                  manufacturers_id

                ) VALUES (

                  '$v_products_image',

                  '$v_products_model',

                  '$v_products_price',

                  '$v_db_status',

                  CURRENT_TIMESTAMP,

                  $v_date_added,

                  $v_date_avail,

                  '$v_tax_class_id',

                  '$v_products_weight',

                  '$v_products_quantity',

                  '$v_manufacturer_id'

                )";

        $result = tep_db_query($query);

    } else {

      // existing product, get the id from the query

      // and update the product data

      $row =  tep_db_fetch_array($result);

      $v_products_id = $row['products_id'];

      echo "<font color='black'> Updated</font><br>";

      $row =  tep_db_fetch_array($result);

      $query = 'UPDATE '.TABLE_PRODUCTS.'

                SET

                  products_price="'.$v_products_price .

              '" ,products_image="'.$v_products_image .

              '", products_weight="'.$v_products_weight .

              '", products_tax_class_id="'.$v_tax_class_id .

              '", products_date_available= ' . $v_date_avail .

              ', products_date_added= ' . $v_date_added .

              ', products_last_modified=CURRENT_TIMESTAMP

              , products_quantity="' . $v_products_quantity . 

              '" ,manufacturers_id=' . $v_manufacturer_id .

              ' , products_status=' . $v_db_status . '

              WHERE

                (products_id = "'. $v_products_id . '")';

 

      $result = tep_db_query($query);

    }

 

// the following is common in both the updating an existing product and creating a new product

    if ( isset($v_products_name)){

      foreach( $v_products_name as $key => $name){

              if ($name!=''){

          $sql = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE

                    products_id = $v_products_id AND

                    language_id = " . $key;

          $result = tep_db_query($sql);

          if (tep_db_num_rows($result) == 0) {

// this is a new product description

            $result = tep_db_query($sql);

            $sql =

              "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."

                (products_id,

                language_id,

                products_name,

                products_description,

                products_url)

                VALUES (

                  '" . $v_products_id . "',

                  " . $key . ",

                  '" . $name . "',

                  '". $v_products_description[$key] . "',

                  '". $v_products_url[$key] . "'

                  )";

            // support for Linda's Header Controller 2.0

            if (isset($v_products_head_title_tag)){

              // override the sql if we're using Linda's contrib

              $sql =

                "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION."

                  (products_id,

                  language_id,

                  products_name,

                  products_description,

                  products_url,

                  products_head_title_tag,

                  products_head_desc_tag,

                  products_head_keywords_tag)

                  VALUES (

                    '" . $v_products_id . "',

                    " . $key . ",

                    '" . $name . "',

                    '". $v_products_description[$key] . "',

                    '". $v_products_url[$key] . "',

                    '". $v_products_head_title_tag[$key] . "',

                    '". $v_products_head_desc_tag[$key] . "',

                    '". $v_products_head_keywords_tag[$key] . "')";

            }

            // end support for Linda's Header Controller 2.0

            $result = tep_db_query($sql);

          } else {

            // already in the description, let's just update it

            $sql =

              "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET

                products_name='$name',

                products_description='".$v_products_description[$key] . "',

                products_url='" . $v_products_url[$key] . "'

              WHERE

                products_id = '$v_products_id' AND

                language_id = '$key'";

            // support for Lindas Header Controller 2.0

            if (isset($v_products_head_title_tag)){

              // override the sql if we're using Linda's contrib

              $sql =

                "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET

                  products_name = '$name',

                  products_description = '".$v_products_description[$key] . "',

                  products_url = '" . $v_products_url[$key] ."',

                  products_head_title_tag = '" . $v_products_head_title_tag[$key] ."',

                  products_head_desc_tag = '" . $v_products_head_desc_tag[$key] ."',

                  products_head_keywords_tag = '" . $v_products_head_keywords_tag[$key] ."'

                WHERE

                  products_id = '$v_products_id' AND

                  language_id = '$key'";

            }

            // end support for Linda's Header Controller 2.0

            $result = tep_db_query($sql);

          }

        }

      }

    }

    if (isset($v_categories_id)){

      //find out if this product is listed in the category given

      $result_incategory = tep_db_query('SELECT

            '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id,

            '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id

            FROM

              '.TABLE_PRODUCTS_TO_CATEGORIES.'

            WHERE

            '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id='.$v_products_id.' AND

            '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id='.$v_categories_id);

 

      if (tep_db_num_rows($result_incategory) == 0) {

        // nope, this is a new category for this product

        $res1 = tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id)

              VALUES ("' . $v_products_id . '", "' . $v_categories_id . '")');

      } else {

        // already in this category, nothing to do!

      }

    }

    // for the separate prices per customer module

    $ll=1;

 

    if (isset($v_customer_price_1)){

     

      if (($v_customer_group_id_1 == '') AND ($v_customer_price_1 != ''))  {

        echo "<font color=red>ERROR - v_customer_group_id and v_customer_price must occur in pairs</font>";

        die();

      }

      // they spec'd some prices, so clear all existing entries

      $result = tep_db_query('

            DELETE

            FROM

              '.TABLE_PRODUCTS_GROUPS.'

            WHERE

              products_id = ' . $v_products_id

            );

      // and insert the new record

      if ($v_customer_price_1 != ''){

        $result = tep_db_query('

              INSERT INTO

                '.TABLE_PRODUCTS_GROUPS.'

              VALUES

              (

                ' . $v_customer_group_id_1 . ',

                ' . $v_customer_price_1 . ',

                ' . $v_products_id . ',

                ' . $v_products_price .'

                )'

              );

      }

      if ($v_customer_price_2 != ''){

        $result = tep_db_query('

              INSERT INTO

                '.TABLE_PRODUCTS_GROUPS.'

              VALUES

              (

                ' . $v_customer_group_id_2 . ',

                ' . $v_customer_price_2 . ',

                ' . $v_products_id . ',

                ' . $v_products_price . '

                )'

              );

      }

      if ($v_customer_price_3 != ''){

        $result = tep_db_query('

              INSERT INTO

                '.TABLE_PRODUCTS_GROUPS.'

              VALUES

              (

                ' . $v_customer_group_id_3 . ',

                ' . $v_customer_price_3 . ',

                ' . $v_products_id . ',

                ' . $v_products_price . '

                )'

              );

      }

      if ($v_customer_price_4 != ''){

        $result = tep_db_query('

              INSERT INTO

                '.TABLE_PRODUCTS_GROUPS.'

              VALUES

              (

                ' . $v_customer_group_id_4 . ',

                ' . $v_customer_price_4 . ',

                ' . $v_products_id . ',

                ' . $v_products_price . '

                )'

              );

      }

 

    }

 

  } else {

    // this record was missing the products_model

    array_walk($items, 'print_el');

    echo "<p class=smallText>No products_model field in record. This line was not imported <br>";

    echo "<br>";

  }

// end of row insertion code

}

?>

 

and

 

admin/import.php

 

<?php

/*

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

 

  Copyright © 2002-4 osCommerce

  Copyright © 2002-3 Tim Wasson

  Copyright © 2004 eCartz.com, Inc.

 

  Released under the GNU General Public License

*/

 

  require('includes/application_top.php');

  require(DIR_WS_FUNCTIONS . 'easypopulate.php');

  require(DIR_WS_INCLUDES . 'ie_configure.php');

  require(DIR_WS_MODULES . 'ie_formats/' . FILENAME_IMPORT);

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<table border="0" width="100%" cellspacing="2" cellpadding="2">

  <tr>

    <td width="<?php echo BOX_WIDTH; ?>" valign="top" height="27">

      <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<?php require(DIR_WS_INCLUDES . 'column_left.php');?>

      </table>

    </td>

    <td class="pageHeading" valign="top">

<?php

  echo sprintf(TEXT_CURRENT_VERSION, $curver) . ' - ' . sprintf(TEXT_DEFAULT_LANGUAGE, $epdlanguage_name, $epdlanguage_id);

?>

      <p class="smallText">

<?php

  if ((isset($HTTP_POST_VARS['localfile']) and ($HTTP_POST_VARS['localfile'] == 'true')) or (isset($HTTP_POST_VARS['uploadandinsert']) and ($HTTP_POST_VARS['uploadandinsert'] == 'true') && $split==0)) {

    if (file_exists(DIR_FS_DOCUMENT_ROOT . $tempdir . $ep_file)){

?>

        <?php echo TEXT_FILENAME . $ep_file; ?><br>

      </p>

      <p class=smallText>

<?php

    }

 

    if ($file_uploaded == 'success') {

?>

        <?php echo TEXT_FILE_UPLOADED; ?><br>

        <?php echo TEXT_TEMPORARY_FILENAME . $usrfl; ?><br>

        <?php echo TEXT_SIZE . $usrfl_size; ?><br>

<?php

    } elseif ($file_uploaded == 'failure') {

      echo TEXT_NO_FILE_UPLOADED;

    }

  }

?>

      </p>

      <table width="75%" border="2">

        <tr>

          <td width="75%">

            <?php echo tep_draw_form('no_split_upload_insert', FILENAME_IMPORT, 'split=0', 'post', 'ENCTYPE="multipart/form-data"'); ?>

              <div align = "left">

                <p><b><?php echo TEXT_UPLOAD_FILE; ?></b></p>

                <p>

                  <?php echo tep_draw_hidden_field('MAX_FILE_SIZE', '100000000'); ?>

                  <?php echo tep_draw_hidden_field('uploadandinsert', 'true'); ?>

                </p>

                <p>

                  <?php echo tep_draw_file_field('usrfl'); ?>

                  <input type="submit" name="buttoninsert" value="<?php echo TEXT_INSERT_INTO_DB; ?>"><br>

                </p>

              </div>

            </form>

 

            <?php echo tep_draw_form('split_upload', FILENAME_IMPORT, 'split=1', 'post', 'ENCTYPE="multipart/form-data"'); ?>

              <p>

                <div align = "left">

                  <p><b><?php echo TEXT_SPLIT_FILE; ?></b></p>

                  <p>

                    <?php echo tep_draw_hidden_field('MAX_FILE_SIZE', '1000000000'); ?>

                  </p>

                  <p>

                    <?php echo tep_draw_file_field('usrfl'); ?>

                    <input type="submit" name="buttonsplit" value="<?php echo TEXT_SPLIT_FILE; ?>"><br>

                  </p>

                </div>

              </p>

            </form>

 

            <?php echo tep_draw_form('localfile_insert', FILENAME_IMPORT, '', 'post', 'ENCTYPE="multipart/form-data"'); ?>

              <p>

                <div align = "left">

                  <p><b><? echo sprintf(TEXT_IMPORT_TEMP, $tempdir); ?></b></p>

                  <p class="smallText">

<?php

    $dir = dir(DIR_FS_CATALOG . $tempdir);

    $contents = array(array('id' => '', 'text' => TEXT_SELECT_ONE));

    while ($file = $dir->read()) {

      if ( ($file != '.') && ($file != 'CVS') && ($file != '..') ) {

        //$file_size = filesize(DIR_FS_CATALOG . $tempdir . $file);

 

        $contents[] = array('id' => $file, 'text' => $file);

      }

    }

    echo tep_draw_pull_down_menu('localfile', $contents, $localfile);

?>

                    <input type="submit" name="buttoninsert" value="<?php echo TEXT_INSERT_INTO_DB; ?>"><br>

                  </p>

                </div>

              </p>

            </form>

          </td>

        </tr>

      </table>

    </td>

  </tr>

</table>

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<p><br></p>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

Thanks for your help Matt

Share this post


Link to post
Share on other sites

I have EP and the IM-EXPORT contrib loaded on my test cart trying to evaluate...when I click the import link in the I get these two error messages:

 

Warning: dir(/home/dcgtest2/public_html/catalog/IMPORT_EXPORT_TEMP_DIR): failed to open dir: No such file or directory in /home/dcgtest2/public_html/catalog/admin/import.php on line 99

 

I have the temp directory set properly with the corect CHMOD (777)

 

Line 99 in import.php:

 

$dir = dir(DIR_FS_CATALOG . $tempdir);

 

Second error is :

 

Fatal error: Call to a member function on a non-object in /home/dcgtest2/public_html/catalog/admin/import.php on line 101

 

Line 101:

 

while ($file = $dir->read()) {

 

TIA! :blink:


Learning is not attained by chance, it must be sought for with ardor and attended to with diligence.

Share this post


Link to post
Share on other sites

Double check your installation. Looks like you didn't install and english file, or you don't have all the entries in place. Alternatively, a misplaced piece of punctuation or extra whitespace in a file may keep the file containing that definition from being loaded.

 

BTW - I've added ORDER BY p.products.id ASC to the Froogle database query to get it to sort multiple entries. I'd like to add an if loop to cause it to skip duplicate entries, but don't want to break anything - its been a long day, so I'll look at it some more tomorrow. This is really a strong need for folks who have a large store, use froogle, and have products that just need to be in multiple categories to make browsing more efficient.

 

Thanks to this thread I now have the 2nd posted version up and running (as posted to the archives). Now I need to start modifying the file layouts etc. I'd like to have product attributes and options downloaded in a separate file, and a new 'complete file' - leaving an option for the current complete file type as a 'basic product file' - for products with no need for attributes or options.

 

Also, I think the ideas of being able to download orders, and upload files that can delete products are very good.

Share this post


Link to post
Share on other sites

Also, on the Froogle file layout - the header lines have been declared obsolete. They don't break an upload, yet - but may in the future.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×