I try to rewrite core file from Magento. But after rewrite the block it was not accessible and I don't know why?
The File I try to rewrite is : Mage_Paypal_Block_Standard_Redirect
The xml config (locate: app/local/Ga/etc/config.xml) :
<global>
<models>
<ga>
<class>Ga_Model</class>
</ga>
</models>
<blocks>
<ga>
<class>Ga_Block</class>
</ga>
<paypal>
<rewrite>
<standard_redirect>
Ga_Block_Paypal_Standard_Redirect
</standard_redirect>
</rewrite>
</paypal>
</blocks>
<helpers>
<ga>
<class>Ga_Helper</class>
</ga>
</helpers>
</global>
The custom block (locate: app/local/Ga/Block/Paypal/Standard/Redirect.php):
class Ga_Block_Paypal_Standard_Redirect extends Mage_Paypal_Block_Standard_Redirect {
protected function _toHtml()
{
return 'test';
}
}
Paypal controller call the block like that :
public function redirectAction()
{
$session = Mage::getSingleton('checkout/session');
$session->setPaypalStandardQuoteId($session->getQuoteId());
$this->getResponse()->setBody($this->getLayout()->createBlock('paypal/standard_redirect')->toHtml());
$session->unsQuoteId();
$session->unsRedirectUrl();
}
"createBlock" method return nothing after the rewrite.
I have no idea what I'm doing wrong.
EDIT : I have found the solution. The problem come from the fact it's necessary to write the custom block class in one line like that :
<blocks>
<ga>
<class>Ga_Block</class>
</ga>
<paypal>
<rewrite>
<standard_redirect>Ga_Block_Paypal_Standard_Redirect</standard_redirect>
</rewrite>
</paypal>
</blocks>
Follow this structure
<global>
<blocks>
<paypal>
<rewrite>
<standard_redirect>MyNamespace_MyModule_Block_Standard_Redirect</standard_redirect>
</rewrite>
</paypal>
</blocks>
<global>