I am trying below code for login to site after entering email & password in pop up. Login is working. but pop up is not hiding after successfull login.
protected function _createProduct()
{
try {
if(isset($login) && (is_array($login) && !empty($login)) || ($login!="")){
$session->login($login['username'], $login['password']);
$result['redirect'] = $this->_getRefererUrl() ? $this->_getRefererUrl() : Mage::getUrl('customer/account', array(
'_secure' => true
));
$result['success'] = true;
Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js');
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
}
else{
$customerId = "";
}
if ($doSave)
$product->save();
return $product;
}
catch () { }
}
here.js
jQuery(".ajaxlogin-window").hide();
error
Fatal error : Call to a member function addJs() on a non-object in line
Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js');
if anyone want to look full controller code : http://pasted.co/9887d0db
1 Answer 1
Change createSimpleProductAction following code
public function createSimpleProductAction()
{
$this->loadLayout();
$product = $this->_createProduct(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
echo 'See getId() . '">created simple product';
}
That means you must need to load layout before
Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js');
answered May 5, 2017 at 7:06
Sohel Rana
36.2k3 gold badges74 silver badges94 bronze badges
-
actually i needed to use your code in proper function :
public function createSimpleProductAndRedirectAction()thanks, now the error removed , but pop up is not hiding....user52996– user529962017年05月05日 07:23:21 +00:00Commented May 5, 2017 at 7:23 -
If you use ajax, then pass value from action and make decision show/hide your div.Sohel Rana– Sohel Rana2017年05月05日 07:31:49 +00:00Commented May 5, 2017 at 7:31
-
as you said, in controller action, after code of login successfull :
$result['success'] = true;i am passing this code :Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js');& i am using jquery to hide the pop up,user52996– user529962017年05月05日 07:46:16 +00:00Commented May 5, 2017 at 7:46
default
Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js');in controller function, so that it will hide pop up after succesfull login, otherwise it will not hide pop up.....