Avenir | Drupal Development | Joomla Development | Magento Development | OsCommerce Development
Showing posts with label add item. Show all posts
Showing posts with label add item. Show all posts

Tuesday, 27 March 2012

How to create a new Magento customer account from an external site?


<?php
require_once ("/your/magento/app/Mage.php");
umask(0);
?>

<?php

// Customer Information
$firstname = "John";
$lastname = "Smith";
$email = "johnsmith@localhost.local";
$password = "myverysecretpassword";

// Website and Store details
$websiteId = Mage::app()->getWebsite()->getId();
$store = Mage::app()->getStore();

$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId;
$customer->setStore($store);

try {
// If new, save customer information
$customer->firstname = $firstname;
$customer->lastname = $lastname;
$customer->email = $email;
$customer->password_hash = md5($password);
if($customer->save()){
echo $customer->firstname." ".$customer->lastname." information is saved!";
}else{
echo "An error occured while saving customer";
}
}catch(Exception $e){

// If customer already exists, initiate login
if(preg_match('/Customer email already exists/', $e)){
$customer->loadByEmail($email);

$session = Mage::getSingleton('customer/session');
$session->login($email, $password);

echo $session->isLoggedIn() ? $session->getCustomer()->getName().' is online!' : 'not logged in';
}
}

?>

Monday, 5 March 2012

To remove the ADD item button in the created custom module in the magento admin panel

To remove the ADD item button in the created custom module in the magento admin panel

File path:app/code/local/Samplemod/Samplemod/Block/Adminhtml/Samplemod.php

<?php
class Customer_Customerdetails_Block_Adminhtml_Customerdetails extends Mage_Adminhtml_Block_Widget_Grid_Container
{
  public function __construct()
  {
    $this->_controller = 'adminhtml_customerdetails';
    $this->_blockGroup = 'customerdetails';
  $this->_headerText = Mage::helper('customerdetails')->__('Item Manager');
   // $this->_addButtonLabel = Mage::helper('customerdetails')->__('Add Item');
    parent::__construct();
     $this->_removeButton('add');
  }
} ?>