I am create SMS module and in SMS template i use custom variable such as {{var customer.getName()}} .

How i can convert this variable to same variable for example if user use {{var customer.getName()}} in SMS template when SMS was sent customer see his/here name in SMS

1 Answer 1


I create this method

    private function replace($string, $customer='', $order=''){

            $string=explode(" ",$string);
            foreach ($string as $item){
                if(strpos($item,'$') !== false){

                       $new_word= $customer->$c_word();

                        $new_word= $order->$o_word();


                $str.=" ".$new_word;

            return $str;

I know this way is not a magento way but for now fixed my problem and i am stay in waiting for better way

            $this->replace("hi $customer.name your id is $customer.id ",$customer,$order);

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.