I am working on a custom Magento( extension.

Let me show you what i have done already.

enter image description here

Here is the code for this Adminhtml form:


class VivasIndustries_SmsNotification_Block_Adminhtml_Sms_Sendmass_Edit_Form extends Mage_Adminhtml_Block_Widget_Form

        public function _prepareLayout() 
              $ExtensionPath = Mage::getModuleDir('js', 'VivasIndustries_SmsNotification'); 
              $head = $this->getLayout()->getBlock('head');

              return parent::_prepareLayout();

        protected function _prepareForm()
            $form = new Varien_Data_Form(array(
                                    'id' => 'edit_form',
                                    'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
                                    'method' => 'post',

                $fieldset = $form->addFieldset('edit_form', array('legend'=>Mage::helper('smsnotification')->__('SMS Information')));

                $CustomerGroups = Mage::getResourceModel('customer/group_collection')->toOptionArray();

                $smsprice_value = Mage::getStoreConfig('vivas/smsprice/smsprice_value');
                $smsprice_tag = Mage::getStoreConfig('vivas/smsprice/smsprice_tag');

                foreach($CustomerGroups as $each){

                $SMSPrice = $count * $smsprice_value;               
                     $customerArray[]=array('value'=> $each['value'],'label'=> $each['label'].' - ('.$count.' Members) - ('.$SMSPrice.' '.$smsprice_tag.')');


                $CustomerGroups = array_merge(array('' => ''), $customerArray);

                $fieldset->addField('customergroups', 'select',
                            'name'      => 'customergroups',
                            'label'     => Mage::helper('smsnotification')->__('Customer Group'),
                            'class'     => 'required-entry',
                            'after_element_html' => '<br><small>If customer group is not selected the SMS will be sended<br> to all store members!</small>',
                            'values'    => $CustomerGroups

                $fieldset->addField('smstext', 'textarea', array(
                          'label'     => Mage::helper('smsnotification')->__('SMS Text'),
                          'class'     => 'required-entry',
                          'required'  => true,
                          'name'      => 'smstext',
                          'onclick' => "",
                          'onkeyup' => "CheckLetterSize(this)",
                          'after_element_html' => '<br><b style="color:brown;"><span id="charNum"></span><span id="charNum1"></span></b><br><small>SMS text must <b>NOT</b> be longer then 160 characters!</small>',
                          'tabindex' => 1

                if ( Mage::getSingleton('adminhtml/session')->getsmsnotificationData() )
                    } elseif ( Mage::registry('smsnotification_data') ) {
                // Add these two lines



                return parent::_prepareForm();

When this form is submitted i want to get all Names, phones and emails of the members in the selected group. The second thing is, when no customer group is selected it must give me names, phones and emails for all customers in the store.

I used to get information about the user from Order information like this:

    class VivasIndustries_SmsNotification_Model_Observer
        public function orderSaved(Varien_Event_Observer $observer)
            /** **/

        $CustomerPhone = $observer->getOrder()->getBillingAddress()->getTelephone();
        $CustomerName = $observer->getOrder()->getBillingAddress()->getName();
        $CustomerEmail = $observer->getOrder()->getBillingAddress()->getEmail();

I know that this is not even close to what i need but i don't know how to get this information.

Can you please help me out?

1 Answer 1


i guess that on the save action of this function,you want to get Customer email, name etc basic form customer group.

As per as your code, customergroups field sending customer group id to Save action url. The below solution give you collection customer basic of customer group id.

        ->addAttributeToSelect('group_id') ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
  • I don't understand how i can get seperatelly the phone for example. I must get all the phones in array like this $phones = array($phone); I don't understand how i get it from your code. Thanks in advance! Jun 3, 2015 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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