Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

attribute options


webangel

Recommended Posts

Posted

Has anyone merged the Attributes Option Type Selection into osc 2.2MS2? I have been trying to make this work but am having difficulty. I am hoping that a better programmer than myself might have attempted this and be willing to share.

 

Thanks,

Lynn

Posted

You'll get more help if you ask a specific question. This is very open-ended and doesn't give anyone a real starting point from which to help you. If you're getting errors, post the exact error message. If you don't understand the directions, post the portion of the directions, etc.

Contributions

 

Discount Coupon Codes

Donations

Posted

Well, mostly I am confused, due to the changes from when code that is 2.0.2MS1 to 2.2MS2.

 

Taking a look at the contribution in the admin/product_attributes.php a loop is added to support the different types.

 

This is the contribution on 2.0.2MS1:

 

case 'add_product_attributes':

for ($i=0;$i<sizeof($HTTP_POST_VARS['values_id']);$i++) {

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $HTTP_POST_VARS['products_id'] . "', '" . $HTTP_POST_VARS['options_id'] . "', '" . $HTTP_POST_VARS['values_id'][$i] . "', '" . $HTTP_POST_VARS['value_price'] . "', '" . $HTTP_POST_VARS['price_prefix'] . "', '" . $HTTP_POST_VARS['type_id'] . "', '" . $HTTP_POST_VARS['options_values_qty'] . "', '" . $HTTP_POST_VARS['attribute_order'] . "', '" . $HTTP_POST_VARS['collegamento'] . "')");

$products_attributes_id = tep_db_insert_id();

if ((DOWNLOAD_ENABLED == 'true') && $HTTP_POST_VARS['products_attributes_filename'] != '') {

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . $products_attributes_id . ", '" . $HTTP_POST_VARS['products_attributes_filename'] . "', '" . $HTTP_POST_VARS['products_attributes_maxdays'] . "', '" . $HTTP_POST_VARS['products_attributes_maxcount'] . "')");

}

}

tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

break;

 

Essentially the loop is added for the value_id supporting the different types. Looking at the 2.2MS2 code without the contribution:

 

case 'add_product_attributes':

$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);

$values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']);

$value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);

$price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

 

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')");

 

if (DOWNLOAD_ENABLED == 'true') {

$products_attributes_id = tep_db_insert_id();

 

$products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);

$products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);

$products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

 

if (tep_not_null($products_attributes_filename)) {

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");

}

}

 

tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

break;

 

To add the contribution to 2.2MS2 it seems like some reordering would be necessary, along with a loop, something like this:

 

case 'add_product_attributes':

$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);

$value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);

$price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

 

// add fetching of new fields here

 

for ($i=0;$i<sizeof($HTTP_POST_VARS['values_id']);$i++) {

$values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id'][$i]);

}

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) .

//add new fields here also

"')");

 

if (DOWNLOAD_ENABLED == 'true') {

$products_attributes_id = tep_db_insert_id();

 

$products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);

$products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);

$products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

 

if (tep_not_null($products_attributes_filename)) {

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");

}

}

 

tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));

break;

 

 

Is that going to be sufficient, or does the tep_db_query() call need to be inside the loop as well?

 

Thanks,

Lynn

Posted

I'm not familiar with this contribution, but in looking at the code, I believe you are entirely on the right track.

 

 

// add fetching of new fields here

 

for ($i=0;$i<sizeof($HTTP_POST_VARS['values_id']);$i++) {

$values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id'][$i]);

}

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) .

//add new fields here also

"')");

 

You will need to move the tep_db_query() inside the loop. Try this block:

 

 case 'add_product_attributes':
$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
$options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']);
$value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']);
$price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']);

// add fetching of new fields here
//kgt ^ this isnt' strictly necessary, but it helps with readability.  See the query below.

for ($i=0;$i<sizeof($HTTP_POST_VARS['values_id']);$i++) {
$values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id'][$i]);

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) ."', '" . tep_db_prepare_input($HTTP_POST_VARS['type_id']) . "', '" . tep_db_prepare_input($HTTP_POST_VARS['options_values_qty']) . "', '" . tep_db_prepare_input($HTTP_POST_VARS['attribute_order']) . "', '" . tep_db_prepare_input($HTTP_POST_VARS['collegamento']) ."')");

if (DOWNLOAD_ENABLED == 'true') {
$products_attributes_id = tep_db_insert_id();

$products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']);
$products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']);
$products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']);

if (tep_not_null($products_attributes_filename)) {
tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')");
}
}
} //this is the closing bracket for the *for* loop.  The 2.0.2 code includes the if( DOWNLOAD_ENABLED ) line in the for loop, so that's what you should do here as well.

tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info));
break;

 

 

This of course isn't tested, so be sure to have a backup to restore to.

Contributions

 

Discount Coupon Codes

Donations

Posted
I'm not familiar with this contribution, but in looking at the code, I believe you are entirely on the right track.

You will need to move the tep_db_query() inside the loop. Try this block:

 

Thanks, I do have a copy of the original files that I can restore to. I will try it with the loop like you outlined.

 

There are a few other places I am not completely sure about, but I need to look at those. I'll post a specific query again if I have trouble figuring it out.

 

Lynn

Archived

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

×
×
  • Create New...