Query Strings of a category index or advanced search page

Open to all! Ask other shopowners for help.
Post Reply
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Query Strings of a category index or advanced search page

Post by radhavallabh »

Hi dear ;
If we search for a item or if we click a category the querystring of the urls get passed on to all products listed which seems to make the URLS on the page look odd.
Eg:if i search fruit
?keyword=fruit should get assigned only to the advanced search page link but it gets assigned to the products too-
https://phoenixcart.org/demo/advanced_s ... ords=fruit

Same for the category page the cPath gets assigned as a querystring to all products-
Like in demo- Each product URL has the cPath
https://phoenixcart.org/demo/index.php?cPath=1_3

Please can you help fix this issue??

Thank you in advance;
Very Warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Query Strings of a category index or advanced search page

Post by ecartz »

If you want to change the product listing template links, override the product listing template and change line 62: https://github.com/CE-PhoenixCart/Phoen ... ng.php#L62

E.g.

Code: Select all

      $listing['link'] = Product::build_link($listing['products_id'], []);
would have no extra query parameters.

Note that if you do this, some breadcrumb links will then be broken, as they won't know the previous links to show.

Code: Select all

      $listing['link'] = Product::build_link($listing['products_id'], [])->retain_query_except(['keyword', 'cPath']);
might be somewhat better.
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Query Strings of a category index or advanced search page

Post by radhavallabh »

ecartz wrote: Mon Aug 01, 2022 10:18 am If you want to change the product listing template links, override the product listing template and change line 62: https://github.com/CE-PhoenixCart/Phoen ... ng.php#L62

E.g.

Code: Select all

      $listing['link'] = Product::build_link($listing['products_id'], []);
would have no extra query parameters.

Note that if you do this, some breadcrumb links will then be broken, as they won't know the previous links to show.

Code: Select all

      $listing['link'] = Product::build_link($listing['products_id'], [])->retain_query_except(['keyword', 'cPath']);
might be somewhat better.
Hi dear;

Code: Select all

      $listing['link'] = Product::build_link($listing['products_id'], [])->retain_query_except(['keywords', 'cPath']);
Worked like a charm :D
Thank you so much!!!
Very warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply