Jump to content

PS 1.6 category pagination $p variable incorrect


Jurist

Recommended Posts

Hello,

 

I am trying to write a simple module that adds link rel=prev, next and canonical before </head> closing but I've encountered a problem with $p variable, which I found after using {debug} function.

 

It says that $p value is always 1, no matter on which page of category I am, no matter if this is first main category or page nr 3 it always return value of 1. This stops me from checking the $p value condition.

 

I've found that layered Layered navigation block v2.2.0 changes the address from:

 

mydomain.com/id-category-name?p=2

 

to 

 

mydomain.com/id-category-name#/page-2

 

which caused the problem. When I manually enter mydomain.com/id-category-name?p=2 it says that $p = 2 correctly. When clicked on number 2 on the product page as usual (mydomain.com/id-category-name#/page-2) it says $p = 1 always.

 

I would really appreciate possible solution with this, as it caused duplicate content issue and prevents our store from getting to the top positions of the search results.

 

Link to comment
Share on other sites

I've found temporary resolution to fix $p variable, at the moment I just removed url rewriting from mydomain.com/themes/my-theme/js/modules/blocklayered/blocklayered.js:

 

/*if (typeof(current_friendly_url) === 'undefined')
current_friendly_url = '#';
 
 
$('div.pagination a').not(':hidden').each(function () {
 
if ($(this).attr('href').search(/(\?|&)p=/) == -1)
var page = 1;
else
var page = parseInt($(this).attr('href').replace(/^.*(\?|&)p=(\d+).*$/, '$2'));
 
var location = window.location.href.replace(/#.*$/, '');
$(this).attr('href', location + current_friendly_url.replace(/\/page-(\d+)/, '') + '/page-' + page);
});
*/
 
and now category has proper url and $p domain, there's one more problem: 
 
how to get variable of last page of the category? If there are 100 products spread across 10 category pages, how to check if page is the last one?
 
 
EDIT:
 
Ok, I think I've managed to sort it out, JS changes the URL and $p variable only for user, not for google. Therefore $p variable can be safely used. With Javascript execution blocked, $p variable returned proper value depending on active site. Solution from this topic works well:
 
Edited by Jurist (see edit history)
Link to comment
Share on other sites

  • 2 months later...
  • 9 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...