Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
magento和sugar CRM集成问题_Magento_Integration_Sugarcrm - Fatal编程技术网

magento和sugar CRM集成问题

magento和sugar CRM集成问题,magento,integration,sugarcrm,Magento,Integration,Sugarcrm,我是magento的新手。实际上我想将magento与sugar crm集成 我放弃了这份指南 但我无法通过此代码获取客户的名字、姓氏和电子邮件 当客户在magento中创建帐户时,leads将在CRM中创建,但字段为空。 如何获取客户的名字、姓氏和电子邮件 谢谢提前分配 这是我的代码,但仍然无法获取客户信息。 公共函数createPostAction() { $session=$this->\u getSession(); 如果($session->isLoggedIn()){ $this->

我是magento的新手。实际上我想将magento与sugar crm集成 我放弃了这份指南

但我无法通过此代码获取客户的名字、姓氏和电子邮件

当客户在magento中创建帐户时,leads将在CRM中创建,但字段为空。 如何获取客户的名字、姓氏和电子邮件

谢谢提前分配 这是我的代码,但仍然无法获取客户信息。 公共函数createPostAction() {

$session=$this->\u getSession();
如果($session->isLoggedIn()){
$this->_重定向('*/*/');
返回;
}
$session->setEscapeMessages(true);//防止用户输入中的XSS注入
如果($this->getRequest()->isPost()){
$errors=array();
if(!$customer=Mage::registry('current_customer')){
$customer=Mage::getModel('customer/customer')->setId(null);
}
/*@var$customerForm Mage\u Customer\u Model\u表单*/
$customerForm=Mage::getModel('customer/form');
$customerForm->setFormCode('customer\u account\u create')
->实体(客户);
$customerData=$CustomerPerform->extractData($this->getRequest());
if($this->getRequest()->getParam('is_subscribed',false)){
$customer->setIsSubscribed(1);
}
/**
*初始化客户组id
*/
$customer->getGroupId();
如果($this->getRequest()->getPost('create_address')){
/*@var$address Mage\u客户\u型号\u地址*/
$address=Mage::getModel('customer/address');
/*@var$addressForm Mage\u Customer\u Model\u Form*/
$addressForm=Mage::getModel('customer/form');
$addressForm->setFormCode('customer\u register\u address')
->设置实体(地址);
$addressData=$addressForm->extractData($this->getRequest(),'address',false);
$addressErrors=$addressForm->validateData($addressData);
如果($addressErrors===true){
$address->setId(空)
->setIsDefaultBilling($this->getRequest()->getParam('default_billing',false))
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping',false));
$addressForm->compactData($addressData);
$customer->addAddress($address);
$addressErrors=$address->validate();
if(is_数组($addressErrors)){
$errors=array\u merge($errors,$addressErrors);
}
}否则{
$errors=array\u merge($errors,$addressErrors);
}
}
foreach(Mage::getConfig()->getFieldset('customer_account')作为$code=>$node){
如果($node->is('create')&&isset($data[$code])){
交换机($代码){
“电子邮件”案例:
$data[$code]=trim($data[$code]);
echo$email=$data[$code];
打破
案例“firstname”:
echo$firstname=$data[$code];
打破
案例“lastname”:
echo$lastname=$data[$code];
打破
}               
}
}
$options=数组(“位置”=>”http://addres.com/soap.php“,“uri”=>”http://addres.com/',“跟踪”=>1);
$user\u auth=array(“user\u name”=>“name”,
“密码”=>md5(“密码”),
“版本”=>“6.2.4”
);
$client=新的SoapClient(Null,$options);
$response=$client->login($user_auth,'name');
$session\u id=$response->id;
$response=$client->set\u条目($session\u id,'Leads',数组(
数组(“name”=>“first_name”,“value”=>$firstname),
数组(“名称”=>“姓氏”,“值”=>$lastname),
数组(“名称”=>“电子邮件”,“值”=>$email));
试一试{
$customerErrors=$CustomerPerform->validateData($customerData);
如果($customerErrors!==true){
$errors=array\u merge($customerErrors,$errors);
}否则{
$customerForm->compactData($customerData);
$customer->setPassword($this->getRequest()->getPost('password');
$customer->setConfirmation($this->getRequest()->getPost('confirmation');
$customerErrors=$customer->validate();
if(is_数组($customerErrors)){
$errors=array\u merge($customerErrors,$errors);
}
}
$validationResult=count($errors)==0;
if(true==$validationResult){
$customer->save();
Mage::dispatchEvent(“客户注册成功”,
数组('account\u controller'=>$this,'customer'=>$customer)
);
如果($customer->isConfirmationRequired()){
$customer->sendNewAccountEmail(
“确认”,
$session->getBeforeAuthUrl(),
Mage::app()->getStore()->getId()
);
$session->addSuccess($this->\($uuuuuuuuuuuuuuuuuuuu($this->uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu($customer->getEmail())需要帐户确认。请检查您的电子邮件中的确认链接。若要重新发送确认电子邮件,请执行以下操作;
$this->_redirectSuccess(Mage::getUrl('*/*/index',数组(''u secure'=>true));
返回;
}否则{
$session->setCustomerAsLoggedIn($customer);
$url=$this->\u欢迎客户($customer);
$this->\u重定向成功($url);
返回;
}
}否则{
$session->setCustomPerformData($this->getRequest()->getPost());
    $session = $this->_getSession();




    if ($session->isLoggedIn()) {
        $this->_redirect('*/*/');
        return;
    }
    $session->setEscapeMessages(true); // prevent XSS injection in user input
    if ($this->getRequest()->isPost()) {
        $errors = array();

        if (!$customer = Mage::registry('current_customer')) {
            $customer = Mage::getModel('customer/customer')->setId(null);
        }

        /* @var $customerForm Mage_Customer_Model_Form */
      $customerForm= Mage::getModel('customer/form');
       $customerForm->setFormCode('customer_account_create')
            ->setEntity($customer);

       $customerData= $customerForm->extractData($this->getRequest());

        if ($this->getRequest()->getParam('is_subscribed', false)) {
            $customer->setIsSubscribed(1);
        }


        /**
         * Initialize customer group id
         */
        $customer->getGroupId();

        if ($this->getRequest()->getPost('create_address')) {
            /* @var $address Mage_Customer_Model_Address */
            $address = Mage::getModel('customer/address');
            /* @var $addressForm Mage_Customer_Model_Form */
            $addressForm = Mage::getModel('customer/form');
            $addressForm->setFormCode('customer_register_address')
                ->setEntity($address);

            $addressData    = $addressForm->extractData($this->getRequest(), 'address', false);
            $addressErrors  = $addressForm->validateData($addressData);
            if ($addressErrors === true) {
                $address->setId(null)
                    ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
                    ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
                $addressForm->compactData($addressData);
                $customer->addAddress($address);

                $addressErrors = $address->validate();
                if (is_array($addressErrors)) {
                    $errors = array_merge($errors, $addressErrors);
                }
            } else {
                $errors = array_merge($errors, $addressErrors);
            }




        }
        foreach (Mage::getConfig()->getFieldset('customer_account') as $code=>$node) {
                if ($node->is('create') && isset($data[$code])) {
                    switch($code) {
                        case 'email':
                            $data[$code] = trim($data[$code]);
                            echo $email = $data[$code];
                        break;
                        case 'firstname':
                           echo $firstname = $data[$code];
                        break;
                        case 'lastname':
                           echo $lastname = $data[$code];
                        break;
                    }               
                }
            }
        $options= array( "location"=>'http://addres.com/soap.php',"uri"=>'http://addres.com/',"trace"=>1 );
        $user_auth=array ("user_name"=>'name',
        "password"=>md5('password'),
        "version"=>'6.2.4'
        );


        $client=new SoapClient(Null,$options);
        $response=$client->login($user_auth,'name');
        $session_id=$response->id;

        $response=$client->set_entry($session_id,'Leads',array(
        array("name"=>'first_name',"value"=>$firstname),
        array("name"=>'last_name',"value"=>$lastname),
        array("name"=>'email',"value"=>$email)));            


        try {
            $customerErrors = $customerForm->validateData($customerData);
            if ($customerErrors !== true) {
                $errors = array_merge($customerErrors, $errors);
            } else {
                $customerForm->compactData($customerData);
                $customer->setPassword($this->getRequest()->getPost('password'));
                $customer->setConfirmation($this->getRequest()->getPost('confirmation'));
                $customerErrors = $customer->validate();
                if (is_array($customerErrors)) {
                    $errors = array_merge($customerErrors, $errors);
                }
            }

            $validationResult = count($errors) == 0;

            if (true === $validationResult) {
                $customer->save();



                Mage::dispatchEvent('customer_register_success',
                    array('account_controller' => $this, 'customer' => $customer)
                );

                if ($customer->isConfirmationRequired()) {
                    $customer->sendNewAccountEmail(
                        'confirmation',
                        $session->getBeforeAuthUrl(),
                        Mage::app()->getStore()->getId()
                    );
                    $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
                    $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
                    return;
                } else {
                    $session->setCustomerAsLoggedIn($customer);
                    $url = $this->_welcomeCustomer($customer);
                    $this->_redirectSuccess($url);
                    return;
                }
            } else {
                $session->setCustomerFormData($this->getRequest()->getPost());
                if (is_array($errors)) {
                    foreach ($errors as $errorMessage) {
                        $session->addError($errorMessage);
                    }
                } else {
                    $session->addError($this->__('Invalid customer data'));
                }
            }
        } catch (Mage_Core_Exception $e) {
            $session->setCustomerFormData($this->getRequest()->getPost());
            if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                $url = Mage::getUrl('customer/account/forgotpassword');
                $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
                $session->setEscapeMessages(false);
            } else {
                $message = $e->getMessage();
            }
            $session->addError($message);
        } catch (Exception $e) {
            $session->setCustomerFormData($this->getRequest()->getPost())
                ->addException($e, $this->__('Cannot save the customer.'));
        }
    } 


    $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));



}
foreach (Mage::getConfig()->getFieldset('customer_account') as $code=>$node) { if ($node->is('create') && isset($data[$code])) { switch($code) { case 'email': $data[$code] = trim($data[$code]); $email = $data[$code]; break; case 'firstname': $firstname = $data[$code]; break; case 'lastname': $lastname = $data[$code]; break; } } }
$this->getRequest()->getPost()
(
    [name] => test
    [email] => test@test.com
    [telephone] => 
    [comment] => test
    [captcha] => Array
        (
            [contact_form] => tttt
        )

    [hideit] => 
)
// Pass customer information from Magento to SugarCRM
$customer_info = array(array('name' => 'first_name', 'value' => $this->getRequest()->getPost('firstname')),
                   array('name' => 'last_name', 'value' => $this->getRequest()->getPost('lastname')),
                   array('name' => 'email2', 'value' => $this->getRequest()->getPost('email')));

$response = $client->set_entry($session_id, 'Leads', $customer_info);
<events>
    <customer_save_after>
        <observers>
            <yournamespace_yourmodule_order_observer>
                <type>singleton</type>
                <class>Yournamespace_Yourmodule_Model_Observer</class>
                <method>sendemail</method>
            </yournamespace_yourmodule_order_observer>
        </observers>
    </customer_save_after>
</events>
<?php
class Yournamespace_Yourmodule_Model_Observer
{
    public function __construct()
    {
        //Just constrcutor for fun :-)
    }

    public function sendemail($observer)
    {
        //$observer contains the object returns in the event.
        $event = $observer->getEvent();
        $order = $event->getOrder();
        mage::log($order->getId());
        //Write code to send email
        return $this;
     }