1

I have added a new button to order view action buttons:

class ReturnButton
{
    public function beforePushButtons(
        \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject,
        \Magento\Framework\View\Element\AbstractBlock $context,
        \Magento\Backend\Block\Widget\Button\ButtonList $buttonList
    ) {

        $this->_request = $context->getRequest();
        if ($this->_request->getFullActionName() == 'sales_order_view'){
              $buttonList->add(
                'returnButton',
                ['label' => __('New return request'), 'onclick' => 'setLocation(\'http://foo.bar\')', 'class' => 'reset'],
                1
            );
        }

    }
}

However, I would need to open a new window, setLocation naturally sets new location for current window. What is the correct way to do this in Magento 2?

4

Substitute 'setLocation(\'http://foo.bar\')' with 'window.open(\'http://foo.bar\')'

That should do it.

1
  • It does. Maybe I'll just settle with this, in case there is no Magento funtion for this. Dec 13 '16 at 17:35

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.