Wednesday, May 29, 2013

How to reset magento Admin user, role and resources permission to all?

scenario 1: All resource permissions were set to none for the admin role
Solution:
Step 1: Get current admin role details
SELECT * FROM admin_role WHERE role_name = 'Administrators' 
/*Administrators - is  Your admin role name*/
Step 2: Remove Existing permissions for the Admin role
/*clean all permission rules*/
DELETE admin_rule
 FROM admin_rule, admin_role
WHERE 
 admin_role.role_name = 'Administrators' /* Your admin role name*/
 AND admin_rule.role_id = admin_role.role_id
Step 3: Update Permission rule for the admin role
INSERT INTO admin_rule (role_id, resource_id, assert_id, role_type, permission)
VALUES ('1','all', '0', 'G', 'allow')
scenario 2: Admin was assignd to a wron role
Solution:
Step 1: Load your user information
    
  SELECT ar.*, au.*
  FROM admin_user AS au
  INNER JOIN admin_role AS ar ON (au.user_id = ar.user_id)
  WHERE au.username = 'username'
Step 2: Load Role information
SELECT * FROM admin_role WHERE role_type = 'G'
Step 3:Update your user for the proper role
UPDATE admin_role SET parent_id = [put selected role_id here] WHERE user_id = [your USER id]

Tuesday, May 21, 2013

How to post data using curl / Zend_Http_Client

using curl
$data = array("name" => "Hagrid", "age" => "36");     
$jsonData = json_encode($data);
$handle = curl_init();
$url = 'http://magento.com/customer/account/login';
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
using Zend_Http_Client
// new HTTP request to some HTTP address
$client = new Zend_Http_Client($url);
// set some parameters
$client->setParameterPost('data', $jsonData);
// POST request
$client->request(Zend_Http_Client::POST);

Tuesday, April 30, 2013

How to get store configuration data from Magento System Configuration?

$configData = Mage::getStoreConfig(
                   'sectionName/groupName/fieldName',
                   Mage::app()->getStore()
               ); 

Wednesday, April 17, 2013

How to create custom page in my account magento page

In your module's config file include your custom layout files using layout updates.

    
 
            
                
                    preferredlocation.xml
                
            
        
   

In your custom layout file include the below script(preferredlocation.xml).
 
  
    
        Preferred Locationpreferredlocation/edit
    
  
    
      
         
          
              
    
 

Display my account navigation links in my account sidebar

In your custom layout file include the below script.
 
  
    
        Preferred Locationpreferredlocation/edit
    
  
    
      
         
          
              
    
 

Thursday, October 11, 2012

Can not login to magento admin and frontend

Im using centos. I had a problem, Magento frontend and admin login doesn’t work and loops back to login with no message. This happens because of session cookie problem. I solved this problem by installing ntp

In your shell type the below command to install ntp

    # yum install ntp

Turn on ntp service

    # chkconfig ntpd on

Synchronize system clock with 0.pool.ntp.org server:

    # ntpdate pool.ntp.org

Start the NTP service:

    # /etc/init.d/ntpd start
 
Now check whether this has solved the cookie problem. If not try the following. comment the below lines in "/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php".

if (!$cookieParams['httponly']) {
 unset($cookieParams['httponly']);
 if (!$cookieParams['secure']) {
  unset($cookieParams['secure']);
  if (!$cookieParams['domain']) {
   unset($cookieParams['domain']);
  }
 }
}

if (isset($cookieParams['domain'])) {
 $cookieParams['domain'] = $cookie->getDomain();
}

Wednesday, April 11, 2012