Jump to content

Override Prestashop Module Controller: Where to place php file?


sqzr

Recommended Posts

Hello

 

I am attempting to override a module in Prestashop. I have successfully overridden the modules' templates but I cannot successfully overwrite the modules' controller.

 

Where should the new controller class file be placed?

 

I have tried the following locations but they dont add new behaviour (change anything):

 

~/overrides/modules/blockwishlist/controllers/front/mywishlist.php

~/themes/MY_THEME/modules/blockwishlist/controllers/front/mywishlist.php

 

According to my previous question I could do it by editing core classes (suggested kindly by u/Sergii P) but I am sure there is a standard way to do this that doesn't involve editing core classes?

 

For reference; here is the contents of mywishlist.php:

<?php

if (!defined('_CAN_LOAD_FILES_'))
	exit;
 
//class BlockWishListMyWishListModuleFrontController extends BlockWishListMyWishListModuleFrontControllerCore // extends ModuleFrontController
class BlockWishListMyWishListModuleFrontControllerOverride extends BlockWishListMyWishListModuleFrontController
{

	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Assign wishlist template
	 */
	public function assign()
	{
		$errors = array();

		....

		$this->setTemplate('mywishlist.tpl');
	}

}

Edited by sqzr (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

So the answer is that you cannot override a modules controller file, correct?

 

Thats correct. You can still achieve what you want - custom functionality in a core module - using the method I describe in the blog post

Link to comment
Share on other sites

Thats correct. You can still achieve what you want - custom functionality in a core module - using the method I describe in the blog post

That's fine, however this topic was specifically opened asking how to override a modules controller.  So I wanted to make sure it is clear for users viewing this thread, that the answer is... It is NOT possible.

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