But because those products have a price of zero, the product catalog then was displaying a price of zero.
To fix this by displaying a minimum price or a range of prices, in catalog/index.php you can use something like this:
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
// $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_ATTRIBUTES . " pa on p.products_id = pa.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . " group by p.products_id";
} else {
// We show them all
// $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, MIN(pa.options_values_price) AS min_options_values_price, MAX(pa.options_values_price) AS max_options_values_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_PRODUCTS_ATTRIBUTES . " pa on p.products_id = pa.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'" . " group by p.products_id";
}
}
You can see the original v2.3.1 statement is commented out. A MIN() and MAX() call are used to get the range of option prices, through a LEFT JOIN with the products_attributes table. The GROUP BY at the end is required for MIN() and MAX() to function.
That retrieves the range of option prices. To display them, modify catalog/include/modules/product_listing.php by adding tests for the min_* and max_* values and displaying either the (product price + option price) or a range of low to high prices:
case 'PRODUCT_LIST_PRICE':
if (tep_not_null($listing['specials_new_products_price'])) {
$prod_list_contents .= ' <td align="right"><del>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>';
} else {
if (tep_not_null($listing['min_options_values_price'])) {
if (tep_not_null($listing['max_options_values_price']) && $listing['min_options_values_price'] < $listing['max_options_values_price']) {
$prod_list_contents .= ' <td align="right">' . $currencies->display_price($listing['products_price']+$listing['min_options_values_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . " - " . $currencies->display_price($listing['products_price']+$listing['max_options_values_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
} else {
$prod_list_contents .= ' <td align="right">' . $currencies->display_price($listing['products_price']+$listing['min_options_values_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
}
} else {
$prod_list_contents .= ' <td align="right">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
}
}
break;
I chose the "$minimum - $maximum" format to reduce language difficulties.
It also is necessary to modify catalog/product_info.php to similarly show the option price, or just to hide the $0 price.
I thought I'd add this tip here for others who also need the prices including options -- and the price range including options.
I don't like the modify-code-files methods required for such alterations, so I'd rather not submit it as a packaged contribution. If someone else wants to extend the code to manufacturer displays and do something with it, please do.
Edited by ScotWilcoxon, 18 January 2012, 20:42.














