Pages

Tuesday, May 8, 2012

Magento Backend user edit in account information checkboxes values show and update code

You have to customize in couple of file for showing checked value and update those checkboxes in magento backend Account Information page.

for showing checked value
app/code/core/Mage/Adminhtml/controllers/CustomerController.php

and for update checkboxes value
app/code/core/Mage/Adminhtml/Block/Widget/form.php


          else if ($inputType == 'checkbox') {
                    $customer11 = Mage::registry('current_customer');
                    if($customer11->getData($attribute->getAttributeCode()) == '1' || $customer11->getData($attribute->getAttributeCode()) != '')
                        $element->setChecked('1');
                    else if($customer11->getData($attribute->getAttributeCode()) == '0' || $customer11->getData($attribute->getAttributeCode()) == '')
                        $element->setChecked('0');
                }

set this codition in function _setFieldset in form.php file for showing your checkbox is checked or not in backend Account infomation page in magento.


            $emailprefs = array(
                'ATTRIBUTECODE1','ATTRIBUTECODE2','ATTRIBUTECODE3',...,
            );
            // Prepare customer saving data
            if (isset($data['account'])) {
                foreach($emailprefs as $pref){
                    $data['account'][$pref] = isset($data['account'][$pref]) ? 1 : 0;
                }
               
                if (isset($data['account']['email'])) {
                    $data['account']['email'] = trim($data['account']['email']);
                }
                $customer->addData($data['account']);
            }

Put this code in function saveAction() in CustomerController.php page for updating your checkboxes values in backend Account infomation page in magento. Replace 'ATTRIBUTECODE' with your checkboxes attribute codes.

1 comment:

  1. i want to make my own blog plz help me
    krunal pandya
    9537412731
    savarkundla

    ReplyDelete