I am trying to send order programmaticaly and I want to send with this order a custom information about user-uploaded image that could be visible in admin backend.

Here is my simple code:

$image = 'uploads/123193284234.jpg';
$cart = Mage::getModel('checkout/cart');
$params = array(
    'product' => 37,
    'qty' => 1,
    'options' => array(
        371 => array(
            'user-uploaded-image' => $image // the info I want to send with order
$cart->addProduct(37, $params);

This code works, now, I want the user-uploaded-image to be displayed in admin backened in order detail as new custom field like this:

enter image description here

Thanks for every suggestions ( plugin, workflow to use ) especially about the part of how to add custom field to order-detail view in admin backend.


Create a layout update in app\design\adminhtml\default\default\layout\msd.xml to add a tab in the admin order view:

<layout version="0.1.0">            
        <reference name="sales_order_tabs">
            <action method="addTab"><name>user_uploaded_image</name><block>msd/adminhtml_sales_order_view_tab_useruploadedimage</block></action>                                                            

I used the module name msd for MageStackDay, which you need to replace with your module name.

The information of the uploaded image can be found in the order_item within the order object. So first, you need find the order_item that matches the product_id 37. Then look up the image info in the product_options. Create this block:

class Kiat_Msd_Block_Adminhtml_Sales_Order_View_Tab_Useruploadedimage
    extends Mage_Adminhtml_Block_Sales_Order_Abstract
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
    protected function _construct()
        $this->setTemplate('msd/sales/order/view/tab/useruploadimage.phtml');     }

    public function getOrder()
        return Mage::registry('current_order');

    public function getImagePaths()
        $imagePaths = array();
        foreach ($order->getAllItems() as $item) {
            if ($item->getProductId() == 37) {
                $options = $item->getProductOptions();
                $imagePaths[$item->getId()] = $options[371]['order_path'];
        return $imagePaths;

    public function getTabLabel()
        return $this->__('User Uploaded Image');

    public function getTabTitle()
        return $this->__('User Uploaded Image');

    public function canShowTab()
        return true;

    public function isHidden()
        return false;

Then in msd/sales/order/view/tab/useruploadimage.phtml, you can output the images:

<?php foreach ($this->getImagePaths() as $imagePath) : ?>
    <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . substr($imagePath, 1); ?>">
<?php endforeach; ?>
| improve this answer | |

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.