You are here:  » URL product page and special characters


URL product page and special characters

Submitted by smartprice24 on Fri, 2017-09-15 10:01 in

Hi David.

2 little question:

1) is possible convert special characters il url product, è,é,ò,à,ì etc.

es. bialetti-0800002-coffee-filter-parti-e-accessori-per-macchina-per-il-caffè

in bialetti-0800002-coffee-filter-parti-e-accessori-per-macchina-per-il-caffe/

and adding / final in url in searchresults

My permalink WP is /%category%/%postname%/

2) is possible add logo merchant in serch results, each product.

Many thanks for support

Submitted by support on Fri, 2017-09-15 11:46

Hi,

Re: 1;

To replace accented vowels with their ASCII equivalents in the normalised_name field (the version of the product name used in URLs) you can use PHP's iconv() function to apply the translation in the normalise functions in both the Price Tapestry and the plugin, and then re-import all feeds for the changes to take effect.

Firstly, in the Price Tapestry installation, edit includes/tapestry.php and look for the following code at line 26:

    $text = preg_replace('/[ ]{2,}/',' ',$text);

...and REPLACE with:

    $text = preg_replace('/[ ]{2,}/',' ',$text);
    setlocale(LC_CTYPE,"en_US.UTF-8");
    $text = iconv("UTF-8","ASCII//TRANSLIT",$text);

And similarly in the plugin, edit pto_common.php and look for the following code at line 22:

    $text = preg_replace('/[ ]{2,}/',' ',$text);

...and REPLACE with:

    $text = preg_replace('/[ ]{2,}/',' ',$text);
    setlocale(LC_CTYPE,"en_US.UTF-8");
    $text = iconv("UTF-8","ASCII//TRANSLIT",$text);

And to automatically append the trailing "/" as your WordPress configuration is doing in the same file look for the following code at line 72:

    return get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html";

...and REPLACE with:

    return get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html/";

Note that the above is for Virtual product pages, if you are using imported product pages an alternative modification is required however in this case the trailing "/" should be appended as per your permalink configuration which is why I wasn't quite sure but if you are using Imported product pages let me know and I'll post the alternative modification...

Re: 2;

To add merchant logos in search results for un-compared results (single merchant), edit pto_search.php and look for the following code at line 384:

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

...and REPLACE with:

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

And then the following code at line 409:

      $pto_searchResults[$k]->rating = $rows3[$product->id]->rating;

...and REPLACE with:

      $pto_searchResults[$k]->rating = $rows3[$product->id]->rating;
      $pto_searchResults[$k]->merchant = $rows3[$product->id]->merchant;

And finally the following code at line 586:

    $each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);

...and REPLACE with:

    global $pto_config_externalPath;
    global $pto_config_logoExtension;
    global $pto_config_externalBaseHREF;
    if ($pto_config_externalPath)
    {
      if (file_exists($pto_config_externalPath."logos/".$row->merchant.$pto_config_logoExtension))
      {
        $merchant_html = "<img border='0' src='".$pto_config_externalBaseHREF."logos/".str_replace(" ","%20",$row->merchant).$pto_config_logoExtension."' />";
      }
    }
    $each = str_replace("%MERCHANT%",$merchant_html,$each);
    $each = str_replace("%PRICE%",$pto_config_currencyHTML.$row->minPrice,$each);

With that in place, from /wp-admin/ > Settings > PriceTapestry.org scroll down to the Search Results / Each template and look for the following content:

  %PRICE%
  <br />

...and REPLACE with:

  %PRICE%
  <br />
  %MERCHANT%
  <br />

Cheers,
David.
--
PriceTapestry.com