Guest User

Untitled

a guest
Jun 11th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Path to the root of your magento installation.
  5. * include traing slash.
  6. */
  7. $root = '/PATH/TO/YOUR/MAGENTOINSTALLATION/';
  8.  
  9. /**
  10. * Username that has the rights to import products.
  11. */
  12. $username = 'USERNAME';
  13.  
  14. /**
  15. * Password
  16. */
  17. $password = 'PASSWORD';
  18.  
  19.  
  20.  
  21. /**
  22. * DO NOT EDIT BELOW THIS LINE
  23. */
  24. //getting Magento
  25. require_once $root.'app/Mage.php';
  26. ob_implicit_flush();
  27. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  28.  
  29. //starting the import
  30.  
  31. Mage::getSingleton("admin/session", array("name"=>"adminhtml"));
  32. $session = Mage::getSingleton("admin/session");
  33.  
  34. try
  35. {
  36. $session->login($username, $password);
  37. } catch(Exception $e) {
  38. echo 'Message: ' .$e->getMessage();
  39. }
  40.  
  41. if(! $session->isLoggedIn())
  42. {
  43. Mage::log(convert(memory_get_usage()) . " - " . "Could not log in with '$username'", null, $logFileName);
  44. exit;
  45. }
  46.  
  47. $sessionId = $session->getEncryptedSessionId();
  48. $formKey = Mage::getSingleton('core/session')->getFormKey();
  49.  
  50. echo json_encode(array('sessionId' => $sessionId, 'formKey' => $formKey));
Add Comment
Please, Sign In to add comment