0

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));
    }
16
  • try this example/amasty/create1 instead of this example/Amasty/create1 – Kingshuk Deb Apr 25 '17 at 7:57
  • tried now, no luck..... – raj Apr 25 '17 at 8:00
  • If you hit the url directly in browser does that work? – Kingshuk Deb Apr 25 '17 at 8:02
  • Try $block->getUrl('example/amasty/create1') – Kishan Patadia Apr 25 '17 at 8:54
  • @KingshukDeb i tried as http://1234.com/example/amasty/create1 , it gave blank page...... – raj Apr 25 '17 at 9:10
1

Please paste missing functions code in your controller file. The code is in other file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.