Sep 21, 2011

Magento: How to check if has access to page?

Syntax:



Mage::getSingleton('admin/session')
->isAllowed('[resource_item1_path]/[resource_item1_child_path]')

Example:



$adminSession = Mage::getSingleton('admin/session');
// Checks the permission for managing of products
$adminSession->isAllowed('admin/catalog/products');

// Checks the permission for the order creation in Magento Admin
$adminSession->isAllowed('sales/order/create');

// Checks the permission for the order view in Magento Admin
$adminSession->isAllowed('sales/order/view'));


Reference:
Defining acl resources custom and admin menu

No comments: