Hi i just created custom module in magento and its frontend doesn't work.
The config file :
<?xml version="1.0"?>
<config>
<modules>
<Shareino_Sync>
<version>0.1.0</version>
</Shareino_Sync>
</modules>
<global>
<helpers>
<sync>
<class>Shareino_Sync_Helper</class>
</sync>
</helpers>
<blocks>
<sync>
<class>Shareino_Sync_Block</class>
</sync>
</blocks>
</global>
<frontend>
<routers>
<sync>
<use>standard</use>
<args>
<module>Shareino_Sync</module>
<frontName>shareinosync</frontName>
</args>
</sync>
</routers>
<layout>
<updates>
<sync>
<file>shareino_front.xml</file>
</sync>
</updates>
</layout>
</frontend>
</config>
The layout file :
# File in : app/design/frontend/default/default/layout/shareino_front.xml
<layout version="0.1.0">
<sync_index_index>
<reference name="content">
<block type="sync/sync" name="sync" template="sync_index.phtml" />
</reference>
</sync_index_index>
</layout>
And sync_index.phtml :
# file in app/design/frontend/default/default/template/sync_index.phtml
<h1>
Test Text
</h1>
I created a block that named Sync.php
class Shareino_Sync_Block_Sync extends Mage_Core_Block_Template
{
public function myfunction()
{
return "Hello tuts+ world";
}
}
At the end my controller :
class Shareino_Sync_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction(){
$this->loadLayout();
$this->renderLayout();
}
public function testAction(){
echo "index Action";
}
}
I think i done every think well , but when i load the action url in browser it doesn't my layout. please help me to know my wrong.
Check your current theme, maybe it is not default/default. If it is different, just place layout and templates under this theme. Or put it into base/default theme for compatibility with all themes.
Make sure the module is registered in app/etc/modules/Shareino_Sync.xml.
And the last, maybe your module is disabled for output. Goes to System->Configuration->Advanced->Advanced->Disable Module Output find your module and make sure it is enabled.
you should always put your module layout files AND template files under base/default the reason is because the fallback theme mechanism of Magento first look for those files in your_package/your_theme then under your_package/default then under base/default. So if you put those files under default/default and your package is not default those files will never be found
Related
I'm working on a custom module to display CMS content. I have a custom front controller which is working as expected. I'm able to call various front actions from the controller. I am using an existing template, which is also displaying as it should. I'm also loading a layout update xml file, from which I was able to remove the product menu, which I don't need, and add a reference block for my custom block's template file.
I know the correct template override file is loading, as I'm testing with the following:
<?php echo __FILE__ . " loaded <br>"; ?>
Which is echoing the correct filename.
However, when I call my custom block method from that same template file, I get nothing.
My module namespace/module is Cmpreshn/Projects. Following is what I have so far:
Config file in
app/code/local/Cmpreshn/Projects/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Cmpreshn_Projects>
<version>0.1.0</version>
</Cmpreshn_Projects>
</modules>
<frontend>
<routers>
<projects>
<use>standard</use>
<args>
<module>Cmpreshn_Projects</module>
<frontName>education</frontName>
</args>
</projects>
</routers>
<layout>
<updates>
<projects>
<file>projects.xml</file>
</projects>
</updates>
</layout>
</frontend>
<global>
<blocks>
<projects>
<class>Projects_Block_List</class>
</projects>
</blocks>
</global>
</config>
Front controller in
app/code/local/Cmpreshn/Projects/controllers/ProjectsController.php
<?php
class Cmpreshn_Projects_ProjectsController extends Mage_Core_Controller_Front_Action {
public function indexAction(){
$this->listAction();
}
public function listAction(){
echo "list action called<br>";
/* get request and save params to object */
$this->request = Mage::app()->getRequest();
/* layout overrides for this module in app/design/frontend/default/pmc1/layout/projects.xml */
$this->loadLayout();
/* use the education template */
$this->getLayout()->getBlock("root")->setTemplate("page/pmc_education.phtml");
/* render the layout */
$this->renderLayout();
}
}
XML updates in
app/design/frontend/default/pmc1/layout/projects.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<projects_projects_list>
<remove name="top.menu"/>
<reference name="content">
<block type="page/html" name="page" template="cmpreshn/projects/list.phtml" />
</reference>
</projects_projects_list>
</layout>
Template overrides and call to custom block in
app/design/frontend/default/pmc1/template/cmpreshn/project/list.phtml
<?php echo __FILE__ . " loaded <br>"; ?>
<?php echo $this->getProjectsList(); ?>
Last but not least, my custom block class in
app/code/local/Cmpreshn/Proejcts/Block/List.php
<?php
class Cmpreshn_Projects_Block_List extends Mage_Core_Block_Template {
public function _construct() {
parent::__construct();
echo "projects list block constructor called<br>";
} // end constructor
public function getProjectsList() {
echo "getProjectsList called <br>";
return("getProjectsList called");
}
} // end class
As I mentioned previously, I am getting the output from the first line of my list.phtml template file, but no output from my custom block method, and no indication that my block is loading (no output from block _construct() method either )
Any help is appreciated. I'm ready to pull my eyes out over this...
I just observed your code and found the following errors:
Registeration of block in registering module file (config.xml) seems wrong.
<global>
<blocks>
<projects>
<class>Cmpreshn_Projects_Block</class> <!-- Not Projects_Block_List -->
</projects>
</blocks>
</global>
The type attribute is wrong in Block element of layout file (projects.xml). You should not call page/html instead you should call projects/list.
There might be more typos. but I could found the above two only. I hope this solves your problem.
change the block type to projects/list in your projects.XML file like this
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<projects_projects_list>
<remove name="top.menu"/>
<reference name="content">
<block type="projects/list" name="page" template="cmpreshn/projects/list.phtml/>
</reference>
</projects_projects_list>
</layout>
you may get the output now.
I've got an issue with Magento xml layouts. I've been trying to change the page template when a customer is logged in, but only for specific pages in the layout. I've tried using the <customer_logged_in> handle in my xml but I can't get it to reference another handle specifically.
Non-working example of what I'd like it to do:
<catalog_product_view>
<customer_logged_in>
<reference name="root">
<action method="setTemplate"><template>page/3columns.html</template></action>
</reference>
</customer_logged_in>
<customer_logged_out>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.html</template></action>
</reference>
</customer_logged_out>
</catalog_product_view>
Is this possible to accomplish with the XML layout system or should I be looking at another approach?
Unfortunately with Magento layouts, there is no way to filter between two layout handles.
What I would recommend is slightly different and more complex, but I believe that it will give you the flexibility that you need.
You will need to create a module to do this. I am including all code necessary to do this.
Module Definition:
app/etc/Your_Module.xml
<config>
<modules>
<Your_Module>
<codePool>local</codePool>
<active>true</active>
</Your_Module>
</modules>
</config>
Config XML:
app/code/local/Your/Module/etc/config.xml:
<config>
<global>
<modules>
<Your_Module>
<version>1.0</version>
</Your_Module>
</modules>
</global>
<frontend>
<controller_action_layout_generate_blocks_after>
<observers>
<your_module_name>
<type>singleton</type>
<class>Your_Module/Observer</class>
<method> controllerActionLayoutGenerateBlocksAfter</method>
</your_module_name>
</observers>
</controller_action_layout_generate_blocks_after>
</frontend>
</config>
The code that makes it work
Then at this path app/code/local/Your/Module/Model/Observer.php:
<?php
class Your_Module_Model_Observer
{
public function controllerActionLayoutGenerateBlocksAfter ($observer)
{
$controller = $observer->getAction();
if ($controller->getFullActionName() == 'catalog_product_view') {
$layout = $controller->getLayout();
$rootBlock = $layout->getBlock('root');
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
$rootBlock->setTemplate('page/1-column.html');
} else {
$rootBlock->setTemplate('page/2-columns.html');
}
}
}
}
(I took a few tips from: update layout programatically in magento event observer)
I would like to do the above.
Ive overridden many files in the past...block, model, helper....but this one eludes me.
Can anyone see what im doing wrong here:
(ive edited this code...to include some of the recomendations now...)
Heres my folder structure (2 controller locations as a test):
/Idigital/Idgeneral/etc/config.xml
/Idigital/Idgeneral/controllers/Checkout/CartController.php
/Idigital/Idgeneral/controllers/CartController.php
Heres my config.xml:
<?xml version="1.0"?>
<config>
<modules>
<idigital_idgeneral>
<version>0.1.0</version>
</idigital_idgeneral>
</modules>
<global>
<blocks>
<idgeneral><class>Idigital_Idgeneral_Block</class></idgeneral>
</blocks>
</global>
<frontend>
<routers>
<checkout>
<use>standard</use>
<args>
<modules>
<Idigital_Idgeneral before="Mage_Checkout">Idigital_Idgeneral_Checkout</Idigital_Idgeneral>
</modules>
</args>
</checkout>
</routers>
<layout>
<updates>
<idgeneral>
<file>idigital.xml</file>
</idgeneral>
</updates>
</layout>
</frontend>
</config>
Ihave placed my controller file in 2 locations to test.
And heres the top of my FIRST controller file:
require_once 'Mage/Checkout/controllers/CartController.php';
class Idigital_Idgeneral_Checkout_CartController extends Mage_Checkout_CartController
{
public function testAction()
{
var_dump('inside checkout/cart/test');exit;
}
/**
* Add product to shopping cart action
*/
public function addAction()
{
blah...
}
Ans my second controller:
require_once 'Mage/Checkout/controllers/CartController.php';
class Idigital_Idgeneral_CartController extends Mage_Checkout_CartController
{
public function testAction()
{
var_dump('inside cart/test');exit;
}
/**
* Add product to shopping cart action
*/
public function addAction()
{
blah...
}
When i visit: /checkout/cart/add
Im directed to the mage controller...not my local. (i have var_dump stmts in each..so i can see which is ran).
When i visit /checkout/cart/test - i get a 404
When i visit /cart/add or cart/test - i get a 404
when i visit idgeneral/cart/test or idgeneral/cart/add - i get a 404
Create your module folders and files
app/code/local/MyNameSpace/MyModule/etc/config.xml
app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php
app/etc/modules/MyNameSpace_All.xml
Edit /etc/config.xml and Create app/code/local/MyNameSpace/MyModule/etc/config.xml with the following content:
<?xml version="1.0"?>
<config>
<modules>
<MyNameSpace_MyModule>
<version>0.1.0</version>
</MyNameSpace_MyModule>
</modules>
<global>
<!-- This rewrite rule could be added to the database instead -->
<rewrite>
<!-- This is an identifier for your rewrite that should be unique -->
<!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
<mynamespace_mymodule_checkout_cart>
<from><![CDATA[#^/checkout/cart/#]]></from>
<!--
- mymodule matches the router frontname below
- checkout_cart matches the path to your controller
Considering the router below, "/mymodule/checkout_cart/" will be
"translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
-->
<to>/mymodule/checkout_cart/</to>
</mynamespace_mymodule_checkout_cart>
</rewrite>
</global>
<!--
If you want to overload an admin controller this tag should be <admin> instead,
or <adminhtml> if youre overloading such stuff (?)
-->
<frontend>
<routers>
<mynamespace_mymodule>
<!-- should be set to "admin" when overloading admin stuff (?) -->
<use>standard</use>
<args>
<module>MyNameSpace_MyModule</module>
<!-- This is used when "catching" the rewrite above -->
<frontName>mymodule</frontName>
</args>
</mynamespace_mymodule>
</routers>
</frontend>
Note: The above didn’t work for me when I override catalog/product controller. I had to use:
<from><![CDATA[#^catalog/product/#]]></from>
<to>mymodule/mycontroller</to>
(notice the missing leading slash)
Since Magento 1.3 you can simply add your module to the frontend router. Rewrites are not neccessary any more:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<MyNameSpace_MyModule>
<version>0.1.0</version>
</MyNameSpace_MyModule>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<MyNameSpace_MyModule before="Mage_Checkout">MyNameSpace_MyModule</MyNameSpace_MyModule>
</modules>
</args>
</checkout>
</routers>
</frontend>
Please note that before=”Mage_Checkout” will load your controller first if available and fall back to Magento’s if not.
If the controller is in another folder, you’ll have to modify the code:
app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php.
Replace
<MyNameSpace_MyModule before="Mage_Checkout">MyNameSpace_MyModule</MyNameSpace_MyModule>
with
<MyNameSpace_MyModule before="Mage_Checkout">MyNameSpace_MyModule_Checkout</MyNameSpace_MyModule>
Edit 'controllers/Checkout/CartController.php'
Create app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php with the following content: (the only change to indexAction() is adding an error_log() call):
<?php
# Controllers are not autoloaded so we will have to do it manually:
require_once 'Mage/Checkout/controllers/CartController.php';
class MyNameSpace_MyModule_Checkout_CartController extends
Mage_Checkout_CartController
{
# Overloaded indexAction
public function indexAction() {
# Just to make sure
error_log('Yes, I did it!');
parent::indexAction();
}
}
Edit 'app/etc/modules/MyNameSpace_All.xml'
(This is to activate your module)
true
local
Edit 'app/design/frontend/[myinterface]/[mytheme]/layout/checkout.xml' and add the following to use the same update handle as before:
<mynamespace_mymodule_checkout_cart_index>
<update handle="checkout_cart_index"/>
</mynamespace_mymodule_checkout_cart_index>
(Note that these tags seem to be case sensitive. Try using all lowercase if this isn’t working for you)
[by Hendy: When I override catalog/product/view using the method described in this Wiki or here, I didn’t have to do the above. However, when using the 'cms way', I had to update the handle manually.]
The above item did not work for me (2009-02-19 by Jonathan M Carvalho)
I discovered that the file to change is app/design/frontend/[myinterface]/[mytheme]/layout/mymodule.xml
Add the following lines:
Point your browser to /checkout/cart/
In your PHP error log, you should find ‘Yes, I did it!’.
You need to be extra precise with the rewrite regular expression because errors are very hard to find.
<Idigital_Idgeneral before="Mage_Checkout">Idgeneral_Checkout</Idigital_Idgeneral>
Should be
<Idigital_Idgeneral before="Mage_Checkout">Idigital_Idgeneral_Checkout</Idigital_Idgeneral>
or try moving your custom controller up to
../Idigital/Idgeneral/controllers/CartController.php
and use
<Idigital_Idgeneral before="Mage_Checkout">Idigital_Idgeneral</Idigital_Idgeneral>
There is also an error in your <modules> tag location. It should be:
<config>
<modules>
<idigital_idgeneral>
<version>0.1.0</version>
</idigital_idgeneral>
</modules>
<global>
...
</global>
<frontend>
....
</frontend>
...
</config>
i.e <modules> shouldn't be inside <global>
Here's a good tutorial on how to dump the config tree that Magento sees as XML: http://alanstorm.com/magento_config
I'm leaving this here for the next poor developer forced to work with this jalopy. Much of the instructions here are pasted from the magento docs which like its source, is a twisted labyrinth of misdirection. Okay enough complaints...
This worked for me in version 1.8
Create your namespace and module:
/app/code/local/MyNameSpace/MyModule
Create your module config:
/app/code/local/MyNameSpace/MyModule/etc/config.xml
<?xml version="1.0" ?>
<config>
<modules>
<MyNameSpace_MyModule>
<version>0.1.0</version>
</MyNameSpace_MyModule>
</modules>
<frontend>
<routers>
<checkout>
<args>
<modules>
<MyNameSpace_MyModule before="Mage_Checkout">MyNameSpace_MyModule_Checkout</MyNameSpace_MyModule>
</modules>
</args>
</checkout>
</routers>
</frontend>
Create your controller:
/app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php
<?php
require_once Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'CartController.php';
class MyNameSpace_MyModule_Checkout_CartController extends Mage_Checkout_CartController
{
public function indexAction() {
// /var/log/debug.log should log the output
Mage::log('cart index override', null, 'debug.log');
// Call the parent class
parent::indexAction();
}
}
Enable your new module:
/app/etc/modules/MyNameSpace_All.xml
<?xml version="1.0" ?>
<config>
<modules>
<MyNameSpace_MyModule>
<active>true</active>
<codePool>local</codePool>
</MyNameSpace_MyModule>
</modules>
</config>
That's all thats needed. Now go celebrate, you just polished a turd! ;)
This is a little notification on the include path of the controller.
This include path can cause errors if the Magento Compiler mode is turned on.
require_once 'Mage/Checkout/controllers/CartController.php';
Instead of that it is good to use
require_once Mage::getModuleDir('controllers', 'Mage_Checkout').DS.'CartController.php';
It will be safer.
Well...it WONT override the checkout cart controller.
So i used the URL REWRITE in the PRODUCT VIEW...from this link...near the bottom of the article. They say its a proper method...
http://www.excellencemagentoblog.com/magento-add-product-to-cart-ajax
if(!url){
url = jQuery('#product_addtocart_form').attr('action');
}
url = url.replace("checkout/cart","idgeneral/cart");
That worked for me. Allows me to get cracking. Basically calls MY controller..instead of checkout controller.
Thanks for the help ROSCIUS...appreciated.
I also had to change my config....my routers section now looks like this:
<routers>
<!-- THIS PART REGISTERS OUR CONTROLLERS FOLDER FOR USE -->
<idgeneral>
<use>standard</use>
<args>
<module>Idigital_Idgeneral</module>
<frontName>idgeneral</frontName>
</args>
</idgeneral>
<!-- THIS PART WONT WORK TO OVERWRITE OUR MAGE CONTROLLER -->
<checkout>
<use>standard</use>
<args>
<modules>
<Idigital_Idgeneral before="Mage_Checkout">Idigital_Idgeneral_Checkout</Idigital_Idgeneral>
</modules>
</args>
</checkout>
</routers>
I'm building a Controller and when I call an Action I get a 404 Error (everything worked last week!). I'm calling the action using:
http://www.website.com/route/controllername/actionname
eg:
http://www.website.com/abcdef/test/echo
I have investigated the problem (using Mage::log('..')) and found out that the controller is being loaded. The controller's name is fine too. Further investigation revealed that the noRouteAction within my controller is being called.
ie my controller contains:
public function noRouteAction() {
echo "noRoute Action";
}
public function echoAction() {
echo "Echo Action";
}
When I call http://www.website.com/abcdef/test/echo I get "noRoute Action".
Why isn't echoAction being called?
Edit:
The config.xml
<?xml version="1.0"?>
<config>
<modules>
<Abcdef_Web>
<version>1.0.0</version>
</Abcdef_Web>
</modules>
<global>
<helpers>
<abcdef>
<class>Abcdef_Web_Helper</class>
</abcdef>
</helpers>
<blocks>
<abcdef>
<class>Abcdef_Web_Block</class>
</abcdef>
</blocks>
</global>
<frontend>
<routers>
<abcdef>
<use>standard</use>
<args>
<module>Abcdef_Web</module>
<frontName>abcdef</frontName>
</args>
</abcdef>
</routers>
<layout>
<updates>
<abcdef>
<file>abcdef.xml</file>
</abcdef>
</updates>
</layout>
</frontend>
</config>
The controller class file: (TestController.php)
<?php
class Abcdef_Web_TestController extends Mage_Core_Controller_Front_Action {
public function noRouteAction() {
echo "noRoute Action";
}
public function echoAction() {
echo "Echo Action";
}
}
?>
OK found the problem!!!!
It seems that "Add Store Code to Urls" was set to yes, so Magento was expecting:
http://www.website.com/storecode/abcdef/test/echo
rather then:
http://www.website.com/abcdef/test/echo
For those with the same problem. This can be disabled through:
System / Configuration / General / Web / Url Options / Add Store Code to Urls
Note:
I do not remember setting this option to Yes. I've seen some reports that this setting could be changing automatically (4 people reporting it):
http://www.magentocommerce.com/boards/viewthread/192613/
As titled.
But still, users can login to the frontend, and administrator could create user account only in backend.
Another possibility would be overloading the customer/account/create action and just redirect the user to the home page when this action is invoked.
In a first time, just do what was proposed by Ben V. It will remove the possibility to view the registration page.
Then, create a new module in which you will overload the AccountController.php.
1- Create a new folder in app/code/local/ named Mycompany
2- Create a new folder in app/code/local/Mycompany/ named Registrationremove
3- Create app/code/local/Mycompany/Registrationremove/etc/
4- Create app/code/local/Mycompany/Registrationremove/etc/config.xml
Copy and Paste in config.xml :
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Registrationremove>
<version>0.1.0</version>
</Mycompany_Registrationremove>
</modules>
<global>
<rewrite>
<mycompany_registrationremove_customer_account_create>
<from><![CDATA[#^/customer/account/create/$#]]></from>
<to>/registrationremove/customer_account/create</to>
</mycompany_registrationremove_customer_account_create>
<mycompany_registrationremove_customer_account_createPost>
<from><![CDATA[#^/customer/account/createPost/$#]]></from>
<to>/registrationremove/customer_account/createPost</to>
</mycompany_registrationremove_customer_account_createPost>
</rewrite>
</global>
<frontend>
<routers>
<registrationremove>
<use>standard</use>
<args>
<module>Mycompany_Registrationremove</module>
<frontName>registrationremove</frontName>
</args>
</registrationremove>
</routers>
</frontend>
</config>
5- Create app/code/local/Mycompany/Registrationremove/controllers
6- Create app/etc/modules/Mycompany_Registrationremove.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Registrationremove>
<active>true</active>
<codePool>local</codePool>
</Mycompany_Registrationremove>
</modules>
</config>
7- Create app/code/local/Mycompany/Registrationremove/controllers/Customer/AccountController.php
Copy and Paste in AccountController.php:
require_once 'Mage/Customer/controllers/AccountController.php';
class Mycompany_Registrationremove_Customer_AccountController extends Mage_Customer_AccountController
{
public function createAction()
{
$this->_redirect('*/*');
}
public function createPostAction()
{
$this->_redirect('*/*');
}
}
8- Create app/code/local/Mycompany/Registrationremove/Helper/Data.php
Copy and paste in Data.php:
class Mycompany_Registrationremove_Helper_Data extends Mage_Core_Helper_Abstract
{
}
Now, when someone tries to access to customer/account/create/ it should be redirected to the home page.
Hope that helped :)
Hugues.
You could modify the login screen to remove the "Create New Account" button. This way existing users can still log in but they have no way to create new accounts.
The file to modify is /app/design/frontend/default/default/template/customer/form/login.phtml. Around line 41 you'll see <div class="col-1 new-users">. Comment out that entire div to hide the New User section of the login page.
Edit:
There is no way to just disable new user registration like you are asking. I did a little more searching, and all I found were several people with the same idea as mine. In addition to my original suggestion, I would
a) remove the <customer_account_create> section of /app/design/frontend/default/default/layout/custom.xml, and
b) remove the registration-related lines from /app/design/frontend/default/default/template/checkout/onepage/login.phtml.
Ok. I got it worked. Refer to Hugues Solution, there are two amendments:
add app\etc\modules\Mycompany_All.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Registrationremove>
<active>true</active>
<codePool>local</codePool>
</Mycompany_Registrationremove>
</modules>
</config>
modify the file: app/code/local/Mycompany/Registrationremove/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Registrationremove>
<version>0.1.0</version>
</Mycompany_Registrationremove>
</modules>
<global>
<rewrite>
<mycompany_registrationremove_customer_account_create>
<from><![CDATA[#^/customer/account/create/$#]]></from>
<to>/registrationremove/customer_account/create</to>
</mycompany_registrationremove_customer_account_create>
<mycompany_registrationremove_customer_account_createPost>
<from><![CDATA[#^/customer/account/createPost/$#]]></from>
<to>/registrationremove/customer_account/createPost</to>
</mycompany_registrationremove_customer_account_createPost>
</rewrite>
</global>
<frontend>
<routers>
<mycompany_registrationremove>
<use>standard</use>
<args>
<module>Mycompany_Registrationremove</module>
<frontName>registrationremove</frontName>
</args>
</mycompany_registrationremove>
</routers>
</frontend>
</config>
In the above example structure, the controller class name should be changed
from
class Mycompany_Registrationremove_AccountController extends Mage_Customer_AccountController
to
class Mycompany_Registrationremove_Customer_AccountController extends Mage_Customer_AccountController
Does this method works for ver. 1.4.1.1?
Finally I decided to skip all the complicated steps and also modify the register.phtml in \app\design\frontend\base\default\template\customer\form, apart from the files that BenV said.
I deleted the form and changed the title to "User registration disabled" :)
I couldn't get any of the solutions posted here to work, and found I had to use the following syntax in the config.xml (specifically frontend routers syntax):
<?xml version="1.0"?>
<config>
<modules>
<Mycompany_Registrationremove>
<version>0.1.0</version>
</Mycompany_Registrationremove>
</modules>
<global>
<rewrite>
<mycompany_registrationremove_customer_account_create>
<from><![CDATA[#^/customer/account/create/$#]]></from>
<to>/registrationremove/customer_account/create</to>
</mycompany_registrationremove_customer_account_create>
<mycompany_registrationremove_customer_account_createPost>
<from><![CDATA[#^/customer/account/createPost/$#]]></from>
<to>/registrationremove/customer_account/createPost</to>
</mycompany_registrationremove_customer_account_createPost>
</rewrite>
</global>
<frontend>
<routers>
<customer>
<args>
<modules>
<Mycompany_Registrationremove before="Mage_Customer">Mycompany_Registrationremove_Customer</Mycompany_Registrationremove>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
There's more info on this method here - http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller
One could always change the customer router to point to a module without controllers, e.g.
<frontend>
<routers>
<customer>
<args>
<module>MyModule_NullRouting</module>
</args>
</customer>
</routers>
</frontend>
As an extension to liquidity's answer, a couple more changes I'd make to improve this. Firstly the regex doesn't match the url if it does not have a trailing slash eg. customer/account/create. To correct, the "from" nodes should read <![CDATA[#^/customer/account/create(/.*)?$#]]> and <![CDATA[#^/customer/account/createPost(/.*)?$#]]>.
Secondly, I've included an observer that listens for the customer_registration_is_allowed event (this gets called in persistent/customer/form/login.phtml when using the RWD theme from the $this->helper('customer')->isRegistrationAllowed() function):
<events>
<customer_registration_is_allowed>
<observers>
<your_module_set_is_active>
<class>Your_Module_Model_Observers_Customer</class>
<method>disableCustomerRegistration</method>
</your_module_set_is_active>
</observers>
</customer_registration_is_allowed>
</events>
Then in the observer:
class Your_Module_Model_Observers_Customer
{
/**
* Force disable customer registration
*
* #param Varien_Event_Observer $observer Observer
* #return void
*/
public function disableCustomerRegistration($observer)
{
$result = $observer->getResult();
if ($result->getIsAllowed() === true) {
$result->setIsAllowed(false);
}
}
}
This sets allowing registration to false and prevents the registration form showing without any template modifications.
Hope this is helpful!