Magento 1.6.2 API Access Role - Bug

Posted on December 22, 2012 by Nimrod Techn There have been 0 comments

Granting API custom/full access role in Magento 1.6.2 (Web Services > Roles) simply doesn't work.
How to we fix it?

Copy app/code/core/Mage/AdminHtml/Block/Api/Tab/RolesEdit.php

To: app/code/local/Mage/AdminHtml/Block/Api/Tab/RolesEdit.php

 

Inside, place the following:

class Mage_Adminhtml_Block_Api_Tab_Rolesedit extends Mage_Adminhtml_Block_Widget_Form {

    public function __construct() {
        parent::__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) {
			if (array_key_exists(strtolower($item->getResource_id()), $resources)
                           && $item->getApiPermission() == 'allow') {
                $resources[$item->getResource_id()]['checked'] = true;
                array_push($selrids, $item->getResource_id());
            }
        }

        $this->setSelectedResources($selrids);

        $this->setTemplate('api/rolesedit.phtml');
    }
}

This post was posted in Working With Magento Collections

Magento is a well-engineered eCommerce platform designed to help engineers develop customized eCommerce online stores. Due to lack of proper coding documentation, Engineer-ing.com was created with the sole purpose of instructing Magento developers to-be with the "how-to-do" know-how. In the event of unresolved issues, you are more than welcome to contact me for consultation. However, please do so only if you possess a Software Engineering background and you're able to specify your question.