0

When I try to edit an order in the Magento backend. After order edited the username setted Guest, but in parent order usernames set John.

I have order s1.micp.ru/UQcmB.png In order user name is TEST after I edited order the user name setted Guest s3.micp.ru/Acx6y.png but i didn't change username

How can i fix it?

4
  • Are you saying the user submits the order with their name but you want to change it to guest? Apr 25 '15 at 12:56
  • I have order [link]s1.micp.ru/UQcmB.png In order user name is TEST after I edited order the user name setted Guest [link] s3.micp.ru/Acx6y.png but i didn't change username @brentwpeterson
    – omelandr
    Apr 25 '15 at 13:06
  • It's not normal behavior. And rewrite core models is not very good solution. You need to determine why does it happen. When I press EDIT order - I'm getting page with my account details. They are already exist. Could you show us what's happening after pressing button EDIT (please provide screenshot), if you still interested in resolving your problem properly.
    – zhartaunik
    Apr 25 '15 at 21:34
  • @zhartaunik [link]s2.micp.ru/G645w.png
    – omelandr
    Apr 27 '15 at 6:26
0

I changed method setAccountData in Mage_Adminhtml_Model_Sales_Order_Create from

    public function setAccountData($accountData)
{
    $customer   = $this->getQuote()->getCustomer();
    $form       = $this->_getCustomerForm();
    $form->setEntity($customer);

    // emulate request
    $request = $form->prepareRequest($accountData);
    $data    = $form->extractData($request);

    $form->restoreData($data);

    $data = array();
    foreach ($form->getAttributes() as $attribute) {
        $code = sprintf('customer_%s', $attribute->getAttributeCode());
        $data[$code] = $customer->getData($attribute->getAttributeCode());
    }


    if (isset($data['customer_group_id'])) {
        $groupModel = Mage::getModel('customer/group')->load($data['customer_group_id']);
        $data['customer_tax_class_id'] = $groupModel->getTaxClassId();
        $this->setRecollect(true);
    }

    $this->getQuote()->addData($data);
    return $this;
}

to

    public function setAccountData($accountData)
{
    $customer   = $this->getQuote()->getCustomer();
    $form       = $this->_getCustomerForm();
    $form->setEntity($customer);

    // emulate request
    $request = $form->prepareRequest($accountData);
    $data    = $form->extractData($request);

    $form->restoreData($data);

    $data = array();
    foreach ($form->getAttributes() as $attribute) {
        $code = sprintf('customer_%s', $attribute->getAttributeCode());
        $data[$code] = $customer->getData($attribute->getAttributeCode());
    }

    if(!$data['customer_firstname'])
    {
        $data['customer_firstname'] = $this->getBillingAddress()->getFirstname().' '.$this->getBillingAddress()->getLastname();
        if(!$data['customer_firstname'])
        {
            $data['customer_firstname'] = $this->getShippingAddress()->getFirstname().' '.$this->getShippingAddress()->getLastname();
        }
    }   

    if (isset($data['customer_group_id'])) {
        $groupModel = Mage::getModel('customer/group')->load($data['customer_group_id']);
        $data['customer_tax_class_id'] = $groupModel->getTaxClassId();
        $this->setRecollect(true);
    }

    $this->getQuote()->addData($data);
    return $this;
}

And it works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.