You are here:  » 404's when navigating to products

Support Forum



404's when navigating to products

Submitted by jamie on Mon, 2016-11-28 22:10 in

Hi David,

I am setting up another domain using wordpress as the front-end instead of the html version of PT, for the first time.

I have installed PT into "example.com/pt/" and the site is fully functional (I can navigate as per normal)

I have also installed the PTO per the manual, and have created a 'shopping' page with the [pto] code.

When I navigate to "example.com/shopping" I can see the search template in the page, and I can click on Merchant/Categories etc and I can see the correct data.

However, whenever I try to view a product I get back a 404.

Ive tried copying the end part of the url to the wordpress url, so for instance
"example.com/pt/product/xyz.html" becomes
"example.com/shopping/product/xyz.html"
but still get a 404.

Ive not changed any of the permalinks, so the container is still /shopping and products are still in /product/

I also confirm I have taken the Base HREF and Install Path from the /pt/support.php

Any ideas why I wouldnt be able to see products?

Many thanks
Jamie

Submitted by support on Tue, 2016-11-29 11:45

Hi Jamie,

Did you set a container permalink setting (wp-admin > Settings > Permalinks) that does not end in "/" e.g. the "Numeric" option?

That should be all it is as .htaccess appears to be working correctly if /merchant/ , /category/ and /brand/ are all working - let me know if still no joy and I'll check it out further with you of course...

Cheers,
David.
--
PriceTapestry.com

Submitted by jamie on Tue, 2016-11-29 17:09

Hi David,

I confirm that the container permalink is currently set to numeric, so no "/" suffix.

Also, just to add, when I click into 'Brand' and then click on a brand no results display (not a 404 page, but there are just no results). Same with 'category' and 'merchant' links. The URL looks correct though. Everything works on the underlying PT site.

Thanks
Jamie

Submitted by support on Tue, 2016-11-29 17:44

Hello Jamie,

I think this is down to an issue regarding URL decoding which is in place for the queries used for search results and product pages but included as a result of rewrite behaviour in earlier versions of WordPress. To correct this, edit the plugin file pto.php and look for the following code at line 159:

  $pto_q = (isset($pto_q)?pto_common_normalise(urldecode($pto_q),":\."):"");

...and REPLACE with:

  $pto_q = (isset($pto_q)?pto_common_normalise($pto_q,":\."):"");

And then the following code at line 165:

  $pto_product = (isset($pto_product)?pto_common_normalise(urldecode($pto_product)):"");

...and REPLACE with:

  $pto_product = (isset($pto_product)?pto_common_normalise($pto_product):"");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by jamie on Thu, 2016-12-01 20:27

Hi All,

I have found a solution to this - if anybody else is facing this issue I hope the following helps.

The problem is that preg_replace() has been deprecated from PHP 5.5 and my hosting company has upgraded to PHP 7.

To fix this, in file pto_common.php update line 20 and 22 to the following:

  //$text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/e','',$text);
  $text = preg_replace_callback('/[^A-Za-z0-9'.$allow.' ]/',
    function($m) {
      return '';
    }
    ,$text);
  //$text = preg_replace('/[ ]{2,}/',' ',$text);
  $text = preg_replace_callback('/[ ]{2,}/',
    function($m) {
      return ' ';
    }
    ,$text);

Thanks,
Jamie

Submitted by support on Thu, 2016-12-01 20:56

Hello Jamie,

Thanks for your update - apologies for not mentioning this earlier it should have occured to me as I came accross the deprecation warning and corrected this as part of the version 3 development. It's actually only the /e modifier that is deprecated, the function itself is still current, and in fact /e is not necessary in both instances so the fix can be simplified as (pto_common.php) line 20:

  $text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/e','',$text);

...REPLACE with:

  $text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/','',$text);

And line 47:

  $price = preg_replace('/[^0-9\.]/e','',$price);

...REPLACE with:

  $price = preg_replace('/[^0-9\.]/','',$price);

Cheers,
David.
--
PriceTapestry.com