Try the Demo

Magento Forum

   
Page 2 of 2
How do I save information to new column in `sales_order` through admin/sales_order_create ? 
 
aephex
Jr. Member
 
Total Posts:  17
Joined:  2008-06-23
 

I’m still looking for a way to log who made the sale when creating a new order from the admin section.

If anyone has any insight, even an alternate way of doing this, please, let me know.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

I haven’t given up, I just had a 16 hour business trip yesterday so I wasn’t quite ready to get back to working on this.  I intend to work on this over the weekend, hopefully I will have something good to report.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
aephex
Jr. Member
 
Total Posts:  17
Joined:  2008-06-23
 

I haven’t been able to devote any time to Magento lately, but I would still appreciate help on this issue.

For those of you just joining us, I am looking for a way to log which user created an order from the admin area.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jenks
Member
 
Total Posts:  37
Joined:  2008-06-03
Michigan
 

I know when messing with the multiple table rates hack I had some issues with saving that came about because I needed to define additional information in the xml files…

Look here..
app/code/core/Mage/Sales/etc

Not sure if it’s system.xml or config.xml but I have a feeling it may be related to needed to define the new field to the model via the xml.  If this isn’t the right module look for something similar wherever it is that you are having troubles at.

 Signature 

If you understand what you’re doing, you’re not learning anything.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Ok guys, I have a solution that works.  This is not really the correct Magento way of doing things but it does work.  This modifies core files but for now it should get you by.

/app/code/core/Mage/Adminhtml/controllers/sales/order/CreateController.php

In the saveAction() Method after this block of code:

$order $this->_getOrderCreateModel()
                ->
importPostData($this->getRequest()->getPost('order'))
                ->
createOrder();

Insert:

/**
             * Identify Current User & Save to database
             */
            $_user Mage::getModel('admin/session')->getUser();
            
$username $_user->getFirstname() . " " $_user->getLastname();
            
            
$data = array (
                
'salesperson'    => $username
            
);
            
            
$where[] "entity_id = '" $order->getId() . "'";
            
            
$conn Mage::getSingleton('core/resource')->getConnection('core_write');
            
$conn->update('sales_order'$data$where);

Make sure that you have added the field:

“salesperson”

Field'salesperson'
TypeVARCHAR
Length
255
NULL
Null

To the table sales_order.

And add this to the orders grid after the ‘Grand Total’ column (or wherever you want):
/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

$this->addColumn('salesperson', array(
            
'header' => Mage::helper('sales')->__('Salesperson'),
            
'index' => 'salesperson',
        ));

That should do it!

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
aephex
Jr. Member
 
Total Posts:  17
Joined:  2008-06-23
 

Thanks for the help Jenks.

Thanks again, Adam. Your solution worked for me. I’m now modifying it to fit my needs.
Cheers.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Glad it worked, good luck!

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
Glitchy
Jr. Member
 
Total Posts:  17
Joined:  2008-02-06
 

Hello,

I’ve tried the exact code described as functional, but I can’t get it to work.  Does this still work for 1.1.4?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Glitchy
Jr. Member
 
Total Posts:  17
Joined:  2008-02-06
 

grid.php - working
CreateController.php - NOT WORKING

$username "TESTVALUE";
        
            
            
$data = array (
                
'salesperson'    => $username
            
);
            
            
$where[] "entity_id = '" $order->getId() . "'";
            
            
$conn Mage::getSingleton('core/resource')->getConnection('core_write');
            
$conn->update('sales_order'$data$where);

 
Magento Community Magento Community
Magento Community
Magento Community
 
Glitchy
Jr. Member
 
Total Posts:  17
Joined:  2008-02-06
 

Correction:  The code DOES work.  I was using it incorrectly.

I want to have the CreateController.php code work in the frontend ordering system.  Which file and where in that file would I copy the modified code?

Anyone?

Thanks in advance…

 
Magento Community Magento Community
Magento Community
Magento Community
 
smitty1140
Member
 
Total Posts:  45
Joined:  2012-01-13
 

Does anyone have this working in 1.6?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2