Magento Coding Solutions

Magento Get Admin Url with key


echo Mage::helper("adminhtml")->getUrl("module_name/action_name/");
Example :

Mage::helper("adminhtml")->getUrl("Ordermanager/adminhtml_ordermanagerbackend/");
Ordermanager:=module_name
adminhtml_ordermanagerbackend = my Module action_name

see below in xml
from : app\code\local\Ordermanager\Ordermanager\etc\config.xml

<menu>
 <ordermanager module="ordermanager">
<title>Ordermanager</title>
<sort_order>100</sort_order>
<children>
 <ordermanagerbackend module="ordermanager">
<title>Backend Page Title</title>
<sort_order>0</sort_order>
<action>ordermanager/adminhtml_ordermanagerbackend</action>
 </ordermanagerbackend>
 <ordermanager module="ordermanager">
   <title>Manage Ordermanager</title>
<sort_order>0</sort_order>
<action>ordermanager/adminhtml_ordermanager</action>
 </ordermanager>
</children>
 </ordermanager>
</menu>

magento login programmatically

<?php $email="customer email address";
 $password="customer password";

 $session = Mage::getSingleton('customer/session');
 $message=""; //error message to add to session

 try {
  $session->login( $email, $password );
  if ($session->getCustomer()->getIsJustConfirmed()) {
  //Customer is confirmed and successfully logged in
  }
 } catch (Mage_Core_Exception $e) {
  //error occured
  switch ($e->getCode()) {
  case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
  //email not confirmed actions here
  break;
  case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
  //Email or password invalid actions here
  $message = $e->getMessage();//echo the error message
  break;
  default:
  $message = $e->getMessage(); //Display other error messages
  }
  $session->addError($message);
 } catch (Exception $e) {
  //login failed because of some other error.
 }?>