Добавление своего пункта в Export to на странице Orders
Пример на картинке (кликабельна):
app/code/community/NAMESPACE/MODULENAME/etc/config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<events> <core_block_abstract_to_html_before> <observers> <NAMESPACE_MODULENAME_sales_grid> <type>singleton</type> <class>NAMESPACE_MODULENAME/observer</class> <method>addNewExportTypeToSalesOrderGrid</method> </NAMESPACE_MODULENAME_sales_grid> </observers> </core_block_abstract_to_html_before> </events> </adminhtml> |
app/code/community/NAMESPACE/MODULENAME/Model/Observer.php
1 2 3 4 5 6 7 8 9 10 |
public function addNewExportTypeToSalesOrderGrid(Varien_Event_Observer $observer) { $block = $observer->getBlock(); if($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid){ /** @var $block Mage_Adminhtml_Block_Sales_Order_Grid */ // namespace/modulename/ordersMyActionExportGrid = путь по которому отправятся данные, должен соответствовать нужному контроллеру и методу в нем $block->addExportType('<code class="source">adminhtml</code>/modulename/ordersMyActionExportGrid', Mage::helper('namespace_modulename')->__('NEW ACTION')); } |
app/code/community/NAMESPACE/MODULENAME/controllers/Adminhtml/SOMEController.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public function ordersMyActionExportGridAction() { $orderIdsParam = $this->getRequest()->getParam('internal_order_ids'); $orderIds = $orderIdsParam ? explode(',', $orderIdsParam) : null; if (!empty($orderIds)) { foreach($orderIds as $orderId){ $order = Mage::getModel('sales/order')->load($orderId); Mage::helper('namespace_modulename')->exportOrder($order); } } else { $errorMessage = Mage::helper('namespace_modulename')->__('Export orders: No selected orders'); Mage::getSingleton('adminhtml/session')->addError( $errorMessage ); } $this->_redirect('*/*/log'); } |
Author: | Tags: /
| Rating:
Leave a Reply