Коллеги, приветствую! Случаем, никто не "встречал" модуль (?): Оставаться в карточке после нажатия кнопки "Сохранить": - добавляем товар - нажимаем Сохранить - остаёмся в той же форме добавления - а не перескок в Продукт Лист
Вот старенький топик - https://forum.opencart-russia.ru/threads/knopka-primenit-v-adminke-opencart-2.2008/ как основу можно использовать
devimirochnik , спасибо! Почитал данный топик. За основу взял другой: Save and Stay almost everywhere https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=19806 - под opencart 2х - и: - "работает ТОЛЬКО при редактировании элемента, а не при создании нового элемента (тогда вы возвращаетесь к списку)." Выдернул кусок кода из данного ocmod, переделал для opencart 3.0.3.7: Спойлер: CODE Код: <?xml version="1.0" encoding="utf-8"?> <modification> <name>[BE] Button Apply</name> <code>BE_Button_Apply</code> <version>1.0.0</version> <author></author> <link></link> <!-- Описание: - добавляет кнопку Применить Дополнительные файлы: - нет Изменение в файлах: admin/controller/catalog/information.php admin/model/catalog/information.php admin/view/template/catalog/information_form.twig --> <file path="admin/controller/catalog/information.php"> <operation> <search><![CDATA[ $this->model_catalog_information->addInformation($this->request->post); ]]></search> <add position="replace"><![CDATA[ $information_id = $this->model_catalog_information->addInformation($this->request->post); ]]></add> </operation> <operation> <search index="1"><![CDATA[ $this->response->redirect($this->url->link('catalog/information', 'user_token=' . $this->session->data['user_token'] . $url, true)); ]]></search> <add position="before"><![CDATA[ if (($this->request->server['REQUEST_METHOD'] == 'POST') && (isset($this->request->post['save_stay']) and $this->request->post['save_stay']=1)) { $this->response->redirect($this->url->link('catalog/information/edit', 'user_token=' . $this->session->data['user_token'] . '&information_id=' . $this->request->get['information_id'] . $url, true)); } ]]></add> </operation> <operation> <search><![CDATA[ $data['text_form'] = !isset($this->request->get['information_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); ]]></search> <add position="after"><![CDATA[ $data['result_success'] = 'Successfully Edited!'; if (isset($this->session->data['success'])) { $data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $data['success'] = ''; } ]]></add> </operation> </file> <file path="admin/model/catalog/information.php"> <operation> <search index="1"><![CDATA[ foreach ($data['information_description'] as $language_id => $value) { ]]></search> <add position="after" offset="4"><![CDATA[ return $information_id; ]]></add> </operation> </file> <file path="admin/view/template/catalog/information_form.twig"> <operation> <search><![CDATA[ <button type="submit" form="form-information" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button> ]]></search> <add position="before"><![CDATA[ <button type="submit" form="form-information" data-toggle="tooltip" title="{{ Save and Stay }}" class="btn btn-success" input type="hidden" id="save_stay" name="save_stay" value="1"><i class="fa fa-save"></i></button> ]]></add> </operation> <operation> <search><![CDATA[ <div class="container-fluid">{% if error_warning %} ]]></search> <add position="after" offset="4"><![CDATA[ {% if success %} <div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ result_success }} <button type="button" class="close" data-dismiss="alert">×</button> </div> {% endif %} ]]></add> </operation> </file> </modification> Может кому надо... Работает. По примеру можно остальное допилить... Вопрос: - а как сделать чтобы при создании нового элемента? - потому, что при создании нового элемента всё равно переадресовывает на главный список...
Там в контроллере функция $this->model_catalog_information->addInformation($this->request->post); вообще-то возвращает id , соответственно, сохраняете id и делаете переадресацию не в листинг а в $this->response->redirect($this->url->link('catalog/information/edit', 'user_token=' . $this->session->data['user_token'] . '&information_id=' . $this->request->get['information_id'] , true));