Magento:向特定资源acl可访问的“编辑产品”页面添加一个按钮

Magento:向特定资源acl可访问的“编辑产品”页面添加一个按钮,magento,button,admin,acl,product,Magento,Button,Admin,Acl,Product,我试图覆盖block Mage_Adminhtml_block_Catalog_Product_Edit,并通过以下方式创建按钮“delete_cache_Product”: protected function _prepareLayout() { parent::_prepareLayout(); $this->_product = $this->getProduct(); $this->setChild('delete_cache_

我试图覆盖block Mage_Adminhtml_block_Catalog_Product_Edit,并通过以下方式创建按钮“delete_cache_Product”:

protected function _prepareLayout()
{
    parent::_prepareLayout();
        $this->_product = $this->getProduct();
        $this->setChild('delete_cache_product',
            $this->getLayout()->createBlock('adminhtml/widget_button')
                ->setData(array(
                'label'     => Mage::helper('catalog')->__('delete cache'),
                'onclick'   => 'confirmSetLocation(\''.Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteCacheProductUrl().'\')',
                'title' => Mage::helper('catalog')->__('Delete product cache?')
            ))
        );
    return $this;
}

问题是如何将该按钮的资源acl关联起来,以便只有访问此类资源的用户才能看到该按钮?

然后创建一个带有acl的自定义管理模块

 if(Mage::getSingleton('admin/session')->isAllowed('admin/custommodulename')){
    $this->setChild('delete_cache_product',
        $this->getLayout()->createBlock('adminhtml/widget_button')
            ->setData(array(
            'label'     => Mage::helper('catalog')->__('delete cache'),
            'onclick'   => 'confirmSetLocation(\''.Mage::helper('catalog')->__('Are you sure?').'\', \''.$this->getDeleteCacheProductUrl().'\')',
            'title' => Mage::helper('catalog')->__('Delete product cache?')
        ))
    );
 }

请参见

我终于找到了解决方案:我在
adminhtml.xml
中创建了一个权限,并直接调用:

# File: adminhtml.xml
<config>
    <acl>
        <admin>
            <children>
                <catalog>
                    <children>
                        <products>
                            <children>
                                <deletecacheproduct>
                                    <title>Delete product cache</title>
                                    <sort_order>0</sort_order>
                                </deletecacheproduct>
                            </children>
                        </products>
                    </children>
                </catalog>
            </children>
            </admin>
        </resources>
    </acl>
</config>

感谢您提供此解决方案,但是有没有办法不创建新的管理模块就可以做到这一点?如果您不创建新的管理模块,您将在何处/如何设置权限?现在,要添加按钮,我正在使用catalog模块覆盖block Mage_Adminhtml_block_catalog_Product_Edit:我想知道是否有办法将权限分配给块而不是新模块??
# File: Edit.php (block)

if (Mage::getSingleton('admin/session')->isAllowed('catalog/products/deletecacheproduct')) {
    ...
}