I have created a few custom modules for Magento and when I try to assign permissions to the module (check the checkbox) when I click save it unchecks the box.
Anyone have any ideas? It sort of sounds like there is something off in my config.xml file so I will post it here just in case:
<config>
<modules>
<Wpe_Vendorlist>
<version>0.1.0</version>
</Wpe_Vendorlist>
</modules>
<admin>
<routers>
<vendorlist>
<use>admin</use>
<args>
<module>Wpe_Vendorlist</module>
<frontName>vendorlist</frontName>
</args>
</vendorlist>
</routers>
</admin>
<adminhtml>
<menu>
<customer>
<children>
<items module="vendorlist">
<title>SO Vendor List</title>
<sort_order>999</sort_order>
<action>vendorlist/adminhtml_vendorlist</action>
</items>
</children>
</customer>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Wpe_Vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</Wpe_Vendorlist>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<vendorlist>
<file>vendorlist.xml</file>
</vendorlist>
</updates>
</layout>
</adminhtml>
<global>
<models>
<vendorlist>
<class>Wpe_Vendorlist_Model</class>
<resourceModel>vendorlist_mysql4</resourceModel>
</vendorlist>
<vendorlist_mysql4>
<class>Wpe_Vendorlist_Model_Mysql4</class>
<entities>
<vendorlist>
<table>vendorlist</table>
</vendorlist>
</entities>
</vendorlist_mysql4>
</models>
<resources>
<vendorlist_setup>
<setup>
<module>Wpe_Vendorlist</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</vendorlist_setup>
<vendorlist_write>
<connection>
<use>core_write</use>
</connection>
</vendorlist_write>
<vendorlist_read>
<connection>
<use>core_read</use>
</connection>
</vendorlist_read>
</resources>
<blocks>
<vendorlist>
<class>Wpe_Vendorlist_Block</class>
</vendorlist>
</blocks>
<helpers>
<vendorlist>
<class>Wpe_Vendorlist_Helper</class>
</vendorlist>
</helpers>
</global>
</config>
I strongly recomend you to take a look at Alan Storm's article about system configuration, and the rest of his serie, it's the best info I've found about magento programing.
For this particular question, here is how I've done it in my module, with your module name:
<acl><!-- permits -->
<resources>
<admin>
<children>
<customer translate="title" module="vendorlist"><!-- this tag matches the menu tag, and the same for his children -->
<title>what will appears in the checkboxes tree when you create a role</title>
<children>
<firstchild>
<title>what will appears in the checkboxes tree when you create a role</title>
</firstchild>
</children>
</customer>
</children>
</admin>
</resources>
</acl>
You won't need the:
<children>
<firstchild>
<title>what will appears in the checkboxes tree when you create a role</title>
</firstchild>
</children>
as you don't have children in your module, it seems, I just put it as an example.
I hope this helps
Please change your config.xml and replace
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Wpe_Vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</Wpe_Vendorlist>
</children>
</admin>
</resources>
</acl>
with
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</vendorlist>
</children>
</admin>
</resources>
</acl>
Only need to change vendorlist after children tag instead of Wpe_Vendorlist. This change worked for me in my custom module,hope may help others also.
You should use only lower case characters in your resource and menu item names. See the constructor on app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php
public function __construct()
{
...
foreach ($rules_set->getItems() as $item) {
$itemResourceId = $item->getResource_id();
if (array_key_exists(strtolower($itemResourceId), $resources) && $item->getPermission() == 'allow') {
$resources[$itemResourceId]['checked'] = true;
array_push($selrids, $itemResourceId);
}
}
....
I would also suggest you consider moving the acl and menu info to adminhtml.xml instead of having it on config.xml.
Another issue is that you should have exactly the same structure in both menu and acl trees, so your acl reflects the menu structure and magento knows what to enable when a permission is given to a role. There's a great article by Ivan Chepurnyi about this here
So, after the changes, you would end up with someting similar to this, on adminhtml.xml:
<adminhtml>
<menu>
<customer>
<children>
<wpe_vendorlist module="vendorlist">
<title>SO Vendor List</title>
<sort_order>999</sort_order>
<action>vendorlist/adminhtml_vendorlist</action>
</wpe_vendorlist>
</children>
</customer>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<customer>
<children>
<wpe_vendorlist>
<title>Vendorlist Module</title>
<sort_order>10</sort_order>
</wpe_vendorlist>
</children>
</customer>
</children>
</admin>
</resources>
</acl>
</adminhtml>
I found something from magento forum. Go to the following link:
http://www.magentocommerce.com/boards/viewthread/78673/
But still can't set permission to these custom modules from newly created roles.
These custom modules didn't appear in main menu for that newly created roles' users.
after changing syntax in acl tag module is displayed in custom module permission
Related
I am using a module which calculates the shipping method based on item weight. The module appears to install but if I make an edit to the main class, nothing seems to be reflected on the front end.
The main class extends the Mage_Shipping_Model_Carrier_Abstract see below:
<?php
class Laurensmedia_Advancedshipping_Model_Carrier_Advancedshipping
extends Mage_Shipping_Model_Carrier_Abstract
implements Mage_Shipping_Model_Carrier_Interface
{
protected $_code = 'advancedshipping';
The config.xml file looks like this:
<?xml version="1.0"?>
<config>
<modules>
<Laurensmedia_Advancedshipping>
<version>0.1.0</version>
</Laurensmedia_Advancedshipping>
</modules>
<global>
<helpers>
<advancedshipping>
<class>Laurensmedia_Advancedshipping_Helper</class>
</advancedshipping>
</helpers>
<blocks>
<advancedshipping>
<class>Laurensmedia_Advancedshipping_Block</class>
</advancedshipping>
</blocks>
<models>
<advancedshipping>
<class>Laurensmedia_Advancedshipping_Model</class>
<resourceModel>advancedshipping_mysql4</resourceModel>
</advancedshipping>
<advancedshipping_mysql4>
<class>Laurensmedia_Advancedshipping_Model_Mysql4</class>
<entities>
<matrix>
<table>advancedshipping_matrix</table>
</matrix>
</entities>
</advancedshipping_mysql4>
<shipping>
<rewrite>
<shipping>Laurensmedia_Advancedshipping_Model_Shipping_Shipping</shipping>
</rewrite>
</shipping>
</models>
<resources>
<advancedshipping_setup>
<setup>
<module>Laurensmedia_Advancedshipping</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</advancedshipping_setup>
<advancedshipping_write>
<connection>
<use>core_write</use>
</connection>
</advancedshipping_write>
<advancedshipping_read>
<connection>
<use>core_read</use>
</connection>
</advancedshipping_read>
</resources>
</global>
<admin>
<routers>
<advancedshipping>
<use>admin</use>
<args>
<module>Laurensmedia_Advancedshipping</module>
<frontName>advancedshipping</frontName>
</args>
</advancedshipping>
</routers>
</admin>
<adminhtml>
<menu>
<advancedshipping module="advancedshipping">
<title>Advancedshipping</title>
<sort_order>100</sort_order>
<children>
<matrix module="advancedshipping">
<title>Manage Matrix</title>
<sort_order>0</sort_order>
<action>advancedshipping/adminhtml_matrix</action>
</matrix>
<import module="advancedshipping">
<title>Import from CSV</title>
<sort_order>1</sort_order>
<action>advancedshipping/adminhtml_matrix/import</action>
</import>
<settings>
<title>Manage Settings</title>
<sort_order>999</sort_order>
<action>adminhtml/system_config/edit/section/lm_advancedshipping</action>
</settings>
</children>
</advancedshipping>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<advancedshipping translate="title" module="advancedshipping">
<title>Advancedshipping</title>
<sort_order>1000</sort_order>
<children>
<matrix translate="title">
<title>Manage Matrix</title>
<sort_order>0</sort_order>
</matrix>
<import translate="title">
<title>Import from CSV</title>
<sort_order>1</sort_order>
</import>
<settings translate="title">
<title>Manage Settings</title>
<sort_order>999</sort_order>
</settings>
</children>
</advancedshipping>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<advancedshipping>
<file>advancedshipping.xml</file>
</advancedshipping>
</updates>
</layout>
</adminhtml>
<default>
<carriers>
<advancedshipping>
<active>1</active>
<model>advancedshipping/carrier_advancedshipping</model>
<name>Advanced Shipping</name>
<title>Laurensmedia</title>
<description>Laurensmedia Advanced Shipping description</description>
<sort_order>0</sort_order>
</advancedshipping>
</carriers>
</default>
</config>
I have tried the following:
Clearing the Magneto cache
Manually deleting the contents of /var/cache/
Copying all of the other modules to ../disabled/ (Effectively
disabling them)
None of the above seems to have worked. Can anyone offer any suggestions as to why when I edit the main class file nothing happens? Even if I deliberately break the file (i.e - delete half the code) I don't even see any errors.
I don't see a <rewrite> declared for Laurensmedia_Advancedshipping_Model_Carrier_Advancedshipping in the config.
That would explain why it's not being picked up, since it appears to want to rewrite a standard Magento class.
If it's not intended as a rewrite, how is that class being called?
I am new to magento and making a custom module and want to work on admin end but after installing extension I get this error:
Fatal error: Class 'Submitdigital_CustomLogo_Helper_Data' not found in /var/zpanel/hostdata/zadmin/public_html/unisport_com/app/Mage.php on line 547
After insatalling extension when I clear cashe it give me this error. After somestudy I found that the error is due to this file at path:
app/code/local/Submitdigital/CustomLogo/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Submitdigital_CustomLogo>
<version>0.1.0</version>
</Submitdigital_CustomLogo>
</modules>
<global>
<helpers>
<customlogo>
<class>Submitdigital_CustomLogo_Helper</class>
</customlogo>
</helpers>
<blocks>
<customlogo>
<class>Submitdigital_CustomLogo_Block</class>
</customlogo>
</blocks>
<models>
<customlogo>
<class>Submitdigital_CustomLogo_Model</class>
<resourceModel>customlogo_mysql4</resourceModel>
</customlogo>
<customlogo_mysql4>
<class>Submitdigital_CustomLogo_Model_Mysql4</class>
<entities>
<customlogo>
<table>customlogo</table>
</customlogo>
</entities>
</customlogo_mysql4>
</models>
<resources>
<customlogo_setup>
<setup>
<module>Submitdigital_CustomLogo</module>
<class>Mage_Eav_Model_Entity_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customlogo_setup>
<customlogo_write>
<connection>
<use>core_write</use>
</connection>
</customlogo_write>
<customlogo_read>
<connection>
<use>core_read</use>
</connection>
</customlogo_read>
</resources>
</global>
<admin>
<routers>
<admin_customlogo>
<use>admin</use>
<args>
<module>Submitdigital_CustomLogo</module>
<frontName>admin_customlogo</frontName>
</args>
</admin_customlogo>
</routers>
</admin>
<adminhtml>
<menu>
<customlogo module="customlogo">
<title>SubmitDigital</title>
<sort_order>100</sort_order>
<children>
<customlogo module="customlogo">
<title>Manage Customlogo</title>
<sort_order>0</sort_order>
<action>customlogo/adminhtml_customlogo</action>
</customlogo>
</children>
</customlogo>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<customlogo translate="title" module="customlogo">
<title>SubmitDigital</title>
<sort_order>1000</sort_order>
<children>
<customlogo translate="title">
<title>Manage Customlogo</title>
<sort_order>0</sort_order>
</customlogo>
</children>
</customlogo>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<customlogo>
<file>customlogo.xml</file>
</customlogo>
</updates>
</layout>
</adminhtml>
<frontend>
<routers>
<customlogo>
<use>standard</use>
<args>
<module>Submitdigital_CustomLogo</module>
<frontName>customlogo</frontName>
</args>
</customlogo>
</routers>
<layout>
<updates>
<customlogo>
<file>customlogo.xml</file>
</customlogo>
</updates>
</layout>
</frontend>
</config>
all goes well with the file but when I add <adminhtml>...</adminhtml> in the file it gives the above error and hence I am not able to see anything at my admin end.
Please Help
here is my customlogo.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<customlogo_adminhtml_customlogo_index>
<reference name="content">
<block type="customlogo/adminhtml_customlogo" name="customlogo" />
</reference>
</customlogo_adminhtml_customlogo_index>
</layout>
You have to create the helper class to fix this issue.
app/code/local/Submitdigital/CustomLogo/Helper/Data.php
class Submitdigital_CustomLogo_Helper_Data extends Mage_Core_Helper_Abstract
{
}
You have the following code to call the helper
<customlogo module="customlogo">
Here
module parameter is used to call the helper for translation.
I am having a custom module. I want it to appear in the permissions section. I define menus in my config.xml file as -
<config>
<modules>
<Inventory_Uploads>
<version>1.4.0</version>
</Inventory_Uploads>
</modules>
<frontend>
<routers>
<uploads>
<use>standard</use>
<args>
<module>Inventory_Uploads</module>
<frontName>uploads</frontName>
</args>
</uploads>
</routers>
<layout>
<updates>
<uploads>
<file>uploads.xml</file>
</uploads>
</updates>
</layout>
</frontend>
<admin>
<routers>
<uploads>
<use>admin</use>
<args>
<module>Inventory_Uploads</module>
<frontName>uploads</frontName>
</args>
</uploads>
</routers>
</admin>
<adminhtml>
<menu>
<uploads module="uploads">
<title>Band Config</title>
<sort_order>71</sort_order>
<children>
<sub_menu1 translate="title">
<title>Config Menu</title>
<sort_order>10</sort_order>
<action>uploads/adminhtml_uploads</action>
</sub_menu1>
</children>
</uploads>
</menu>
<acl>
<resources>
<admin>
<children>
<uploads translate="title" module="uploads">
<title>Band Config</title>
<sort_order>71</sort_order>
<action>uploads/adminhtml_uploads</action>
<children>
<items module="uploads">
<title>Config Menu</title>
<sort_order>10</sort_order>
<action>uploads/adminhtml_uploads</action>
</items>
</children>
</uploads>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<uploads>
<file>uploads.xml</file>
</uploads>
</updates>
</layout>
</adminhtml>
<global>
<models>
<uploads>
<class>Inventory_Uploads_Model</class>
<resourceModel>uploads_mysql4</resourceModel>
</uploads>
<uploads_mysql4>
<class>Inventory_Uploads_Model_Mysql4</class>
<entities>
<order><table>admin_user</table></order>
</entities>
</uploads_mysql4>
</models>
<resources>
<uploads_setup>
<setup>
<module>Inventory_Uploads</module>
<class>Mage_Sales_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</uploads_setup>
<uploads_write>
<connection>
<use>core_write</use>
</connection>
</uploads_write>
<uploads_read>
<connection>
<use>core_read</use>
</connection>
</uploads_read>
</resources>
<blocks>
<uploads>
<class>Inventory_Uploads_Block</class>
</uploads>
</blocks>
<helpers>
<uploads>
<class>Inventory_Uploads_Helper</class>
</uploads>
</helpers>
</global>
</config>
It appears in the permission section. When I select them and save, they gets saved properly. But when I assign that role to any user and login then sub-menu not appears there. It only shows "Band Config" as menu but does not show it's submenu "Config Menu". Is there any tag error in xml?
Any help appreciated.
Thanks.
The name of the children in section must be the same as defined in your section, sub_menu1.
Try with this configuration :
<acl>
<resources>
<admin>
<children>
<uploads translate="title" module="uploads">
<title>Band Config</title>
<sort_order>71</sort_order>
<action>uploads/adminhtml_uploads</action>
<children>
<sub_menu1 module="uploads">
<title>Config Menu</title>
<sort_order>10</sort_order>
<action>uploads/adminhtml_uploads</action>
</sub_menu1>
</children>
</uploads>
</children>
</admin>
</resources>
</acl>
I want to add a section in magento dashboard for a particular user type with user add/edit/delete facility, so I have created a module for magento Admin but it not diplay in Admin menu.
I want to display association menu in magento admin.
Although it is displaying in system -> config ->advance to give enable/disable facility.
The config xml is.
0.1.0
<global>
<models>
<association>
<class>yanga_association_Model</class>
<resourceModel>association_mysql4</resourceModel>
</association>
<association_mysql4>
<class>yanga_association_Model_Mysql4</class>
<entities>
<association>
<table>association</table>
</association>
</entities>
</association_mysql4>
</models>
<resources>
<association_setup>
<setup>
<module>yanga_association</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</association_setup>
<association_write>
<connection>
<use>core_write</use>
</connection>
</association_write>
<association_read>
<connection>
<use>core_read</use>
</connection>
</association_read>
</resources>
<blocks>
<association>
<class>yanga_association_Block</class>
</association>
</blocks>
<helpers>
<association>
<class>yanga_association_Helper</class>
</association>
</helpers>
</global>
<admin>
<routers>
<association>
<use>admin</use>
<args>
<module>Yanga_Association</module>
<frontName>association</frontName>
</args>
</association>
</routers>
</admin>
<adminhtml>
<menu>
<association module="association">
<title>Association</title>
<sort_order>71</sort_order>
<children>
<items module="association">
<title>Manage Association</title>
<sort_order>0</sort_order>
<action>association/adminhtml_association</action>
</items>
</children>
</association>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<Association>
<title>Association Module</title>
<sort_order>10</sort_order>
</Association>
</children>
</config>
</children>
</system>
<Yanga_Association>
<title>System Configuration Tab</title>
<sort_order>10</sort_order>
</yanga_Association>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<association>
<file>association.xml</file>
</association>
</updates>
</layout>
</adminhtml>
Kindly provide us the solution if have.
Thanks in advance.
If you are trying to access sytem settings than you have to code like
<config translate="title">
<title>Configuration</title>
<sort_order>1</sort_order>
<action>adminhtml/system_config/edit/section/association</action>
</config>
Instead of .Replace this code with and check it.Hops it works
You forgot to add your menu's permission in your acl declaration, your ACL should look like this -:
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<system>
<children>
<config>
<children>
<Association>
<title>Association Module</title>
<sort_order>10</sort_order>
</Association>
</children>
</config>
</children>
</system>
<association>
<title>Association</title>
<children>
<items translate="title" module="association">
<title>Manage Association</title>
</items>
</children>
</association>
<Yanga_Association>
<title>System Configuration Tab</title>
<sort_order>10</sort_order>
</yanga_Association>
</children>
</admin>
</resources>
</acl>`
Hope it helps!
Cheers
S
I’ve created a custom module and my config.xml is as follows…
<?xml version="1.0"?>
<config>
<admin>
<routers>
<blacklist>
<use>admin</use>
<args>
<module>Leon_Blacklist</module>
<frontName>blacklist</frontName>
</args>
</blacklist>
</routers>
</admin>
<adminhtml>
<menu>
<blacklist translate="title" module="blacklist">
<title>Blacklist</title>
<sort_order>71</sort_order>
<children>
<items translate="title" module="blacklist">
<title>Manage Items</title>
<sort_order>0</sort_order>
<action>blacklist/adminhtml_blacklist</action>
</items>
</children>
</blacklist>
</menu>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Leon_Blacklist translate="title" module="blacklist">
<title>Blacklist Module</title>
<sort_order>10</sort_order>
<children>
<items translate="title" module="blacklist">
<title>Manage Items</title>
</items>
</children>
</Leon_Blacklist>
</children>
</admin>
</resources>
</acl>
<layout>
<updates>
<blacklist>
<file>blacklist.xml</file>
</blacklist>
</updates>
</layout>
</adminhtml>
<config>
The module works as expected if an admin account is logged in. I can see the module in the admin panel and in the Role Resource Tab (System->Permissions->Roles), but when I tried to check the module and save the user role, it will say that it has been saved. But when I rechecked the user role, it is still unchecked.
And when I tried to login using the account with the said user role, the custom module is hidden. What seems to be the problem? Any kind of help is much appreciated..
Thanks.
Your acl section of config is a little wrong. Tags should be similar to menu section. So in your case it should look like this:
<acl>
<resources>
<admin>
<children>
<blacklist translate="title" module="blacklist">
<title>Blacklist Module</title>
<sort_order>10</sort_order>
<children>
<items translate="title" module="blacklist">
<title>Manage Items</title>
</items>
</children>
</blacklist>
</children>
</admin>
</resources>
</acl>
Here is my acl section of config.xml
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<banner translate="title" module="banner">
<title>Banner Module</title>
<sort_order>10</sort_order>
<children>
<banner translate="title" module="banner">
<title>Manage Banners</title>
</banner>
</children>
</banner>
</children>
</admin>
</resources>
</acl>
Also add the below function in your controller to avoid the "Access denied" message
protected function _isAllowed(){
return true;
}
Code taken from: http://chandreshrana.blogspot.in/2015/06/custom-module-role-not-save-in.html