Jump to content

[MODULE] disable other modules on specific pages or enable them


c64girl

Recommended Posts

I was thinking about disabling modules on specific pages. I found that modules hook to head or other hooks but they are not used on main page. The google score is killing me because of this. Is there a module that will be able set on what pages other modiles will run and on what pages modules will not run?

Link to comment
Share on other sites

2 hours ago, Daresh said:

It is a built in feature when editing a specific module attached to a specific hook, take a closer look and you'll find it.

No its not, some modules hook to head instead of checkout. They load .js and .css on all pages instead of the ones they are used at the moment. I have recaptcha module from prestashop store it loads everywhere instead of the pages that it soppose to like register login or checkout, slowing down the page. Same other modules, autors do good modules but they sometime dont think the consequences.

Link to comment
Share on other sites

5 minutes ago, Daresh said:

But a module creator can only assume default controllers are present in the shop, not knowing about other controllers (like the ones from modules). So it's best in my opinion to optimize it manually for each specific situation.

I did, i disable loading the modules on index page if they don't needed there. Because they load some .js and .css slowing down main page

Link to comment
Share on other sites

  • 6 months later...

Hi,

I read the previous messages and I have something related to this.

Could you please give me some hints (with code example) to do the following:

I want to disable the module ps_facetedsearch on particular category pages. Some categories will use the module and others wont. The module is slowing down my pages A LOT even if I don't use the module on that particular page. My store has over 30000 products and a lot of combinations. the module facetedsearch calls a SQL query that takes 11 seconds to finish... 

So how can I check the category ID to disable the module. Is it in the module's code? Where?

Thank you for your help!

Link to comment
Share on other sites

hi @Retro All-Stars

please check my response here:
 


Looks like there's some ongoing problem with Prestashop being targeted by scrappers / AI bots which creates heavy load and essentially overpowers entire stores.

I have been working on multiple stores recently facing the same problem. Some of them were trying to access page with parameter numberPerPage=9999999 which basically made store load all the products data (text content, images, stock info, combinations). 

I already have much better solution than in my comment there. I think I will release a module in a couple of days. It will keep filters working for real people, but will redirect 301 all the bots and scaper activity. This makes layered work perfectly as usual for everyone while reducing strain on the store and the server dramatically. 

Link to comment
Share on other sites

On 3/21/2025 at 7:48 AM, Retro All-Stars said:

Hi,

I read the previous messages and I have something related to this.

Could you please give me some hints (with code example) to do the following:

I want to disable the module ps_facetedsearch on particular category pages. Some categories will use the module and others wont. The module is slowing down my pages A LOT even if I don't use the module on that particular page. My store has over 30000 products and a lot of combinations. the module facetedsearch calls a SQL query that takes 11 seconds to finish... 

So how can I check the category ID to disable the module. Is it in the module's code? Where?

Thank you for your help!

edit template and unselect categories that you do not want faceted search.

tip: when one uses one template for many categories this will slow category page load, consider making templates for different categories, that will help a lot.

Link to comment
Share on other sites

On 3/21/2025 at 1:48 PM, Retro All-Stars said:

Hi,

I read the previous messages and I have something related to this.

Could you please give me some hints (with code example) to do the following:

I want to disable the module ps_facetedsearch on particular category pages. Some categories will use the module and others wont. The module is slowing down my pages A LOT even if I don't use the module on that particular page. My store has over 30000 products and a lot of combinations. the module facetedsearch calls a SQL query that takes 11 seconds to finish... 

So how can I check the category ID to disable the module. Is it in the module's code? Where?

Thank you for your help!

 

 

 

if($this->context->controller->php_self != 'index') {

        $this->context->controller->addJS($this->_path.'views/js/socail_login.js');
        $this->context->controller->addCSS($this->_path.'views/css/front.css');
        $this->context->controller->addCSS($this->_path.'views/font/fontello-codes.css');

} 

This code will cut the loading files js and css on index page, but You can use it to disable module loading funciotns in php file and specify CATEGORY pages.

 

 


It will be something like this, test this:

$currentCategoryId = Tools::getValue('id_category');

$excludedCategories = [421, 525, 444];

if ($currentCategoryId && !in_array($currentCategoryId, $excludedCategories)) {
    
	// here go your code You want to block to load

}

 

Link to comment
Share on other sites

Ok thank you very much for your answers.

I decided to not use the faceted search module at all on my category pages because it makes my site very slow. I will only use it on my search results page. So I will try to create a different layout for this page and see if it works...

Edited by Retro All-Stars (see edit history)
Link to comment
Share on other sites

On 3/27/2025 at 9:34 AM, Retro All-Stars said:

Ok thank you very much for your answers.

I decided to not use the faceted search module at all on my category pages because it makes my site very slow. I will only use it on my search results page. So I will try to create a different layout for this page and see if it works...

yes,  create one template for each major category.  this will speed things  up.   Really the one main feature of PrestaShop is built in faceted search allowing visitor to drill down into catalog on category page....

 

I highly recommend amazzing filters on addons:

https://addons.prestashop.com/en/search-filters/18575-amazzing-filter.html

 

Link to comment
Share on other sites

On 3/28/2025 at 12:29 PM, QuickUpdate.net said:

@Retro All-Stars The faceted search is very slow because it is poorly written and requires to re-index results constantly - there are better alternatives (modules) for filtering products.

what is better alternative, that would be nice to share yes?  I disagree it's poorly written, most admins I have seen create one template for all categories, that has proven to affect performance.  As I recommended form over 10 yers of ps experience, many clients, project, create separate template for each major category.  

Link to comment
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...