Advertisement

Thursday 18 April 2013

Difference Between Overloading and Overriding

Overloading:
In Simple words, Same function name but different signature(Parameters)



Ex:

class Maths{

function sum($a, $b) {

$c=$a+$b;
return c; 

}

function sum($a, $b, $c) {           //PARAMETERS DIFFERS

$d=$a+$b+$c;
 return $d;
}


}



Overriding(Polyphormism):
Same Function Name, same signature, different functionality.




Ex:

class Maths{

function sum($a, $b) {

$c=$a+$b;
return c; 

}
 
}

Class Another extends Maths{


function sum($a, $b) {

$c=$a-$b;                            // FUNCTIONALITY DIFFERS
return c; 

}
}

Tuesday 9 April 2013

Magento Redirect After Login Not Working - FIXED

1. Go to

           System > Configuration > Customers > Customer Configuration > Login Options

            Make it as NO



2. To Redirect to previous page after login. Go to page login.phtml and replace form action i.e. line 40 or if you are using mini login than go to page mini.login.phtml and replace form action i.e. line 28 with the one given here.


Replace with:

          
<form action="<?php echo $this->getPostActionUrl() ?>" method="post"> 


to:

<form action="<?php echo str_replace('login', 'loginPost', $this->helper('customer')->getLoginUrl()) ?>"  
method="post" id="login-form">

Monday 4 March 2013

Magento - 404 Error

How to find Error in Magento 1.7.2:


1. Enable the Developer Mode :

            Go to Index.php


1. Enable The Developer Mode:

Now the error may be like this:


simplexml_load_string() [function.simplexml-load-string]:
 Entity: line 1: 
parser error : 
XML declaration allowed only at the start of the document 
in C:\wamp\www\{MY PROJ}\app\code\core\Mage\Core\Model\Layout\Update.php on line 445

2. Enable the Log in index.php:

Mage::log(print_r($filename, true));

find Last error in /var/cache/system.log

That's it!