You are here:  » New product field on search result page


New product field on search result page

Submitted by IG on Fri, 2014-05-30 15:59 in

Hi David

I have created a new product field "oldprice" to save the price before it was reduced in the database. I managed to use this additional product field on the featured product page, but it won't work on the search results page.

As you can see here, it shows CHF below the discounted price, but the old price itself is not shown:
{link saved}

Why does the following code not work:

<div class="col-md-2 text-center"> <span class="price"><?php print $config_currencyHTML.$product["price"]; ?></span><br /<span class="price"><?php print $config_currencyHTML.$product["oldprice"]; ?></span></div>

Kind regards,
Ivo

Submitted by support on Fri, 2014-05-30 16:09

Hello Ivo,

You need to add the new field to the list of fields selected for search results (which are limited to only those required for performance reasons). To do this, edit search.php and look for the following code at line 374:

$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

...and REPLACE with:

$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating,oldprice FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

Cheers,
David.
--
PriceTapestry.com