'Overriding CsMarketplace account controller with a custom controller
I've seen lots of code available to override core Magento files, but not any Magento plugin files.
I have installed the CsMarketplace plugin to my website for vendor management, and I want to override the vendor - register function to write my custom code which needs to work just after vendor is successfully registered.
I Need to override: function createPostAction();
in file mypoject/app/code/local/Ced/CsMarketplace/controllers/AccountController.php
File 1: mypoject/app/code/local/Core/Ced/CsMarketplace/controllers/AccountController.php
require_once 'app/code/local/Ced/CsMarketplace/controllers/AccountController.php';
class Core_Ced_CsMarketplace_AccountController extends Ced_CsMarketplace_Controller_AbstractController {
/**
* Create customer account action
*/
public function createPostAction() {
//my custom code
}
}
File 2: mypoject/app/code/local/Core/Ced/CsMarketplace/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Core_Ced_CsMarketplace>
<version>1.0</version>
</Core_Ced_CsMarketplace>
</modules>
<frontend>
<routers>
<CsMarketplace>
<args>
<modules>
<Core_Ced_CsMarketplace before="Ced_CsMarketplace">Core_Ced_CsMarketplace</Core_Ced_CsMarketplace>
</modules>
</args>
</CsMarketplace>
</routers>
</frontend>
</config>
File 3: mypoject/app/etc/modules/Core_All.xml
<?xml version="1.0"?>
<config>
<modules>
<Core_Customer>
<active>true</active>
<codePool>local</codePool>
</Core_Customer>
<Core_Ced_CsMarketplace>
<active>true</active>
<codePool>local</codePool>
</Core_Ced_CsMarketplace>
</modules>
</config>
Solution 1:[1]
Your controller is incorrectly placed in the filesystem. Magento always assumes that controllers located somewhere under a controllers
directory which is itself exactly inside just a Namespace + Modulename folder, e.g.
app/code/[codepool]/[Namespace]/[Modulename]/controllers/ # I previously missed the codepool, because Magento 2 :-)
You are trying to get the system to locate controllers in a location where it by design cannot locate them.
(edit based on OP comment)
Controllers need two levels of depth (namespace + module name). The following won't work:
app/code/local/Namespace/controllers
app/code/local/Namespace/Modulename/SomeOtherFolder/controllers
In your case, you may choose CustomCed
as your namespace, giving:
app/code/local/CustomCsd/CsMarketplace/controllers/AccountController.php
In there you will override createPostAction()
.
Also, depending on what you are doing, you could possibly use one of the dynamic events which exist around controller action dispatching.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Community |