You are here:  » Find largest price differences in comparisons


Find largest price differences in comparisons

Submitted by Nic0904 on Sun, 2016-04-17 12:49 in

Hi David,

I wondered if it would be possible to add a feature that would find the largest price differences for products that have comparisons. Two options either percentage or absolute.

The big advantage of such a feature is

I am pretty sure that comparisons are worked out as a page is loaded so is not a simple DB search, maybe a cron job after import?

Any ideas?

Cheers
Dave

Submitted by support on Mon, 2016-04-18 08:29

Hello Dave,

I'd only really recommend this for a niche site but it's straight forward to add a computed "saving" column to the search query and offer this as a sort option. If you wanted to give this a go, edit search.php and make a Search and Replace as follows:

Search:

MIN(price) as minPrice

Replace:

MIN(price) as minPrice,MAX(price) - MIN(price) AS saving

Then look for the following code at line 85:

    $orderByDefault["priceDesc"] = "minPrice DESC";

...and REPLACE with:

    $orderByDefault["priceDesc"] = "minPrice DESC";
    $orderByDefault["saving"] = "saving DESC";

And then the following code at line 95:

    $orderByFullText["priceDesc"] = "minPrice DESC";

...and REPLACE with:

    $orderByFullText["priceDesc"] = "minPrice DESC";
    $orderByFullText["saving"] = "saving DESC";

And finally the following code at line 463:

      $sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
      $banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;

...and REPLACE with:

      $sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
      $sortSaving = ($sort=="saving"?"<strong>".translate("Saving")."</strong>":"<a href='".$sortHREF."saving'>".translate("Saving")."</a>");
      $banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc.", ".$sortSaving;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Nic0904 on Mon, 2016-04-18 17:07

Hi David,

Thanks for that works like a charm and looks great

Cheers
Dave