0

I need two different registration forms on two different websites. I separate websites like:

http://testmagento.devpassion.eu/website1 and http://testmagento.devpassion.eu/website2

And in folder structure:

/magento_folder/website1 and /magento_folder/website2

For now I just copy and change index.php and .htaccess to folders website1 and website2.

Should I copy all files and folders from root to website1 and website2 that corresponding to registration forms or there is some other why to separate this.

Also need register to two different customer group. So should I copy Accountcontroller.php to website1 and website2 folders?

2

So what I gather form your question you want to run 2 shops in the same Magento installation both with different registration forms?

You're using the store code added to the base url approach so just to make sure you have all the basic steps covered to run both stores please check out this page. In short the steps are

  • create a directory for the url addon (in your case website1 and website2)
  • copy the index.php and .htaccess to this directory
  • Change in the index the $mageRunCode to the shops code and $mageRunType to website
  • then create symbolic links for app, errors, includes, js, lib, media, skin and var.

Now for the registration form. You'll have to first set up 2 template directories for the 2 shops. In case the design should look the same I suggest the following setup. Let's say your theme's name is shopperdesign.

- app
  - design
    - frontend
      - shoppersdesign
        - default (this contains all the template files both shops need)
          - template
          [...]
        - shop1
          - template
            - customer
              - form
                - register.phtml
        - shop2
          - template
            - customer
              - form
                - register.phtml

Now in the BE under System > Configuration > Design set up shoppersdesign as the Current package name, depending on the shop shop1 or shop2 for all the fields under theme except Default which should be default.

This way you can edit only the registration form PHTML without having to copy all the template files.

For the AccountController this is a little bit more tricky since only one codebase can be used per Magento installation. I guess you need to add some extra fields to save in the database?

One option would be to copy it to the directory of that store creating the path ./websites1/app/code/core/Mage/Customer/controllers/AccountController.php but that would require you to make symlinkes for ALL the other files and directories that are in any of the subdirectories you've created.

In this case, since you're already editing the forms I would create a createPostAction method and call it createPost2Action. Do this by overwriting/extending the controller in your own extension and adding the method to your controller class. This post by Inchoo will explain more about that.

Now you can edit the registration form to post to domain.com/customer/acoount/createpost2 insteadof domain.com/customer/acoount/createpost.

Now personally I would want to go about extending a controller for this since it's kind of messy. Better to use an observer in my opinion. I did some Googling and seems you're best of using the controller_action_postdispatch_customer_account_createpost event to observe. When this event is triggered the customer is already saved in the database. You could load it by email and perform what ever extra actions you need to do.

your extensions config.xml

<?xml version="1.0"?>
<config>
  <global>
    [...]
    <events>
      <controller_action_postdispatch_customer_account_createpost>
        <observers>
          <extension_customer_observer>
            <type>singleton</type>
            <class>Your_Extension_Model_Observer</class>
            <method>addExtraData</method>
          </extension_customer_observer>
        </observers>
      </controller_action_postdispatch_customer_account_createpost>     
    </events>
    [...]
  </global>
</config>

Your/Extension/Model/Observer.php

class Your_Extension_Model_Observer
{
   public function addExtraData(Varien_Event_Observer $observer)
   {
      $post = Mage::app()->getRequest()->getPost();
      $customer = Mage::getModel('customer/customer')->loadByEmail($post['email']);
      [...]
   }
}

I hope all of the above is a bit helpful to you as I wasn't 100% sure what you were trying to accomplish.

  • thansk for that. it is helpful. – srdan Oct 6 '13 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.