2

I am working on a custom Magento extension. Version: 1.9.0.1.

I have a custom Adminhtml form, here it is:

enter image description here

Here is the Form code:

<?php

class VivasIndustries_SmsNotification_Block_Adminhtml_Sms_Status_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
    {


        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')));

                $statuses = Mage::getResourceModel('sales/order_status_collection')
                    ->toOptionArray();

                $statuses = array_merge(array('' => ''), $statuses);

                $fieldset->addField('state', 'select',
                    array(
                        'name'      => 'state',
                        'label'     => Mage::helper('smsnotification')->__('Order Status'),
                        'class'     => 'required-entry',
                        'values'    => $statuses,
                        'required'  => true,
                    )
                );

                $fieldset->addField('smstext', 'textarea', array(
                          'label'     => Mage::helper('smsnotification')->__('SMS Text'),
                          'class'     => 'required-entry',
                          'required'  => true,
                          'name'      => 'smstext',
                          'onclick' => "",
                          'onchange' => "",
                          'after_element_html' => '<br><small>SMS text must <b>NOT</b> be longer then 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 two lines


                $form->setUseContainer(true);
                $this->setForm($form);

                ////

                return parent::_prepareForm();
            }
    }

I use this code to get the customer name from the order:

$CustomerName = $observer->getOrder()->getBillingAddress()->getName();

How can i check the whole text and if it finds CustomVariable_CustomerName to replace it with the real customer name ?

Thanks in advance!

Venelin Vasilev
  • 1,062
  • 4
  • 33
  • 60

1 Answers1

2

As you have save different order status wise order sms message using this form.

as this form then must be model collection where save the those data. Using this collection you can set sms text.

$Status=Mage::getResourceModel('smsnotification/YourModelName_collection')
    ->addFieldToFilter('state',$observer->getOrder()->getStatus());
$smstext=$Status->getFirstItem()->getSmstext(); 
Amit Bera
  • 77,456
  • 20
  • 123
  • 237