You are here:  » search page ideas

Active Forum Topics


search page ideas

Submitted by Tobix on Wed, 2020-11-18 12:00 in

Hi,
On the search page I wanted to enrich it with more information.

Currently it is very minimal but, by adding the garments in the database, I wanted to add for example delivery times and subsequently payment methods.
In the meantime, how can we make the first one? The average delivery times for each store? Already in the feed I have these parameters.

Submitted by support on Wed, 2020-11-18 15:00

Hi Tobix,

This has the same consideration as showing the store logo on search results as they are based on a summary query so additional fields would need to be included in the re-query to make sure the parameters displayed are all associated with the same merchant.

The Search Results / Each template doesn't support the "%DB_fieldname%" placeholders however this (in conjunction with the other modifications required) can be added but firstly, although the information you wish to display is in your feeds are you already importing that data having added custom fields to your Price Tapestry installation?

If not, that would be the first step; otherwise let me know when you have the data that you wish to include in the search results being imported and the name of the custom field that you added to the $config_fieldSet array in config.advanced.php and I'll take it from there with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Wed, 2020-11-18 16:36

Yes I already have the data and modified the database + the config.advanced.php file.

I now need to call these files in the search page in the place I want.

Thanks!

Submitted by support on Thu, 2020-11-19 08:48

Hi,

For the Store Logo modification you will have added the following code to pto_search.php

  global $pto_config_databaseTablePrefix;
  $ins = array();
  foreach($pto_searchResults as $row)
  {
    $ins[] = "'".esc_sql($row->name)."'";
  }
  $sql = "SELECT name,merchant FROM `".$pto_config_databaseTablePrefix."products` WHERE name IN (".implode(",",$ins).") ORDER BY name,price";
  $wpdb->query($sql);
  $cheapestMerchants = array();
  foreach($wpdb->last_result as $row)
  {
    if (!isset($cheapestMerchants[$row->name]))
    {
      $cheapestMerchants[$row->name] = $row->merchant;
    }
  }

...REPLACE this with:

  global $pto_config_databaseTablePrefix;
  $ins = array();
  foreach($pto_searchResults as $row)
  {
    $ins[] = "'".esc_sql($row->name)."'";
  }
  $sql = "SELECT name,merchant,custom_field1,custom_field2 FROM `".$pto_config_databaseTablePrefix."products` WHERE name IN (".implode(",",$ins).") ORDER BY name,price";
  $wpdb->query($sql);
  $cheapestMerchants = array();
  $customFields = array();
  foreach($wpdb->last_result as $row)
  {
    if (!isset($cheapestMerchants[$row->name]))
    {
      $cheapestMerchants[$row->name] = $row->merchant;
    }
    $customFields[$row->name] = $row;
  }
  foreach($pto_searchResults as $i => $row)
  {
    foreach($customFields[$row->name] as $k => $v)
    {
      $pto_searchResults[$i]->$k = $v;
    }
  }

Notice in the $sql at line 7 of the replacement custom_field1,custom_field2 in the SELECT field list. Replace these with your actual custom field names as required, and then in your Search Results / Each template (wp-admin > Settings > PriceTapestry.org) use placeholders for example:

%DB_custom_field1%

Hope this helps!

Cheers,
David.
--
PriceTapestry.com