Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quick Add Products


andz56

Recommended Posts

Hi all,

 

I have found a contribution that i feel could be amazing for a lot of people. The Quick Add Products contribution

does exactly what it says on the tin (or at least it would if it worked!!!)

 

http://www.oscommerce.com/community/contributions,1281/

 

The contribution basically allows you to add numerous fields for numerous new products all within a single page.

The problem is that although it easily updates and recalls most of the fields, the images field updates the database

in 'products_images' but does not copy the image across to the images directory.

 

In summary although the image is stored in the database, the image online does not display as it is not physically

in the directory. I will post the code below in the hope that someone far cleverer than myself will be able to assist with

an answer and allow many people the possibility of using a really fast contribution.

 

Thanks

 

THE QUICK_ADD_PRODUCTS.php CODE: -

 

<?php
 require('includes/application_top.php');


//// Tax Row
   $tax_class_array = array();
   $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
   while ($tax_class = tep_db_fetch_array($tax_class_query)) {
     $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
                                'text' => $tax_class['tax_class_title']);
   }

////Info Row pour le champ fabriquant
$manufacturers_array = array(array('id' => '0', 'text' => NO_MANUFACTURER));
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
	$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
	'text' => $manufacturers['manufacturers_name']);
}


##// Update database
 switch ($HTTP_GET_VARS['action']) {
   case 'add' :
	$products_added = 0;

	for ($i = 1; $i <= MAX_PRODUCTS; $i++) {
		$valid = false; $product_exist = false;
		if($HTTP_POST_VARS['product_name'][$i]){
			foreach($HTTP_POST_VARS['product_name'][$i] as $id => $product_language_name){	
				if($product_language_name != ''){
					if(!$product_exist){
						if(strrchr($HTTP_POST_VARS['product_image'][$i], '\\'))$image = substr(strrchr(trim(stripslashes($HTTP_POST_VARS['product_image'][$i])), '\\'), 1);else $image = substr(strrchr(trim(stripslashes($HTTP_POST_VARS['product_image'][$i])), '/'), 1);
						tep_db_query("INSERT INTO " . TABLE_PRODUCTS . " (products_quantity, products_model, products_image, products_price, products_weight, products_status, products_tax_class_id, manufacturers_id) VALUES (" . $HTTP_POST_VARS['product_quantity'][$i] . ", '" . $HTTP_POST_VARS['product_model'][$i] . "', '" . $HTTP_POST_VARS['product_image'][$i] . "', " . $HTTP_POST_VARS['product_price'][$i] . ", " . $HTTP_POST_VARS['product_weight'][$i] . ", ". $HTTP_POST_VARS['product_status'][$i] . ", " . $HTTP_POST_VARS['product_tax'][$i] . ", " . $HTTP_POST_VARS['product_manufacturer'][$i] . ");");
						$products_id_query = tep_db_query("SELECT products_id from " . TABLE_PRODUCTS . " WHERE products_quantity=" . $HTTP_POST_VARS['product_quantity'][$i] ." and products_model='" . $HTTP_POST_VARS['product_model'][$i] ."' and products_price=" . $HTTP_POST_VARS['product_price'][$i] . " and products_weight=" . $HTTP_POST_VARS['product_weight'][$i] . " and products_image='" . $HTTP_POST_VARS['product_image'][$i] . "' and products_status=" . $HTTP_POST_VARS['product_status'][$i] . " and products_tax_class_id=" . $HTTP_POST_VARS['product_tax'][$i] . " and manufacturers_id=" . $HTTP_POST_VARS['product_manufacturer'][$i] . ";");
						$products_id = tep_db_fetch_array($products_id_query);
						tep_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " VALUES ('" . $products_id['products_id'] . "', '" . $HTTP_POST_VARS['product_categories'][$i] . "');");
					}
					tep_db_query("INSERT INTO " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description) VALUES ('" . $products_id['products_id'] . "', '" . $HTTP_POST_VARS['languages'][$i][$id] . "', '" . $product_language_name . "', '" . $HTTP_POST_VARS['product_description'][$i][$id] . "');");

					$product_exist = true;
					$valid = true;
				}
			}
		}
		if($valid)$products_added++;
	}
	$messageStack->add($products_added . ' ' . TEXT_PRODUCTS_ADDED , 'success');
   break;
 }

##// Let's start displaying page with forms
?>

 

 

 

 

THE MY SQL: -

INSERT INTO `configuration_group` (`configuration_group_id`, `configuration_group_title`, `configuration_group_description`, `sort_order`, `visible`) VALUES ('400', 'Quick Add Product', 'You can for example choose haw many products will be added in one time.', '400', '1');

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES (2000, 'Number of products.', 'MAX_PRODUCTS', '5', 'Number of products you can add in one time.', '400', '0', '2003-06-04 08:49:27', '2003-06-04 08:49:27', NULL, NULL), 
(2001, 'Display price with all included tax.', 'DISPLAY_TVA_UP_ADD', 'true', 'Do you want that the price with all included tax be displayed?', 3400, 11, '2003-06-04 05:07:06', '2003-06-04 04:40:12', NULL, 'tep_cfg_select_option(array(\'true\', \'false\'),'), 
(2002, 'Taxe rate.', 'ALL_INCLUDED_TAX_VALUE', 19.6, 'You have to choose the tax rate you want to use to calculate the price with all included tax.', 3400, 11, '2003-06-04 05:07:06', '2003-06-04 04:40:12', NULL, NULL); 

 

 

 

Thanks again, i hope sone one can help

Link to comment
Share on other sites

I just feel that on many occasions more technical stuff has been carried out. All this contribution now needs to do is copy the image from the database to the images directory!

The image is not stored in the database, its location is.

 

If you have problems uploading images, it may well be another issue.

Link to comment
Share on other sites

Ahhh Thanks.

 

Any ideas of where to start then?...i think this contribution worked in the early days!

OK, try creating a new product in admin and see how you go. It maybe related to a patch to the version of osc you have.

Edited by Coopco
Link to comment
Share on other sites

OK, try creating a new product in admin and see how you go. It maybe related to a patch to the version of osc you have.

 

I assume by this you mean just do it the normal way and forget about quick add?

Link to comment
Share on other sites

Does anyone else have any good suggestions on how this issue could be work around. Surely not everyone does it the conventional way and/or through using easy populate do they?

 

If this isn't the best contribution to do this or it cannot be fixed, has anyone got any suggestions on any other quick add products type modules?

 

Thanks

Link to comment
Share on other sites

  • 3 years later...

for some reason i can't get this to work. i got the link displayed under catalog, but the page is empty, and under configuration there is nothing. there is should a be an entry to adjust the Number of products.

any ideas hot to fix this?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...