Reputation: 227
I'm tryin to override Mage/Catalog/Block/Product/Abstract.php .
Assume that my module named Abc.
Here is my app/etc/modules/Abc_Catalog.xml
<?xml version="1.0"?>
<config>
<modules>
<Abc_Catalog>
<active>true</active>
<codePool>local</codePool>
</Abc_Catalog>
</modules>
</config>
Here is my code/local/Abc/Catalog/etc/config.xml
<?xml version="1.0"?>
<config>
<global>
<blocks>
<catalog>
<rewrite><product_abstract>Abc_Catalog_Block_Product_Abstract</product_abstract></rewrite>
</catalog>
</blocks>
</global>
</config>
Here is my code/local/Abc/Catalog/Product/Abstract.php
include_once "Mage/Catalog/Block/Product/Abstract.php";
class Abc_Catalog_Block_Product_Abstract extends Mage_Catalog_Block_Product_Abstract
{
public function getAddToCartUrl($product, $additional = array())
{
echo 'here'; exit;
/*if ($product->getTypeInstance(true)->hasRequiredOptions($product)) {
if (!isset($additional['_escape'])) {
$additional['_escape'] = true;
}
if (!isset($additional['_query'])) {
$additional['_query'] = array();
}
$additional['_query']['options'] = 'cart';
return $this->getProductUrl($product, $additional);
}*/
return $this->helper('checkout/cart')->getAddUrl($product, $additional);
}
}
But its doesn't work. What i'm doing wrong?
Upvotes: 0
Views: 1472
Reputation: 5993
You can create a same folder/file structure for that abstract class you wish to override.
i.e.: /local/Mage/Customer/Model/Address/Abstract.php
and write that entire class exactly equal as the original (with all methods), and change what you need.
No additional .xml is required, only the file on the specified folder. But remember: when upgrading Magento maybe you need to review this file.
Upvotes: 0
Reputation: 4978
In Magento it is not possible to rewrite an Abstract block in the traditional way. Can't you rewrite the class that is extending the abstract one?
Upvotes: 1