4

we have created a Telesales role inside Magento with relevant permissions, and have assigned users (Telesales agents) against that role.

Now I am aware of the SO post Differentiating Backend vs. Frontend Purchases in Magento, but I need to find a way to show orders created by a specific backend user. Is this possible? I have also looked into the Advanced Reports extension from AheadWorks, but this doesn't seem to be a feature they support.

3 Answers 3

1

You can use this to find the admin orders created by a specific user

$order = Mage::getModel('sales/order')->getCollection()
       ->addFieldToFilter('remote_ip',array('null' => true)) // this will load all admin orders
       ->addFieldToFilter('customer_firstname',array('eq' => 'Joe')); // here you can also use customer_id/customer_email/customer_lastname..
echo "<pre>";print_r($order->getData());
3
  • Thanks Manashvi. Wouldn't this still be looking at orders for a particular customer instead of a backend user?
    – maGz
    Jul 8, 2015 at 5:45
  • There is no way to filter the order collection by admin user in particular Jul 8, 2015 at 5:52
  • @ManashviBirla magento.stackexchange.com/q/286442/57334 Any help thanks
    – zus
    Aug 24, 2019 at 11:43
1

As Manashvi mentioned, there is no way to understand which specific user created an order. However, we have made use of IWD's Sales Rep Tracking extension which has fulfilled this requirement.

0

I created a new module that created a foreign key in the order to the admin user table and records the logged-in admin user who places the order.

But that didn't help for older orders. So I also did this that implements a Grid that selects from the sales/order table instead of the sales/order_grid table.

Note: This is just an example. Collection code should go in the collection class.

protected function _prepareCollection()
{
    $collection = Mage::getModel('sales/order')->getCollection();

    $expr = new Zend_Db_Expr('IF(ISNULL(remote_ip), 0, 1)');

    $collection->addExpressionToSelect('is_web_order', $expr);
    $collection->addFilterToMap('is_web_order', $expr);
}

Then in Grid.php:

protected function _prepareColumns()
{
    $this->addColumn('is_web_order', [
        'header'            => Mage::helper('adminhtml')->__('Website') . ' ' . Mage::helper('adminhtml')->__('Order'),
        'index'             => 'is_web_order',
        'type'              => 'options',
        'width'             => '50px',
        'options'           => [
            0   => Mage::helper('adminhtml')->__('No'),
            1   => Mage::helper('adminhtml')->__('Yes'),
        ],
        'filter_index'      => 'is_web_order',
        'sortable'          => false,
        'align'             => 'center',
    ]);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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