Magento/PHP - Get phones on all members in a customer group -


i working on custom magento extension. working around adminhtml part , i've created custom form there.

here form code:

<?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();             }     } 

here code have in save action:

$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('*'); } 

this code supposed give me group id when press submit button. have phones of these members in array that:

$phones = array($phone); 

how can phone numbers , make them in array ?

thanks in advance!

this code give collection of customer in group.. can code.

$customers = mage::getmodel('customer/customer')                             ->getcollection()                             ->addattributetoselect('*')                             ->addfieldtofilter('group_id', $groupid);      $phone=array();     foreach($customers ans $customer)     {        $phone[]=$customer->gettelephone();     } 

Comments

Popular posts from this blog

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -