Jump to content

Ajax pagination conflict with custom module

Recommended Posts

Hi everyone,

I was hoping to get some pointers on an issue I'm encountering with a custom module and Ajax pagination on PS

I've been working on a module that injects certain <li> items in any given catalogue page listings. For example, if categoryID == XXX, there might be a special discount banner which will be shown as the first <li> item in the list of products when you load the category page.


What's working well:

I'm inserting my custom hook in product-list.tpl, immediately following the "UL#product_list" as shown below. If my CategoryID conditions are met, the module correctly inserts a custom <li> right before the first product <li>.

<ul id="product_list" class="clearfix">
// It checks if CategoryID == X, and if so it inserts a <li>custom content</li> here
{foreach from=$products item=product name=products}
<li>Product 1</li>
<li>Product 2</li>
// etc.


What's not working:

When any given category has more than one page (whether it matches one of my promo CategoryID conditions or not), if you click on a different page (e.g. Page 2), the page gets stuck with the Ajax loading wheel spinning, and it fails to load the next page. It also fails if you try to load directly "Page 2" by using a URL such as <a href="http://mydomain/my-category-name#/page-1">2</a>

Looking at the logs, I get this error:

PHP Fatal error:  Call to undefined method FrontController::getCategory()

My module uses the following code to determine the current category (which works fine when loading the category) but it seems to be clashing with the Ajax pagination script:

$context = Context::getContext();
$category_ID = $context->controller->getCategory()->id;


I am hoping you might have some advice as to what I could do to solve this.

Thank you!


Edited by Nhe
Added more context (see edit history)

Share this post

Link to post
Share on other sites

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More