Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

move, copy and delete multiple products in one step


Guest

Recommended Posts

I figured it out...

 

Changed: tep_array_merge to array_merge

 

Seems to have done the trick

 

 

 

I followed all the instructions step by step but im getting this error:

 

Fatal error: Call to undefined function: tep_array_merge() in html/shop/admin/products_multi.php on line 233

 

Can someone help, please advise, thanks

Link to comment
Share on other sites

  • 3 months later...
  • Replies 197
  • Created
  • Last Reply

I have 2 questions.

 

If you link an item with a quantity of 1 to another category...when it's purchased...does the inventory drop to zero for both listings? You can't buy it, regardless of the fact it's appearing in more than one category, right?

 

Lastly...I've seen some posts in this thread regarding Header Tags Controller, which I use.

 

If I link an item from Category A to Category B...do I lose the header tags on the item when viewed from Category B, the linked one? Do I lose header tags entirely on the item, in both categories it's now in? I'm confused by the issues with HTC. Thanks for any help!

Link to comment
Share on other sites

  • 1 month later...

Did anyone find the fix to this error, seems like I'm not the only one.

 

Warning: Invalid argument supplied for foreach() in /home/reef/public_html/shop/admin/products_multi.php on line 56

 

Warning: Cannot modify header information - headers already sent by (output started at /home/reef/public_html/shop/admin/products_multi.php:56) in /home/reef/public_html/shop/admin/includes/functions/general.php on line 36

Link to comment
Share on other sites

Did anyone find the fix to this error, seems like I'm not the only one.

 

Warning: Invalid argument supplied for foreach() in /home/reef/public_html/shop/admin/products_multi.php on line 56

 

Warning: Cannot modify header information - headers already sent by (output started at /home/reef/public_html/shop/admin/products_multi.php:56) in /home/reef/public_html/shop/admin/includes/functions/general.php on line 36

 

I just noticed that I only get this error if I submit the form without anything selected. All the functions seem to be working fine if one of more products are selected.

 

Another quick question, when I'm viewing all my categories in this module I see the "choose all / remove chosen" option but there are no check boxes. Is this supposed to be this way? maybe to protect against deleting complete categories?

Link to comment
Share on other sites

  • 2 months later...

These additions will allow you to export a comma-delimited spreadsheet of products that you check off in the multiple product manager. You can update the query, header for the spreadsheet ($export = "Product Name,Description,Model,MSRP,Stree Price, Image\n";), and the data ($export .= ) to be whatever you want. This exports the basics.

 

___In this file (or your respective language file):

catalog/admin/includes/languagues/english/products_multi.php

 

-- add this line:

define('EXPORT', 'Export these products');

 

___In this file:

catalog/admin/products_multi.php

 

-- around line 36 after the delete case, add this new case:

case 'export_product':

function tep_get_products_special_price($product_id) {

$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status");

$product = tep_db_fetch_array($product_query);

return $product['specials_new_products_price'];

}

$export = '';

$wherestatement = '';

