Wie folgt zeige ich, wie ihr im Backend einen Button zur Product-Edit Page hinzufügen könnt. Dazu muss eine neue Extension erstellt werden.
Folgende Verzeichnisse und Dateien müssen angelegt werden:
/app/code/local/M28visions/AddAdminhtmlOptionsButton/
/app/code/local/M28visions/AddAdminhtmlOptionsButton/etc/
/app/code/local/M28visions/AddAdminhtmlOptionsButton/etc/config.xml
/app/code/local/M28visions/AddAdminhtmlOptionsButton/Block/Adminhtml/Catalog/Product/Edit.php
/app/etc/modules/M28visions_AddAdminhtmlOptionsButton.xml — zum Aktivieren der Extension
Quellcode:
/app/code/local/M28visions/AddAdminhtmlOptionsButton/etc/config.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?xml version="1.0"?> <config> <modules> <M28visions_AddAdminhtmlOptionsButton> <version>0.0.1</version> </M28visions_AddAdminhtmlOptionsButton> </modules> <frontend> </frontend> <global> <blocks> <m28visions_addadminhtmloptionsbutton> <class>M28visions_AddAdminhtmlOptionsButton_Block</class> </m28visions_addadminhtmloptionsbutton> <adminhtml> <rewrite> <catalog_product_edit>M28visions_AddAdminhtmlOptionsButton_Block_Adminhtml_Catalog_Product_Edit</catalog_product_edit> </rewrite> </adminhtml> </blocks> </global> </config> |
Quellcode:
/app/code/local/M28visions/AddAdminhtmlOptionsButton/Block/Adminhtml/Catalog/Product/Edit.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <?php class M28visions_AddAdminhtmlOptionsButton_Block_Adminhtml_Catalog_Product_Edit extends Mage_Adminhtml_Block_Catalog_Product_Edit { /** * @var Mage_Catalog_Model_Product Product instance */ private $_product; /** * Preparing global layout * * @return M28visions_AddAdminhtmlOptionsButton_Block_Adminhtml_Catalog_Product_Edit|Mage_Core_Block_Abstract */ protected function _prepareLayout() { parent::_prepareLayout(); $this->_product = $this->getProduct(); $this->setChild('view_on_front', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('catalog')->__('Add Product Options'), 'onclick' => 'setLocation(\''.$this->getUrl('m28adminhtml/adminhtml_product', array('_current'=>true)).'\')', 'disabled' => !$this->_isVisible(), 'title' => Mage::helper('catalog')->__('Add Product Options') )) ); return $this; } /** * Returns duplicate & view on front buttons html * * @return string */ public function getDuplicateButtonHtml() { return $this->getChildHtml('duplicate_button') . $this->getChildHtml('view_on_front'); } /** * Checking product visibility * * @return bool */ private function _isVisible() { return $this->_product->isVisibleInCatalog() && $this->_product->isVisibleInSiteVisibility(); } } |
Quellcode:
/app/etc/modules/M28visions_AddAdminhtmlOptionsButton.xml
1 2 3 4 5 6 7 8 9 | <?xml version="1.0"?> <config> <modules> <M28visions_AddAdminhtmlOptionsButton> <active>true</active> <codePool>local</codePool> </M28visions_AddAdminhtmlOptionsButton> </modules> </config> |