I'm currently learning Magento and have a strange issue with the toolbar/pagination Ajax script.

Custom theme used - BuyShop

I'd usually leave code examples, however, I can't work out which code to target.

Parent category page: domain.com/products.html

Subcategory page: domain.com/products/juico-juicers.html

When on a subcategory page the ajax toolbar/pagination script works perfectly. For example if you click page 2, /products/juico-juicers.html?p=2, it loads perfectly.

When you do the same on the parent category page, /products.html?p=2, it loads incorrectly; I think it's a parsing issue.

Any help on this issue would be great!!!

2 Answers 2


Oh man this is actually funny.
I took a look at the how the ajax works and here it is.

in js/VS/ajaxtoolbar.js there is this line that handles the success of the ajax call and replaces the current products with the the ones returned by the ajax call.


This should work fine if you have only one element with the class category-products. but for that specific category, you also have the class on the body element because magento adds a class to the body depending on the page. For the category pages this class is category-<?php echo $category->getUrlKey() ?> and the url key in your case is 'products'. So you end up with category-products.

The solution would be to change the class name contains the response. Or replace it with an id.

  • haha I now feel stupid. That said, the script seems flawed as naming your parent category 'Products' must be fairly popular Jun 13, 2014 at 14:58
  • @SamHolguin.I don't know how popular it is (I never used it), but you are right. They should have taken this into account. Usually when doing such things you should use id and not rely on class because is dangerous.
    – Marius
    Jun 13, 2014 at 15:05
  • The curious thing is that on subcategory pages, the body class name also contains the category title category-products-category-name
    – Alex Dinca
    Jun 13, 2014 at 15:42
  • yes, but category-products is not the same as category-products-category-name.
    – Marius
    Jun 13, 2014 at 17:25

If you look inside the js/VS/ajaxtoolbar.js file, on line 57, you can see that after the ajax request is finished, the script replaces all blocks with class category-products with thre resulted HTML.

The resulted HTML is only the product list, meaning that only that part of the page should be changed. But if you look inside the <body> tag, you will see that this also has the category-products class name, which means that the entire body of the page will be replaced with the product list block.

Solution: remove the category-products class from the body tag so that the script won't replace the entire page with the AJAX result


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.