I'm trying to extend the Action List. I've looked for rewrite conflicts with the many rewrite tools. I'm just not seeing it. Here is my code.
<?php
class MDN_BarcodeLabel_Block_Product_List extends
Mage_Adminhtml_Block_Catalog_Product_List {
protected function _prepareMassaction() {
parent::_prepareMassaction();
// Append new mass action option
$this->getMassactionBlock()->addItem(
'BarcodeLabel',
array('label' => $this->__('Print barcode labels'),
'url' => $this->getUrl('adminhtml/BarcodeLabel_Admin/printSelectedProductLabel')
)
);
}
}
?>
Here rewrite script below show it being listed by itself. Here is the Observer.php. I have everything working fine on a clean install, but I can't seem to find the conflict anywhere. There is ACL built in, but that is working perfect.
public function addMassAction($observer) {
$block = $observer->getEvent()->getBlock();
if (get_class($block) == 'Mage_Adminhtml_Block_Widget_Grid_Massaction'
&& $block->getRequest()->getControllerName() == 'catalog_product') {
$admin_user_session = Mage::getSingleton('admin/session');
$adminuserId = $admin_user_session->getUser()->getUserId();
$role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole();
$roleIdUser = $role_data->getRoleId();
$barcodeprofiles = Mage::getModel('barcodeprofile/barcodeprofile')->getCollection()
->addFieldToFilter('status', 1);
$arrayBarcode = array();
foreach($barcodeprofiles as $data) {
$arrayRole = explode(',', $data->getRole());
if(in_array($roleIdUser, $arrayRole)) {
$arrayBarcode[$data->getId()] = $data->getProfile();
}
}
$block->addItem('BarcodeLabel', array(
'label' => Mage::helper('BarcodeLabel')->__('Print barcode labels'),
'url' => Mage::app()->getStore()->getUrl('adminhtml/BarcodeLabel_Admin/printSelectedProductLabel'),
'additional' => array(
'visibility' => array(
'name' => 'barcode_profile',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('catalog')->__('Barcode Profile'),
'values' => $arrayBarcode
)
)
));
If you interested here is the config.xml. Sorry about the length. ...
<global>
<helpers>
<BarcodeLabel>
<class>MDN_BarcodeLabel_Helper</class>
</BarcodeLabel>
</helpers>
<blocks>
<BarcodeLabel>
<class>MDN_BarcodeLabel_Block</class>
</BarcodeLabel>
<adminhtml>
<rewrite>
<catalog_product_list>MDN_BarcodeLabel_Block_Product_List</catalog_product_list>
</rewrite>
</adminhtml>
</blocks>
<models>
<BarcodeLabel>
<class>MDN_BarcodeLabel_Model</class>
<resourceModel>BarcodeLabel_mysql4</resourceModel>
</BarcodeLabel>
<BarcodeLabel_mysql4>
<class>MDN_BarcodeLabel_Model_Mysql4</class>
<entities>
<List>
<table>barcode_label_list</table>
</List>
<ProductVarchar>
<table>catalog_product_entity_varchar</table>
</ProductVarchar>
</entities>
</BarcodeLabel_mysql4>
<AdvancedStock>
<rewrite>
<Pdf_BarcodeLabels>MDN_BarcodeLabel_Model_Pdf_Labels</Pdf_BarcodeLabels>
</rewrite>
</AdvancedStock>
</models>
<resources>
<BarcodeLabel_setup>
<setup>
<module>MDN_BarcodeLabel</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</BarcodeLabel_setup>
<BarcodeLabel_write>
<connection>
<use>core_write</use>
</connection>
</BarcodeLabel_write>
<BarcodeLabel_read>
<connection>
<use>core_read</use>
</connection>
</BarcodeLabel_read>
</resources>
<events>
<model_save_after>
<observers>
<BarcodeLabel>
<type>singleton</type>
<class>BarcodeLabel/observer</class>
<method>model_save_after</method>
</BarcodeLabel>
</observers>
</model_save_after>
</events>
</global>
<adminhtml>
<translate>
<modules>
<MDN_BarcodeLabel>
<files>
<default>MDN_BarcodeLabel.csv</default>
</files>
</MDN_BarcodeLabel>
</modules>
</translate>
<layout>
<updates>
<BarcodeLabel>
<file>BarcodeLabel.xml</file>
</BarcodeLabel>
</updates>
</layout>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<barcodelabel module="BarcodeLabel">
<title>Barcode label</title>
</barcodelabel>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
<events>
<core_block_abstract_prepare_layout_before>
<observers>
<BarcodeLabel_core_block_abstract_prepare_layout_before>
<class>BarcodeLabel/observer</class>
<method>addMassAction</method>
</BarcodeLabel_core_block_abstract_prepare_layout_before>
</observers>
</core_block_abstract_prepare_layout_before>
</events>
</adminhtml>
<frontend>
<secure_url>
<BarcodeLabel>/BarcodeLabel/</BarcodeLabel>
</secure_url>
<routers>
<BarcodeLabel>
<use>standard</use>
<args>
<module>MDN_BarcodeLabel</module>
<frontName>BarcodeLabel</frontName>
</args>
</BarcodeLabel>
</routers>
</frontend>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<BarcodeLabel before="Mage_Adminhtml">MDN_BarcodeLabel_Adminhtml</BarcodeLabel>
</modules>
</args>
</adminhtml>
</routers>
</admin>
...
addMassActionbut in config.xml asmodel_save_after. They should match exactly. – Adarsh Khatri Mar 14 '16 at 03:08