Tag Archives: Block

Magento Override Block

1) Change the directory to magento installation

2) vi app/etc/modules/Phpcodez_Checkout.xml and paste the below given code
<?xml version=”1.0″?>
<config>
<modules>
<Phpcodez_Checkout>
<active>true</active>
<codePool>local</codePool>
</Phpcodez_Checkout>
</modules>
</config>
3) mkdir app/code/local/Phpcodez
4) mkdir app/code/local/Phpcodez/Checkout
5) mkdir app/code/local/Phpcodez/Checkout/etc
6) mkdir app/code/local/Phpcodez/Checkout/Block
7) vi app/code/local/Phpcodez/Checkout/etc/config.xml and paste the below given code
<?xml version=”1.0″?>
<config>
<modules>
<Phpcodez_Checkout>
<version>0.1.0</version>
</Phpcodez_Checkout>
</modules>
<global>
<blocks>
<checkout>
<rewrite>
<links>Phpcodez_Checkout_Block_Links</links>
</rewrite>
</checkout>
</blocks>
</global>
</config>

8) vi app/code/local/Phpcodez/Checkout/Block/Links.php and paste here the below given code
<?php
class Phpcodez_Checkout_Block_Links extends Mage_Checkout_Block_Links{
public function addCheckoutLink() {

if (!$this->helper(‘checkout’)->canOnepageCheckout()) {
return $this;
}

$parentBlock = $this->getParentBlock();
if ($parentBlock && Mage::helper(‘core’)->isModuleOutputEnabled(‘Mage_Checkout’)) {
$text = $this->__(‘Checkout Overriden’);
$parentBlock->addLink(
$text, ‘checkout’, $text,
true, array(‘_secure’ => true), 60, null,
‘class=”top-link-checkout”‘
);
}
return $this;
}
}
?>