Magento/PHP - Get Phones, Emails, Names for all customers in a selected customer group -


i working on custom magento(1.9.0.1) extension.

let me show have done already.

enter image description here

here code adminhtml form:

<?php  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');               $head->addjs('jquery.js');               $head->addjs('vivas.js');                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');                  $customerarray=array();                 foreach($customergroups $each){                       $count=mage::getresourcemodel('customer/customer_collection')                                 ->addattributetofilter('group_id',$each['value'])->getsize();                 $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',                         array(                             'name'      => 'customergroups',                             'label'     => mage::helper('smsnotification')->__('customer group'),                             'class'     => 'required-entry',                             'after_element_html' => '<br><small>if customer group not selected sms sended<br> 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> longer 160 characters!</small>',                           'tabindex' => 1                         ));                       if ( mage::getsingleton('adminhtml/session')->getsmsnotificationdata() )                     {                         $form->setvalues(mage::getsingleton('adminhtml/session')->getsmsnotificationdata());                         mage::getsingleton('adminhtml/session')->setsmsnotificationdata(null);                     } elseif ( mage::registry('smsnotification_data') ) {                         $form->setvalues(mage::registry('smsnotification_data')->getdata());                     }                 // add these 2 lines                   $form->setusecontainer(true);                 $this->setform($form);                  ////                  return parent::_prepareform();             }     } 

when form submitted want names, phones , emails of members in selected group. second thing is, when no customer group selected must give me names, phones , emails customers in store.

i used information user order information 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 not close need don't know how information.

can please me out ?

thanks in advance!

in admin controller, form posted: $groupid = $this->getrequest()->getpost('customergroups', ''); if (!empty($groupid)) { //get customers group $customers = mage::getmodel('customer/customer') ->getcollection() ->addattributetoselect('*') ->addfieldtofilter('group_id', $groupid); } else { //get customers $customers = mage::getmodel('customer/customer') ->getcollection() ->addattributetoselect('*'); }


Comments