Вы можете сделать это с помощью переопределений. Создайте файл с именем AdminOrdersController.php
в папке overrides/controllers/admin/
, и добавьте следующее:
<?php
class AdminOrdersController extends AdminOrdersControllerCore
{
public function initPageHeaderToolbar()
{
parent::initPageHeaderToolbar(); // this will assign native icons
// This is where you add you custom icon
$this->page_header_toolbar_btn['my_custom_icon'] = array(
'href' => self::$currentIndex.'&mycustomaction&token='.$this->token,
'desc' => $this->l('My custom action', null, null, false),
'icon' => 'process-icon-save'
);
}
public function initProcess()
{
parent::initProcess();
if (Tools::getIsset('mycustomaction')) {
if ($this->tabAccess['view'] === '1') {
$this->display = 'mycustomaction';
$this->action = 'mycustomaction';
}
else
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
public function initContent()
{
parent::initContent();
if ($this->display == 'mycustomaction')
$this->content.= $this->renderMyCustomAction();
}
public function renderMyCustomAction()
{
// this is where you render your custom page.
}
}
Обратите внимание, что это быстрый макете. Он должен работать, хотя :)
UPDATE
Если вы просто хотите значок, чтобы открыть новую страницу, оставить только метод initPageHeaderToolbar
и обеспечить правильный href
атрибут, вы можете удалить initProcess
, initContent
и renderMyCustomAction
методов. Я оставлю их в своем первоначальном ответе, если кто-то найдет это полезным.
В настоящее время ваш вопрос слишком широк. Пожалуйста, объясните цель этой кнопки. –