0

I want to get the Order ID in the View.php file. Basically I created a button in view.php in the back-end. now I want to pass the order id through query string to the external URL.

  • How can I get the Order id in above scenario?
  • How can I open an external URL in new browser window.

Here is my code:

$this->_addButton('order_reorder', array(
    'label'     => Mage::helper('sales')->__('Print'),
    //  'onclick'   => "setLocation('".$this->getUrl('http://www.google.com')."')"
    'onclick'   => 'setLocation(\'' . 'http://www.exportleftovers.co/leopardmagento/test.php?order_id=$order' . '\')',
    'class'     => 'go'                                 
));   
0
// assuming you are getting $order object in your file  
$url = "http://www.exportleftovers.co/leopardmagento/test.php?order_id={$order->getId()}"; 
$this->_addButton('order_reorder', array(
    'label' => Mage::helper('sales')->__('Print'),
    'onclick' => "window.open('".$url."')")
);
  • thanks Minesh Patel.... now i can open it in new window. Do you have an idea how can i get the "ORDER ID" in new window? – Muneeb Ahmad Apr 20 '16 at 5:43
  • if you mean in test.php file use $orderId = $_REQUEST['order_id']; – Minesh Patel Apr 20 '16 at 5:44
  • thanks you so much Minesh Patel. its working now. thanks alot. – Muneeb Ahmad Apr 20 '16 at 5:57
  • Hi now my "leopard label"button is showing when new order is received, but one thing is when canceled the order and again i re-order then "leopard label" button is not showing in the back-end any idea? – Muneeb Ahmad Apr 20 '16 at 12:13
0

Hi now my "leopard label"button is showing when new order is received, but one thing is when canceled the order and again i re-order then "leopard label" button is not showing in the back-end any idea? below is the code of "view.php" file.

class Mage_Adminhtml_Block_Sales_Order_View extends Mage_Adminhtml_Block_Widget_Form_Container {

public function __construct()
{
    $this->_objectId    = 'order_id';
    $this->_controller  = 'sales_order';
    $this->_mode        = 'view';

    parent::__construct();

    $this->_removeButton('delete');
    $this->_removeButton('reset');
    $this->_removeButton('save');
    $this->setId('sales_order_view');
    $order = $this->getOrder();
    $coreHelper = Mage::helper('core');

    // Get the Order Id and also Make the new button for printing.


    $url = "http://www.exportleftovers.co/leopardmagento/api_call_get_orders_magento.php?order_id={$order->getId()}"; 
    $this->_addButton('order_reorder', array(
                    'label'     => Mage::helper('sales')->__('Leopard Label'),
                    'onclick' => "window.open('".$url."')"

    ));   

    if ($this->_isAllowedAction('edit') && $order->canEdit()) {
        $confirmationMessage = $coreHelper->jsQuoteEscape(
            Mage::helper('sales')->__('Are you sure? This order will be canceled and a new one will be created instead')
        );
        $onclickJs = 'deleteConfirm(\'' . $confirmationMessage . '\', \'' . $this->getEditUrl() . '\');';
        $this->_addButton('order_edit', array(
            'label'    => Mage::helper('sales')->__('Edit'),
            'onclick'  => $onclickJs,
        ));
        // see if order has non-editable products as items
        $nonEditableTypes = array_keys($this->getOrder()->getResource()->aggregateProductsByTypes(
            $order->getId(),
            array_keys(Mage::getConfig()
                ->getNode('adminhtml/sales/order/create/available_product_types')
                ->asArray()
            ),
            false
        ));

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.