if(is_array($choose)){

foreach ($choose as $products_id) {

$wherestatement .= " p.products_id='".tep_db_input($products_id). "' OR ";

}

 

if($wherestatement){

$wherestatement = " AND (".substr($wherestatement,0,-4).")";

}

$search = array('/\n/','/\r/','/,/');

$replace = array(' ',' ',' ');

 

$sql = tep_db_query("select products_name, products_description, products_model, products_price, products_image_lg from ".TABLE_PRODUCTS. " p, ".TABLE_PRODUCTS_DESCRIPTION." pd where p.products_id=pd.products_id ".$wherestatement."");

if(mysql_num_rows($sql)>0){

$export = "Product Name,Description,Model,MSRP,Stree Price, Image\n";

}

while($row = tep_db_fetch_array($sql)){

if ($new_price = tep_get_products_special_price($row['products_id'])) {

$products_price = $new_price;

} else {

$products_price = $row['products_price'];

}

$products_price = number_format($products_price,2,'.','');

 

$large_image = '';

if($row['products_image_lg']){

$large_image = 'http://www.doittennis.com/images/lg-clean/'.$row['products_image_lg'];

}

 

$export .= preg_replace($search, $replace, strip_tags($row['products_name'])).','.preg_replace($search, $replace, strip_tags($row['products_description'])).','.$row['products_model'].','.$products_price.','.$products_price.','.$large_image."\n";

}

 

if($export && mysql_num_rows($sql)>0){

header("Content-type: application/octet-stream");

header("Content-Disposition: attachment; filename=Products-".date('Y-m-d').".csv");

header("Pragma: no-cache");

header("Expires: 0");

print $export;

exit;

} else {

if (USE_CACHE=='true') {tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased');}

tep_redirect(tep_href_link(FILENAME_PRODUCTS_MULTI, 'cPath=' . $cPath));

}

}

break;

 

-- towards the end of the file above the table row with the submit button, add this:

 

<tr>

<td class="smallText"></td>

<td align="right" class="smallText" colspan="2">

<label for="export_product"><?php echo EXPORT; ?></label><input type="radio" name="action" value="export_product" id="export_product">

 

</td>

</tr>

 

Suggestions for improvements welcome.

Best wishes!

Link to comment
Share on other sites

  • 5 months later...
  • 2 weeks later...
I just noticed that I only get this error if I submit the form without anything selected. All the functions seem to be working fine if one of more products are selected.

 

Another quick question, when I'm viewing all my categories in this module I see the "choose all / remove chosen" option but there are no check boxes. Is this supposed to be this way? maybe to protect against deleting complete categories?

 

From what I cann see the contribution is not designed to act on categories - only products. By checking $_REQUEST['choose'] it should tell us that no products are selected so all actions can be ignored - so no error.

 

Look for:

 

$cat_stat=0; // internal use -- 0 = no / 1 = yes

 

and add after:

 

if(isset($_REQUEST['choose'])) {

 

and look for:

 

// check if the catalog image directory exists
 if (is_dir(DIR_FS_CATALOG_IMAGES)) {

 

and add before:

 

}

 

So it should all look like this:

 

if(isset($_REQUEST['choose'])) {

 $action=(isset($_REQUEST['action']) ? $_REQUEST['action'] : '');
 if (tep_not_null($action)) {
$choose = (isset($_REQUEST['choose']) ? $_REQUEST['choose'] : '');
switch ($action) {
  case 'delete_product_confirm':
		  $del_art=(isset($_REQUEST['del_art']) ? $_REQUEST['del_art'] : '');
		  foreach ($choose as $products_id) {
			  if ($del_art=='complete')	tep_remove_product($products_id);
			  elseif ($del_art=='this_cat') {
				  $duplicate_check = tep_db_fetch_array(tep_db_query("select count(*) as total from ".TABLE_PRODUCTS_TO_CATEGORIES. " where products_id='".tep_db_input($products_id). "' and categories_id<>'". tep_db_input($current_category_id)."'"));
				  //If product exists only in this category we remove him totally
				  //If we have this product in other categories we just remove from TABLE_PRODUCTS_TO_CATEGORIES.
				  if ($duplicate_check['total']>0)	 tep_db_query("delete from ".TABLE_PRODUCTS_TO_CATEGORIES.
						 " where products_id='". $products_id."' and categories_id='".$current_category_id."'");
				  else	tep_remove_product($products_id);
			  }
			  if (USE_CACHE=='true') {tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased');}
		  }
		  tep_redirect(tep_href_link(FILENAME_PRODUCTS_MULTI, 'cPath=' . $cPath));
		  break;
  case 'move_product_confirm':
		  foreach ($choose as $products_id) {
			  $new_parent_id=tep_db_prepare_input($_REQUEST['categories_id']);
			  $duplicate_check_query=tep_db_query("select count(*) as total from ".TABLE_PRODUCTS_TO_CATEGORIES.
						 " where products_id='".tep_db_input($products_id)."' and categories_id='". tep_db_input($new_parent_id)."'");
			  $duplicate_check = tep_db_fetch_array($duplicate_check_query);
			  if($duplicate_check['total']<1)	  tep_db_query("update ".TABLE_PRODUCTS_TO_CATEGORIES.
						 " set categories_id ='".tep_db_input($new_parent_id).
						 "' where products_id='".tep_db_input($products_id)."' and categories_id='". $current_category_id."'");
			  if (USE_CACHE == 'true') {tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased');}
		  }
		  tep_redirect(tep_href_link(FILENAME_PRODUCTS_MULTI, 'cPath='.$new_parent_id.'&pID='.$products_id));
		  break;
  case 'link_to_confirm':
		  foreach ($choose as $products_id) {
			  $categories_id = tep_db_prepare_input($_REQUEST['categories_id']);
			  if ($_REQUEST['categories_id'] != $current_category_id) {
				  $check=tep_db_fetch_array(tep_db_query("select count(*) as total from ".
								 TABLE_PRODUCTS_TO_CATEGORIES." where products_id='".tep_db_input($products_id) .
								  "' and categories_id='". tep_db_input($categories_id) . "'"));
				  if ($check['total']<'1')	tep_db_query("insert into ".TABLE_PRODUCTS_TO_CATEGORIES.
								" (products_id, categories_id) values ('".tep_db_input($products_id)."', '".tep_db_input($categories_id)."')");
			  } else	$messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
			   if (USE_CACHE == 'true') {tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased');}
		  }
		  tep_redirect(tep_href_link(FILENAME_PRODUCTS_MULTI, 'cPath=' . $categories_id . '&pID=' . $products_id));
		  break;
  case 'copy_to_confirm':
		  foreach ($choose as $products_id) {
			  $product_query = tep_db_fetch_array(tep_db_query('select * from '.TABLE_PRODUCTS.' where products_id="'.(int)$products_id.'"'));
			  $product_query['products_id'] = '';
			  tep_db_perform(TABLE_PRODUCTS, $product_query);
			  $categories_id = tep_db_prepare_input($_REQUEST['categories_id']);
			  $dup_products_id = tep_db_insert_id();

//Attributes Copy, Contributed by Joshua Guerra, [email protected]
			  $num_row_query=tep_db_query("select products_attributes_id from ".TABLE_PRODUCTS_ATTRIBUTES." WHERE products_id=".$products_id);
			  $num_rows_attrib = array();
			  while ($categorie = tep_db_fetch_array($num_row_query))	 $num_rows_attrib[]=$categorie['products_attributes_id'];
			  sort($num_rows_attrib);
			  //for ($j=0; $j < sizeof($num_rows_attrib); $j++) {
			  foreach($num_rows_attrib as $attrib_id) {
				  $attrib = tep_db_fetch_array(tep_db_query("select products_attributes_id, options_id, options_values_id, options_values_price, price_prefix from ".TABLE_PRODUCTS_ATTRIBUTES." where products_attributes_id=".$attrib_id));

				  tep_db_query("insert into ".TABLE_PRODUCTS_ATTRIBUTES." (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('".$dup_products_id."','".$attrib['options_id']."','". $attrib['options_values_id']."','".tep_db_input($attrib['options_values_price']).
				  "','".tep_db_input($array['price_prefix'])."')");
			  }
// EOF: Attributes Copy
			  $description_query=tep_db_query("select language_id, products_name, products_description, products_url from ".TABLE_PRODUCTS_DESCRIPTION." where products_id='".$products_id."'");
			  while ($description = tep_db_fetch_array($description_query)) {
				  tep_db_query("insert into ".TABLE_PRODUCTS_DESCRIPTION." (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('".$dup_products_id."', '".$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
			  }
			  tep_db_query("insert into ".TABLE_PRODUCTS_TO_CATEGORIES." (products_id, categories_id) values ('". $dup_products_id."', '".$categories_id."')" );
			   if (USE_CACHE == 'true') {tep_reset_cache_block('categories'); tep_reset_cache_block('also_purchased');}
		  }
		  tep_redirect(tep_href_link(FILENAME_PRODUCTS_MULTI, 'cPath='.$categories_id.'&pID=' .$dup_products_id));
		  break;
}
 }
 }

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 4 months later...
hi all,

 

i've developped a simple tool to move, delete and copy multiple products in one step.

 

Anybody interested?

 

Where can i send it to for public download?

 

sr

 

Im using Headertags Seo 3.0.*

How can i make it work so this data is copied to

 

Thanks

Link to comment
Share on other sites

  • 3 weeks later...

Does anyone know if this is working on RC2?

My client says it's not moving the products on her new installation.

 

Tks for any input.

Patty

Link to comment
Share on other sites

  • 1 month later...
Does anyone know if this is working on RC2?

My client says it's not moving the products on her new installation.

 

Tks for any input.

 

I am having the same problem - When I search for a particular product and select it to move it doesn't get moved.

 

If I go into a category and select the product it gets moved - It doesn't appear to be working when you search and select products. Any iunput appreciated

 

Thanks

 

Mark

Regards

 

Mark A Reynolds

Link to comment
Share on other sites

  • 5 weeks later...

It seems this contribution has been abandoned, although it's a great one and very useful, but it's full of bugs and needs a good update.

 

I just discovered a very serious issue:

The delete function does NOT delete the products from the db completely!! It will delete the products from the products_to_categories table, but it won't delete them from the products and products_description tables, which will end up messing up the whole database!

 

I have a client with a huge db full of ghost products because of this, which is causing a series of problems, including mysql overload. I don't even know what would happen with the products attributes, for this client doesn't use them, but it will probably have problems as well.

 

I'm thinking of paying a programmer to fix this for me, since there hasn't been any replies to the issues posted here in ages. Anybody would like to join me?

 

Any good programmer who would like to take a shot at this please contact me and let me know your price.

Patty

Link to comment
Share on other sites

  • 2 months later...

Hi I just installed this mod and it is not working for me. Can someone help me?

 

The errors I am getting are this:

 

 

Warning: Invalid argument supplied for foreach() in /homepages/16/d298883732/htdocs/nicehead/products_multi.php on line 52

 

Warning: Cannot modify header information - headers already sent by (output started at /homepages/16/d298883732/htdocs/nicehead/products_multi.php:52) in /homepages/16/d298883732/htdocs/nicehead/includes/functions/general.php on line 22

 

This happens when I try to link categories from the Multiple Products to the regular products admin.

 

Thanks,

Eva

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

Great tool, very much appreciated, will save me days of work for sure. All set up and running fine although i was worried at first by the post regarding it not deleting products from the db completely - a simple work around would be to use the multi move function to get everything that needs to be completely deleted into a temp cat then go back to the usual method of deleting the whole cat and its contents - that would work for me i think but please advise in if I am missing something? Usually though i do not like to remove products from the DB to keep records of what was sold etc but its worth knowing that feature does not work as expected.

 

All in all, I wish I had found this tool three years ago, thanks to all who have worked on it.

Tony.

Tony

Link to comment
Share on other sites

  • 4 months later...

Hi,

 

I use the great contribution. I use the Multistore Contrib too (http://www.oscommerce.com/community/contributions,1730). There you have multiple Store(s) (e.g. Store1, Store2, ...) and only one Database with the products. There is one table, wich connects the StoreID withe the productID.

 

Is there an easy way to use the "products-multi"-Contrib for select products and assign them to one or more Stores?

 

Thanks!

 

Axel

Link to comment
Share on other sites

  • 4 months later...

1. Has anyone modified this to work with products_model AND products_name?

 

2. If you search for a products_name, it won't let you update the result.

The category_id of each product is not known if they come from different categories.

 

search query should include the search for model:

$products_query = tep_db_query("select p.products_tax_class_id, p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_model, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and (pd.products_name like '%" . $HTTP_GET_VARS['search'] . "%' or p.products_model like '%" . $HTTP_GET_VARS['search'] . "%') order by pd.products_name"); // original

 

We could than add a hidden field for the category same as it is done with $choose

<input type="hidden" name="kat[]" value="<?= $products['categories_id'] ?>" id="checkbox_kat_<?= $products_count ?>">

 

and add this to the fubctions, ex:

case 'move_product_confirm':

for ($i = 0; $i < $selected_cnt; $i++) {

$products_id = $choose[$i];

$current_cat_id = $kat[$i];

$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

 

$duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . tep_db_input($products_id) . "' and categories_id = '" . tep_db_input($new_parent_id) . "'");

 

$duplicate_check = tep_db_fetch_array($duplicate_check_query);

 

if ($duplicate_check['total'] < 1) {

tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . tep_db_input($new_parent_id) . "' where products_id = '" . tep_db_input($products_id) . "' and categories_id = '" . $current_cat_id . "'");

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

} // for

 

tep_redirect(tep_href_link(FILENAME_PRODUCTS_MULTI, 'cPath=' . $new_parent_id . '&pID=' . $products_id));

break;

It works, but not really...

Any help out there?

Link to comment
Share on other sites

  • 6 months later...

Hi

 

i'm sorry! i know that this topic is very old, but... really, i need help.

 

my osC is a old version. 2.2 RC2a. I can not to update it because i have made many changes.

 

different from most colleagues, my problem is the fact that the variable $action is always null. Regardless of which option I choose (copy, move, delete ...)

 

can someone to help?

 

 

ps.: sorry, me english is not good. i'm braziliam.

Link to comment
Share on other sites

  • 1 year later...

hello im using OSC Installed Version: osCommerce Online Merchant v2.3.1

 

installed Multiple_Products_Manager_for_2.3.1_v2.6

 

no errors but no products load in the "Multiple Products Manager"

 

any ideas? thanks

 

update:

products appear in more Cat.

 

but not in TOP and in a Cat with 1000+ products?

Link to comment
Share on other sites

It seems this contribution has been abandoned, although it's a great one and very useful, but it's full of bugs and needs a good update.

 

I just discovered a very serious issue:

The delete function does NOT delete the products from the db completely!! It will delete the products from the products_to_categories table, but it won't delete them from the products and products_description tables, which will end up messing up the whole database!

 

I have a client with a huge db full of ghost products because of this, which is causing a series of problems, including mysql overload. I don't even know what would happen with the products attributes, for this client doesn't use them, but it will probably have problems as well.

 

I'm thinking of paying a programmer to fix this for me, since there hasn't been any replies to the issues posted here in ages. Anybody would like to join me?

 

Any good programmer who would like to take a shot at this please contact me and let me know your price.

 

are you sure?

what tables\entry are not removed?

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...