I try to rewrite core file from magento. Somehow it does not overwrite the code. I try to overwrite the function getProduct().
Tipfix/Block/Product/View.php
<?php
class WP_Tipfix_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
{
public function getProduct()
{
if (!Mage::registry('product') && $this->getProductId()) {
$product = Mage::getModel('catalog/product')->load($this->getProductId());
Mage::register('product', $product);
}
//return Mage::registry('product');
}
}
Tipfix/etc/config.xml
<blocks>
<WP_Tipfix>
<class>WP_Tipfix_Block</class>
</WP_Tipfix>
<catalog>
<rewrite>
<product_view>WP_Tipfix_Block_Catalog_Product_View</product_view>
</rewrite>
</catalog>
</blocks>
I have know idea what i'm doing wrong.
Gr. Lex
Your class is WP_Tipfix_Block_Catalog_Product_View
which means it must be in the folder WP/Tipfix/Block/Catalog/Product/View.php
. You must either move your Product directory into a new directory called Catalog in that place or rename your class (both the class and in the XML) to WP_Tipfix_Block_Product_View
. I recommend moving the file.
Please change the config.xml
content of your module to this, and I'm sure that it should work:-
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<WP_Tipfix>
<version>1.0.0</version>
</WP_Tipfix>
</modules>
<global>
<blocks>
<wptipfix>
<class>WP_Tipfix_Block</class>
</wptipfix>
<catalog>
<rewrite>
<product_view>WP_Tipfix_Block_Catalog_Product_View</product_view>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Hope it helps.
UPDATE:- After Ben's comment, I feel that I should have mentioned that the OP must also use the solution as mentioned by Max in his answer. So the OP will need a combined effort to fix his problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With