Guest Posted July 22, 2009 Share Posted July 22, 2009 Can someone help? I use the contrib Extra Product Fields 1.1 by wdepot. This contrib generates a listing of extra field values. I just want 1 value of this function for a flash import. e.g. size M instead of the whole listing. Do I have to do an implode? This is the code which generates the listing (product_info.php) [indent]// begin Extra Product Fields $epf = array(); if ($product_check['total'] > 0) { $epf_query = tep_db_query("select e.epf_id, e.epf_uses_value_list, e.epf_show_parent_chain, e.epf_use_as_meta_keyword, l.epf_label from " . TABLE_EPF . " e join " . TABLE_EPF_LABELS . " l where e.epf_status and (e.epf_id = l.epf_id) and (l.languages_id = " . (int)$languages_id . ") and l.epf_active_for_language order by epf_order"); while ($e = tep_db_fetch_array($epf_query)) { // retrieve all active extra fields $epf[] = array('id' => $e['epf_id'], 'label' => $e['epf_label'], 'uses_list' => $e['epf_uses_value_list'], 'show_chain' => $e['epf_show_parent_chain'], 'search' => $e['epf_advanced_search'], 'keyword' => $e['epf_use_as_meta_keyword'], 'field' => 'extra_value' . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id']); } $query = "select p.products_date_added, p.products_last_modified, pd.products_name"; foreach ($epf as $e) { if ($e['keyword']) $query .= ", pd." . $e['field']; } $query .= " from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"; $pname = tep_db_fetch_array(tep_db_query($query)); $datemod = substr((tep_not_null($pname['products_last_modified']) ? $pname['products_last_modified'] : $pname['products_date_added']), 0, 10); } else { $pname = TEXT_PRODUCT_NOT_FOUND; $datemod = date('Y-m-d'); } ------------------------------------- further in product_info: // begin Extra Product Fields foreach ($epf as $e) { if (tep_not_null($product_info[$e['field']])) { // only display if information is set for product echo '<b>' . $e['label'] . ': </b>'; if ($e['uses_list']) { echo tep_get_extra_field_list_value($product_info[$e['field']], $e['show_chain']); } else { echo $product_info[$e['field']]; } echo '<br>'; } } // end Extra Product Fields[/indent] And in functions/general.php: //for Extra Product Fields function tep_get_extra_field_list_value($value_id, $show_chain = false) { $sql = tep_db_query("select epf_value, parent_id from " . TABLE_EPF_VALUES . " where value_id = " . (int)$value_id); $value = tep_db_fetch_array($sql); if ($show_chain && ($value['parent_id'] > 0)) { return tep_get_extra_field_list_value($value['parent_id'], true) . ' | ' . $value['epf_value']; } else { return $value['epf_value']; } } function tep_list_epf_children($parent_id) { $sql = tep_db_query("select value_id from " . TABLE_EPF_VALUES . " where parent_id = " . (int)$parent_id); $list = ''; while ($i = tep_db_fetch_array($sql)) { $list .= ', ' . $i['value_id'] . tep_list_epf_children($i['value_id']); } return $list; } function tep_build_epf_pulldown($epf_id, $languages_id, $value_array = '', $parent_id = 0, $indent = '') { if (!is_array($value_array)) $value_array = array(); $sql = tep_db_query("select epf_value, value_id from " . TABLE_EPF_VALUES . " where epf_id = " . (int)$epf_id . " and languages_id = " . (int)$languages_id . " and parent_id = " . (int)$parent_id . " order by sort_order, epf_value"); while ($v = tep_db_fetch_array($sql)) { $value_array[] = array('id' => $v['value_id'], 'text' => $indent . $v['epf_value']); $value_array = tep_build_epf_pulldown($epf_id, $languages_id, $value_array, $v['value_id'], $indent . '·'); } return $value_array; } function tep_get_product_extra_value($epf_id, $product_id, $language_id) { $epf_query = tep_db_query("select epf_id, epf_uses_value_list from " . TABLE_EPF . " where epf_id = " . (int)$epf_id); $e = tep_db_fetch_array($epf_query); $field = "extra_value" . ($e['epf_uses_value_list'] ? '_id' : '') . $e['epf_id']; $product_query = tep_db_query("select " . $field . " 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[$field]; } Please help! Thanks for your answer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.