Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

new field in products_description; new_product_preview problem


Tabula_Rasa

Recommended Posts

Posted

Hello. I'm hoping somebody can help. I've gone through the thousands of posts on the subject and, for the most part I've almost got everything working, however I'm stuck on one part of this modification:

 

I added a bunch of fields to the tables products and products_description. For the most part everything works, except that I cannot get the fields and values to show with the contents of products_description in the preview part of categories.php (action=new_product_preview). It shows items from products, but not products_description. When I click 'upload' it does post the data to the database, however.

 

In admin/categories.php at the first instance of new_product_preview:

 

  } elseif ($action == 'new_product_preview') {
if (tep_not_null($HTTP_POST_VARS)) {
  $pInfo = new objectInfo($HTTP_POST_VARS);
  $products_name = $HTTP_POST_VARS['products_name'];
  //insert7(); /* INSERTFUNCTION dinsert9 () */
  $products_description = $HTTP_POST_VARS['products_description'];
  $products_listing_header = $HTTP_POST_VARS['products_listing_header'];
  $products_listing_text = $HTTP_POST_VARS['products_listing_text'];
  $products_directions_location = $HTTP_POST_VARS['products_directions_location'];
  $products_directions_car = $HTTP_POST_VARS['products_directions_car'];
  $products_directions_public = $HTTP_POST_VARS['products_directions_public'];
  $products_directions_parking = $HTTP_POST_VARS['products_directions_parking'];
  $products_essential_information = $HTTP_POST_VARS['products_essential_information'];
  $products_special_features = $HTTP_POST_VARS['products_special_features'];
  $products_editors_pics = $HTTP_POST_VARS['products_editors_pics'];
  $products_description_short = $HTTP_POST_VARS['products_description_short'];
  $products_head_title_tag = $HTTP_POST_VARS['products_head_title_tag'];
  $products_head_desc_tag = $HTTP_POST_VARS['products_head_desc_tag'];
  $products_head_keywords_tag = $HTTP_POST_VARS['products_head_keywords_tag'];
  $products_url = $HTTP_POST_VARS['products_url'];
} else {
$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_listing_header, pd.products_listing_text, pd.products_info_header, pd.products_directions_location, pd.products_directions_car, pd.products_directions_public, pd.products_directions_parking, pd.products_essential_information, pd.products_special_features, pd.products_editors_pics, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, p.products_quantity, p.product_image_listing, p.product_image_listing2, p.product_image_detail1_th, p.product_image_detail2_th, p.product_image_detail3_th, p.product_image_detail4_th, p.product_image_detail1, p.product_image_detail2, p.product_image_detail3, p.product_image_detail4, p.product_image_ex1, p.product_image_ex2, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
  $product = tep_db_fetch_array($product_query);

 

then some lines later,

 

	$form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product';

echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');

// HTC BOC  /* INSERTFUNCTION dinsert11 () */	   
$languages = tep_get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
	$pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_listing_header = tep_get_products_listing_header($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_listing_text = tep_get_products_listing_text($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_info_header = tep_get_products_info_header($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_directions_location = tep_get_products_directions_location($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_directions_car = tep_get_products_directions_public($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_directions_parking = tep_get_products_directions_parking($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_essential_information = tep_get_products_essential_information($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_special_features = tep_get_products_special_features($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_editors_pics = tep_get_products_editors_pics($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_description_short = tep_get_products_description_short($pInfo->products_id, $languages[$i]['id']);
	$pInfo->products_head_title_tag = tep_db_prepare_input($products_head_title_tag[$languages[$i]['id']]);
	$pInfo->products_head_desc_tag = tep_db_prepare_input($products_head_desc_tag[$languages[$i]['id']]);
	$pInfo->products_head_keywords_tag = tep_db_prepare_input($products_head_keywords_tag[$languages[$i]['id']]);
	$pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']);
  } else {
	$pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]);
	$pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]);
	$pInfo->products_listing_text = tep_db_prepare_input($products_listing_text[$languages[$i]['id']]);
	$pInfo->products_info_header = tep_db_prepare_input($products_info_header[$languages[$i]['id']]);
	$pInfo->products_directions_location = tep_db_prepare_input($products_directions_location[$languages[$i]['id']]);
	$pInfo->products_directions_car = tep_db_prepare_input($products_directions_car[$languages[$i]['id']]);
	$pInfo->products_directions_public = tep_db_prepare_input($products_directions_public[$languages[$i]['id']]);
	$pInfo->products_directions_parking = tep_db_prepare_input($products_directions_parking[$languages[$i]['id']]);
	$pInfo->products_essential_information = tep_db_prepare_input($products_essential_information[$languages[$i]['id']]);
	$pInfo->products_special_features = tep_db_prepare_input($products_special_features[$languages[$i]['id']]);
	$pInfo->products_editors_pics = tep_db_prepare_input($products_editors_pics[$languages[$i]['id']]);
	$pInfo->products_description_short = tep_db_prepare_input($products_description_short[$languages[$i]['id']]);
	$pInfo->products_head_title_tag = tep_db_prepare_input($products_head_title_tag[$languages[$i]['id']]);
	$pInfo->products_head_desc_tag = tep_db_prepare_input($products_head_desc_tag[$languages[$i]['id']]);
	$pInfo->products_head_keywords_tag = tep_db_prepare_input($products_head_keywords_tag[$languages[$i]['id']]);
	$pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]);
  }	 
// HTC EOC

 

The new functions in the second to last part, such as " tep_get_products_listing_text" are copies of " tep_get_products_description" located in includes/functions/general.php except that the names of fields and name of the function match. For example:

 

 function tep_get_products_description($product_id, $language_id) {
$product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
$product = tep_db_fetch_array($product_query);

return $product['products_description'];
 }
 function tep_get_products_listing_header($product_id, $language_id) {
$product_query = tep_db_query("select products_listing_header from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
$product = tep_db_fetch_array($product_query);

return $product['products_listing_header'];
 }

 

Lastly, in the html output,

 

	<table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_name; ?></td>
		<td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
<!-- /* INSERTFUNCTION dinsert12 () */ -->
  <tr>
	<td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?></td>
  </tr>

  <tr>
	<td><?php echo $pInfo->products_listing_text; ?></td>
  </tr>
  <tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_LISTING; ?>   <?php $product_image_listing; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_LISTING2; ?>   <?php $product_image_listing2; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL_TH1; ?>   <?php $product_image_detail1_th; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL_TH2; ?>   <?php $product_image_detail2_th; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL_TH3; ?>   <?php $product_image_detail3_th; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL_TH4; ?>   <?php $product_image_detail4_th; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL1; ?>   <?php $product_image_detail1; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL2; ?>   <?php $product_image_detail2; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL3; ?>   <?php $product_image_detail3; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_DETAIL4; ?>   <?php $product_image_detail4; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_EX1; ?>   <?php $product_image_ex1; ?> </tr>
<tr><td class="main"><?php echo TEXT_PRODUCTS_IMAGE_EX2; ?>   <?php $product_image_ex2; ?></tr>

 

The part that says to echo, <?php echo $pInfo->products_listing_text; ?>, only results in the output "Array"... not the contents of the field. I'm fairly confident that the issue is in the general.php function,

 

  function tep_get_products_listing_header($product_id, $language_id) {
$product_query = tep_db_query("select products_listing_header from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
$product = tep_db_fetch_array($product_query);

return $product['products_listing_header'];
 }

But, I don't know why it wouldn't work. It's essentially a copy of everything that is done with products_descriptions. Only names of fields are changed.

 

I need the fields, all of them, to show up in the preview. How do I do this?

 

Thank you.

Posted

As I see the tep_get_products_listing_header returns the 'products_listing_header' from the database. Where is the tep_get_products_listing_text function? Have you checked it?

Posted
As I see the tep_get_products_listing_header returns the 'products_listing_header' from the database. Where is the tep_get_products_listing_text function? Have you checked it?

 

All of the text fields corresponded with functions in ~/general.php that were the same as the original _products_description except that the names were swapped appropriately. ;)

 

I somehow solved it, but I'm not sure what I did... since the output was, literally, "array" instead of the content of the array, I'm suspecting a typo that I unconsciously fixed while playing with this.

 

It's a huge pain the way that osCommerce has the new fields (and therefore new field creation) spread all over the place. The name of a new field should be generated once, then all instances of it should just be automatically generated with parmeters for input type, etc. Not a single one of my clients were ever satisfied with the pre-established fields that osCommerce has put into place and 'new fields' is always a day project.

Posted
It's a huge pain the way that osCommerce has the new fields (and therefore new field creation) spread all over the place. The name of a new field should be generated once, then all instances of it should just be automatically generated with parmeters for input type, etc. Not a single one of my clients were ever satisfied with the pre-established fields that osCommerce has put into place and 'new fields' is always a day project.

 

Really depends how you're implementing a feature. The categories.php in particular has by default lots of complexity. I would prefer to use some extra module like the products extra fields or categories extra fields or some attribute module to enhance products and for images there are modules which use external tables so the default tables products and products_description remain pretty much the same. You still have a bit more work to do on the catalog end, merging tables to acquire information, but it's cleaner and easier to maintain.

Archived

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

×
×
  • Create New...