We are allowing guest to create an account with help of below function
<form action="<?php echo $this->getUrl('productlike/index/create',
array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on')))
?>" method="post" id="ajaxlogin-create-form">
controllers
app/code/local/Outthink/ProductLike/controllers - Indexcontroller.php
class Outthink_ProductLike_IndexController extends Mage_Core_Controller_Front_Action {
public function createAction(){ }
}
we are using same function code in another module as below, but its not working
<form action="<?php echo $this->getUrl('example/Amasty/create1',
array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on')))
?>" method="post" id="ajaxlogin-create-form">
app/code/local/Amasty/Example/controllers - Amastycontrollers.php
class Amasty_Example_AmastyController extends Mage_Core_Controller_Front_Action {
public function create1Action(){ }
}
Is this right way ? I dont want to rewrite same controller action because i need some other feature with the functions.
update
Fatal error Call to undefined method Amasty_Example_AmastyController::_getCustomer()
in line $customer = $this->_getCustomer();
public function create1Action()
{
// Clear the messages each time we call it
Mage::getSingleton('core/session')->getMessages(true);
$session = Mage::getSingleton('customer/session');
if ($session->isLoggedIn()) {
return;
}
$session->setEscapeMessages(true); // prevent XSS injection in user input
if (!$this->getRequest()->isPost()) {
return;
}
$result = array(
'success' => false
);
$customer = $this->_getCustomer();
try {
$errors = $this->_getCustomerErrors($customer);
if (empty($errors)) {
if (version_compare(Mage::getVersion(),"1.9.1.0",">="))
{
// Only from 1.9.1.0
$customer->cleanPasswordsValidationData();
}
$customer->save();
Mage::dispatchEvent('customer_register_success',
array('account_controller' => $this, 'customer' => $customer)
);
$result['redirect'] = $this->_successProcessRegistration($customer);
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$productId=$this->getRequest()->getPost('product_id');
$likeProduct=Mage::getModel('productlike/productlike')->getCollection()
->addFieldToSelect('fav_id')
->addFieldToFilter('product_id',$productId)
->addFieldToFilter('customer_id',$customerId)->load();
/*
*/
$result['success'] = true;
}
} catch (Mage_Core_Exception $e) {
}
catch (Exception $e) {
// $result['error'] = $this->__('Cannot save the customer.');
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
example/amasty/create1
instead of thisexample/Amasty/create1
http://1234.com/example/amasty/create1
, it gave blank page......