You are here:  » merchant info at the top search results


merchant info at the top search results

Submitted by wilkins on Mon, 2011-03-14 12:19 in

Hi David

Trying to think of a way of getting info for merchant on the top of a page when it is just for that merchant, both on the search and merchant search page. Another way would be a link in the results that link to merchant info. Is this possible.

Brent

Submitted by support on Mon, 2011-03-14 12:30

Hi Brent,

Very easy to do using some merchant info .html files, and then to call them in above the search results for merchant: queries.

First, create a folder on your site:

merchantinfo/

And inside that folder, create files with the exact merchant name (including spaces) as it appears on your site, plus .html, for example

merchantinfo/Merchant Name.html

Then, in search.php, look for where the search results are included towards the end of the file with the following code:

require("html/searchresults.php");

...and REPLACE that with:

if (($parts[0]=="merchant") && ($page==1))
{
  $merchantinfoFilename = "merchantinfo/".$parts[1].".html";
  if (file_exists($merchantinfoFilename))
  {
    require($merchantinfoFilename);
  }
}
require("html/searchresults.php");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by wilkins on Mon, 2011-03-14 12:48

Hi

That works great, could this also be extended to the filter pages ie

search.php?q=shoe&merchantFilter[]=Barratts

Thanks

Brent

Submitted by wilkins on Mon, 2011-03-14 12:51

Hi David

That worked great, could this be extended to the filter system you wrote recently ie

search.php?q=shoe&merchantFilter[]=Barratts

Brent

Submitted by support on Mon, 2011-03-14 13:39

Hi Brent,

Sure - to show the merchantinfo/ text for both merchant: queries or any merchant in merchantFilter, use the following in place of the above replacement:

if (($parts[0]=="merchant") && ($page==1))
{
  $merchantinfoFilename = "merchantinfo/".$parts[1].".html";
  if (file_exists($merchantinfoFilename))
  {
    require($merchantinfoFilename);
  }
}
elseif(count($merchantFilter))
{
  foreach($merchantFilter as $merchant)
  {
    $merchantinfoFilename = "merchantinfo/".$merchant.".html";
    if (file_exists($merchantinfoFilename))
    {
      require($merchantinfoFilename);
    }
  }
}
require("html/searchresults.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2012-10-26 16:24

Greetings,

How would merchant info be shown under the merchant name and before the "Displaying 1 of xxxx" and not after the "Sort by..."?

Thanks!

Submitted by support on Fri, 2012-10-26 16:38

Hi,

Rather than inserting the modification:

if (($parts[0]=="merchant") && ($page==1))
{
  $merchantinfoFilename = "merchantinfo/".$parts[1].".html";
  if (file_exists($merchantinfoFilename))
  {
    require($merchantinfoFilename);
  }
}
elseif(count($merchantFilter))
{
  foreach($merchantFilter as $merchant)
  {
    $merchantinfoFilename = "merchantinfo/".$merchant.".html";
    if (file_exists($merchantinfoFilename))
    {
      require($merchantinfoFilename);
    }
  }
}

...before:

  require("html/searchresults.php");

..instead, insert the code immediately before:

  require("html/banner.php");

...and that will move the included content above the search results header...

Cheers,
David.
--
PriceTapestry.com

Submitted by Convergence on Fri, 2012-10-26 18:03

Hi David,

That places the merchant info text ABOVE the merchant name. Any chance of putting it just below the merchant name?

Thanks!

Submitted by support on Fri, 2012-10-26 18:40

Hi there,

Ah yes - html/banner.php displays both the H2 and H3 areas, so to display the merchant info inbetween the two, the mod needs to go in that file - with a slight change since banner.php is included on other pages also!

In that file, look for the following code at line 5:

<?php if (isset($banner["h3"])) : ?>

...and REPLACE with:

<?php
if (strpos($_SERVER["PHP_SELF"],"search.php")!==FALSE)
{
if (($parts[0]=="merchant") && ($page==1))
{
  $merchantinfoFilename = "merchantinfo/".$parts[1].".html";
  if (file_exists($merchantinfoFilename))
  {
    require($merchantinfoFilename);
  }
}
elseif(count($merchantFilter))
{
  foreach($merchantFilter as $merchant)
  {
    $merchantinfoFilename = "merchantinfo/".$merchant.".html";
    if (file_exists($merchantinfoFilename))
    {
      require($merchantinfoFilename);
    }
  }
}
}
?>
<?php if (isset($banner["h3"])) : ?>

Cheers,
David.
--
PriceTapestry.com

Submitted by Capricorn on Wed, 2012-10-31 18:21

Hi David,

I just found a new Notice, When using this code:

---------------------------------------------------

if (($parts[0]=="merchant") && ($page==1))
{
$merchantinfoFilename = "merchantinfo/".$parts[1].".html";
if (file_exists($merchantinfoFilename))
{
require($merchantinfoFilename);
}
}
elseif(count($merchantFilter))
{
foreach($merchantFilter as $merchant)
{
$merchantinfoFilename = "merchantinfo/".$merchant.".html";
if (file_exists($merchantinfoFilename))
{
require($merchantinfoFilename);
}
}
}

---------------------------------------------------

I got everything working fine with that code on the first page of results of any merchant, but if I click next, or any number of the navigation links, or do any other search, I get this Notice.

Notice: Undefined variable: merchantFilter in F:\xampp\htdocs\store\search.php on line 504

Line 504 on my search.php have this code:

elseif(count($merchantFilter))

Remember that I only get Notice when I remove the "// error_reporting(E_ERROR);"

Otherwise I don't see no Notice errors and the code works as it's.

I was thinking that maybe it's some "isset" mising somewhere?

Thanks.

Submitted by support on Thu, 2012-11-01 08:36

Hi,

That will be this line:

elseif(count($merchantFilter))

...replace with:

elseif(isset($merchantFilter) && count($merchantFilter))

Cheers!
David.
--
PriceTapestry.com

Submitted by Convergence on Sat, 2013-01-26 22:46

Hi David,

Apologies for the delay in responding to your assistance.

Unfortunately, this adds the merchant info directly after "(Displaying 1 to xx of xxx)" and not directly after the merchant name itself [in between the merchant name and (Displaying 1 to xx of xxx)].

Thanks!

Submitted by support on Sun, 2013-01-27 10:15

Hi,

It can be combined with the H2 banner, no problem! Instead of making the change in html/banner.php, back in search.php look for where the first part of that line is generated by this code around line 277:

$banner["h2"] = translate("Product search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong>&nbsp;";

...and REPLACE with:

$banner["h2"] = translate("Product search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong>&nbsp;";
if (($parts[0]=="merchant") && ($page==1))
{
  $merchantinfoFilename = "merchantinfo/".$parts[1].".html";
  if (file_exists($merchantinfoFilename))
  {
    $banner["h2"] .= file_get_contents($merchantinfoFilename);
  }
}
elseif(count($merchantFilter))
{
  foreach($merchantFilter as $merchant)
  {
    $merchantinfoFilename = "merchantinfo/".$merchant.".html";
    if (file_exists($merchantinfoFilename))
    {
      $banner["h2"] .= file_get_contents($merchantinfoFilename);
    }
  }
}

Hope i've understood correctly, let me know if still not quite right of course!

Cheers,
David.
--
PriceTapestry.com