Magento DSGVO Kontaktform

If, as part of the new EU General Data Protection Regulation (GDPR) coming into force, you want to modify the Magento contact form so that the name is no longer a required field and instead becomes an optional field, there are a few things to consider. First, remove the "required" class and the "asterisk" in the file \app\design\frontend\PAKET\TEMPLATE\template\contacts\form.phtml, so that the result looks like this:

 

 

 

<label for="name"><?php echo Mage::helper('contacts')->__('Name') ?></label>

<div class="input-box">

                <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text" type="text" />

</div>

 

So far, this is fairly straightforward. The problem now is that the name validation does not depend solely on the "required" class; it is hard-coded into Magento. To change this, we create a small extension that bypasses this validation:

First, we create the file (package names / extension names can be chosen freely)

 

\app\code\local\Econcess\Contacts\etc\config.xml

 

with the following content:

 

<config>

    <modules>

        <Econcess_Contacts>

            <version>1.0.0</version>

        </Econcess_Contacts>

    </modules>

                <frontend>

                               <routers>

                                                <contacts>

                                                               <args>

                                                                               <modules>

                                                                                              <econcess_contacts before="Mage_Contacts">Econcess_Contacts</econcess_contacts>

                                                                               </modules>

                                                               </args>

                                               </contacts>

                               </routers>

                </frontend>

</config>

 

To activate the module, we then create the file

 

\app\etc\modules\Econcess_Contacts.xml

 

with the following content

 

 

<?xml version="1.0"?>

<config>

    <modules>

        <Econcess_Contacts>

            <active>true</active>

            <codePool>local</codePool>

        </Econcess_Contacts>

    </modules>

</config>

 

After these preparations, we create the file

 

\app\code\local\Econcess\Contacts\controllers\IndexController.php

 

as a copy of the file

 

\app\code\core\Mage\Contacts\controllers\IndexController.php

 

and simply comment out the assignment of "true" to the boolean variable "$error", so that

 

 

if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {

                $error = true;

}

 

becomes

 

 

if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) {

                //$error = true;

}

 

Then we are done. Tested with Magento 1.9.1.0.