Category: Uncategorized

If you are facing a problem like in magento admin you can’t save acl information for api / admin user, here is the solution :-

For Api User overwrite the constructor of the block Mage_Adminhtml_Block_Api_Tab_Rolesedit with following function :-

 public function __construct() {
        Mage_Adminhtml_Block_Widget_Form :: __construct();

        $rid = Mage::app()->getRequest()->getParam('rid', false);

        $resources = Mage::getModel('api/roles')->getResourcesList();

        $rules_set = Mage::getResourceModel('api/rules_collection')->getByRoles($rid)->load();

        $selrids = array();
        foreach ($rules_set->getItems() as $item) {
            //changed the code here..
            if (array_key_exists($item->getResource_id(), $resources) && $item->getPermission() == 'allow') {
                $resources[$item->getResource_id()]['checked'] = true;
                array_push($selrids, $item->getResource_id());



Magento date time

Are you using date-time functions (date(), time(),now(), etc) directly inside magento ??? Think twice man !!!

Even though time is set properly in you server or you set right timezone in your php.ini file, you might be surprised to see the result of the following code :-

//This time will not match your server time
$now = time();
echo date('m/d/y h:i:s', time());

This is because whatever settings you have in your php.ini, Magento reset timezone to ‘UTC’ in Mage_Core_Model_App.

File:- \app\code\core\Mage\Core\Model\App.php Line:-255


So, solution is set your targeted timezone in Admin->System->Configuration / General->Locale options and rather using date() function user the following code:-

$now = Mage::getModel('core/date')->timestamp(time());
echo date('m/d/y h:i:s', $now);

That’s it, have happy time with Magento 🙂 .