You are here:  » Search result listing

Support Forum



Search result listing

Submitted by karolisgo on Thu, 2012-01-05 14:30 in

Hi David,

I think that at the top of search results I should have firstly Mapped products (if any, because they are reviewed and confirmed), after those, I want to list resuls by price (higest to lowest) because higest price usually means more interested product.

Is it possible to do such changes as default values in my script?

Thanks,
K.

Submitted by support on Thu, 2012-01-05 16:15

Hi Karolis,

Yes this would be easy to do but for efficiency will require a flag field in the database to show that the product has been mapped.

To do this, first create the new field by applying the following dbmod.php patch:

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `mapped` TINYINT(1) NOT NULL default '0'"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Upload the file, browse to dbmod.php once to add the new field, then delete the file.

Next, in includes/admin.php look for the following comment at line 315:

    /* niche mode */

...and REPLACE with:

    if (isset($admin_importProductMappingsOverrides[$importRecord["name"]]))
    {
      $importRecord["mapped"] = "1";
    }
    else
    {
      $importRecord["mapped"] = "0";
    }
    /* niche mode */

Then in search.php look for the following code at line 10:

  $sort = (isset($_GET["sort"])?$_GET["sort"]:"relevance");

...and REPLACE with:

  $sort = (isset($_GET["sort"])?$_GET["sort"]:"mapped");

Then the following code at line 57:

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

...REPLACE with

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

And finally the following code at line 67:

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

...and REPLACE with:

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

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Thu, 2012-01-05 22:21

Quick and easy solution :) great.

Two issues:

- mapped=1 works only with IMPORT, but it doesnt work with SlowImport. Is it possible to fix that, because I am using slow import for all my feeds;

- I have two mapped products for test reason. Both are marked mapped=1. Black iPad and White iPad, so they should now take first two rows in search results with keyword "ipad". Strange is that White iPad is #1 in results, but Black iPad is around #12. Both went to first page, but priority now is more then strange. Why some products goes upper instead of mapped?

Submitted by support on Fri, 2012-01-06 08:56

Hi Karolisgo,

Early versions of the slow import tool (admin/feeds_import_slow.php) didn't populate the $admin_importProductMappingsOverrides array used by the above modification - if you extract the latest version of that file from the distribution that should be all it is.

Regarding the priority, as it stands the mapped sort has replaced the relevance sort (I assume there are more than just the iPad products mapped) so what you can do is add back the relevance sort after the mapped sort. In the modification above, where you added this line:

    $orderByFullText["mapped"] = "mapped DESC";

...REPLACE that with:

    $orderByFullText["mapped"] = "mapped DESC,relevance DESC";

(relevance sort doesn't apply to the basic search method)

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Fri, 2012-01-06 12:17

Thanks. I've uploaded newest slow import file, will take a look at the results after another import, tomorrow.