Browsing articles tagged with "admin Archives - Kalpesh Mehta"
Jul 13, 2013
kalpesh

Magento system config 404 error

Magento gives 404 error / Forbidden error / Access denied error when you try to open the screen of your newly written config/system XML code because either of 2 reasons.

1.) You have written the code CORRECTLY, but Magento needs to write permissions for that module in session to show it.
– Just logout and login again and you should see your newly developed screen.

2.) You have some error in your ACL role code. Magento needs the ACL role information to allow admin view the admin module.
– Check your ACL code definition again and make sure everything there is correct.

Sample code of ACL to display custom menu item in navigation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<config>
    <acl>
        <resources>
            <all>
                <title>Allow everything</title>
            </all>
            <admin>
                <children>
                    <mycustommenu translate="title" module="modulename">
                        <title>Custom MENU</title>
                        <sort_order>500</sort_order>
                        <children>
                            <!-- child items go here -->
                            <submenuitem translate="title" module="modulename">
                                <title>Custom SUB MENU</title>
                                <sort_order>10</sort_order>
                            </submenuitem>
                        </children>
                    </mycustommenu>
                </children>
            </admin>
        </resources>
    </acl>
</config>

Continue reading »

May 22, 2013
kalpesh

Magento Recoverable Error Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website

Magento Recoverable Error: Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in /var/www/xxx/app/code/core/Mage/Core/Model/App.php on line 634 and defined in /var/www/xxx/app/code/core/Mage/Core/Model/Store.php on line 395

When migrating Magento site from old server to new server, this error often occurs and appears in var/log/system.log. It prevents your Magento Admin to load JS and CSS files hence your admin panel becomes skinless.

The solution to get rid of this and load JS and CSS files is to run the following mysql commands in Mysql console or phpMyAdmin.

1
2
3
4
5
6
SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;

What the above mysql commands does is:
– Disables foreign key checks on tables so that you don’t get any foreign key errors while executing immediate update queries.
– Updates store, store_group and website tables with ID = 0, for admin user

Once the above set of queries are executed, don’t forget to clear cache to reflect your changes.

Jul 10, 2011
kalpesh

Magento: Show only specific attributes in layered navigation

In Magento, if you have lots of attributes (e.g. Type, Size, Price, Color, etc.) defined for categories, all are shown in the layered navigation on the left side. This may be sometimes annoying as they may break the website design. It is possible to disable the desired attributes from displaying on frontend.

The solution is, go to:

– Magento Backend -> Catalog Tab -> Attributes -> Manage Attributes
– Click the attributes you do not want to display in layered navigation
– Select NO where it says “Use in Layered Navigation”
– Save

Now all the attributes with Use in Layered Navation as Yes will only show in frontend Shopping options.

Jun 19, 2011
kalpesh

Magento: Checking customer/admin is logged in or not

The most important part in magento development is to check whether customer is logged in or not in the system. So that you can show specific features and extra privileges to your customers. There are many things that are restricted to the guests, while members can see the special privilege things.

Also if the customer is not logged in, we can show a link like “Log in”; while for logged in customers, we can show link like “Log out”, “My account”, etc. This is already present in Magento, but we may want to add more features to our customers. So here is the code where you can check customer is logged in or not.

This will check whether the customer is logged in the magento system or not.

1
2
3
4
5
6
7
$session=Mage::getSingleton('customer/session', array('name'=>'frontend') );

if ($session->isLoggedIn()) {
    echo "Welcome, ".$session->getCustomer()->getName();
} else {
    echo "Not logged in";
}

This will check whether admin is logged in or not in a magento site.

1
2
3
4
5
6
7
$adminsession = Mage::getSingleton('admin/session', array('name'=>'adminhtml'));

if($adminsession->isLoggedIn()) {
    echo "Welcome Admin";
} else {
    echo "Not logged in";
}

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications