1

I tried everything, but nothing seems to work. This is my code:

Block/Adminhtml/Customer/Group/Edit/Form.php

<?php

class Devra_Membership_Block_Adminhtml_Customer_Group_Edit_Form extends Mage_Adminhtml_Block_Customer_Group_Edit_Form
{


    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $form = $this->getForm();

        $fs = $form->getElement('base_fieldset');

        $fs->addField('customer_group_plan_price', 'text',
            array(
                'name'  => 'plan_price',
                'label' => 'Precio del plan',
                'title' => 'Precio del plan',
                'class' => '',
                'required' => false
            )
        );

        $customerGroup = Mage::registry('current_group');
        if( Mage::getSingleton('adminhtml/session')->getCustomerGroupData() ) {
            $form->addValues(Mage::getSingleton('adminhtml/session')->getCustomerGroupData());
            Mage::getSingleton('adminhtml/session')->setCustomerGroupData(null);
        } else {
            $form->addValues($customerGroup->getData());
        }
    }

}

etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Devra_Membership>
            <version>1.0.0</version>
        </Devra_Membership>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <customer_group_edit_form>Devra_Membership_Block_Adminhtml_Customer_Group_Edit_Form</customer_group_edit_form>
                </rewrite>
            </adminhtml>
        </blocks>
        <resources>
            <devra_membership_setup>
                <setup>
                    <module>Devra_Membership</module>
                </setup>
            </devra_membership_setup>
        </resources>
    </global>

</config>

sql/devra_membership_setup/install-1.0.0.php

<?php

$installer = $this;

$installer->startSetup();

$conn->addColumn($installer->getTable('customer/customer_group'), 'customer_group_plan_price', array(
    'type'      => Varien_Db_Ddl_Table::TYPE_INTEGER,
    'unsigned'  => true,
    'nullable'  => false,
    'default'   => '0',
    'comment'   => 'Price of the plan',
));

$installer->endSetup();

I tried to add a controller with a save action, but it doesn't work too.

4

First you have to add column 'customer_group_plan_price' in table customer_group_plan_price so need to change line in Form.php

$fs->addField('customer_group_plan_price', 'text',
    array(
        'name'  => 'plan_price',
        'label' => 'Precio del plan',
        'title' => 'Precio del plan',
        'class' => '',
        'required' => false
    )
);

to

$fs->addField('customer_group_plan_price', 'text',
    array(
        'name'  => 'customer_group_plan_price',
        'label' => 'Precio del plan',
        'title' => 'Precio del plan',
        'class' => '',
        'required' => false
    )
);

in config.xml

<devra_membership_setup>
    <setup>
        <module>Devra_Membership</module>
        <class>Mage_Core_Model_Resource_Setup</class> //add class
    </setup>
</devra_membership_setup>

To save your custom field customer_group_plan_price you have to extend app\code\core\Mage\Adminhtml\controllers\Customer\GroupController.php and add saveAction() to save that field.

Note : Tested Code , Let me know in case of any query.

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.