Please refer @jruzafa answer for more details. This is just to provide more details on how we can achieve this in "best way" as he mentioned in his answer.
This is how you need to rewrite this block in your config.xml
file
File : app\code\local\Example\Mymodule\etc\config.xml
<config>
<global>
<blocks>
<wishlist>
<rewrite>
<customer_wishlist_item_options>Example_Mymodule_Block_Customer_Wishlist_Item_Options</customer_wishlist_item_options>
</rewrite>
</wishlist>
</blocks>
</global>
</config>
Now Define your Options.php
like this.
File: app\code\local\Example\Mymodule\Block\Customer\Wishlist\Item\Options.php
<?php
class Example_Mymodule_Block_Customer_Wishlist_Item_Options
extends Mage_Wishlist_Block_Customer_Wishlist_Item_Options
{
public function getTemplate()
{
$template = Mage_Wishlist_Block_Abstract::getTemplate();
if ($template) {
return $template;
}
$item = $this->getItem();
// If $item is it not instance of Mage_Wishlist_Block_Customer_Wishlist_Item_Options
if ($item instanceof Mage_Wishlist_Block_Customer_Wishlist_Item_Options){
$data = $this->getOptionsRenderCfg($item->getProduct()->getTypeId());
if (empty($data['template'])) {
$data = $this->getOptionsRenderCfg('default');
}
} else {
$data = $this->getOptionsRenderCfg('default');
}
return empty($data['template']) ? '' : $data['template'];
}
}
A small change in this approach is this line :
$template = Mage_Wishlist_Block_Abstract::getTemplate();
As you can see it replaces parent::getTemplate();
. This is because parent::getTemplate()
will call Mage_Wishlist_Block_Customer_Wishlist_Item_Options::getTemplate()
and hence you will again get same error. In order to avoid that we are using the real parent class directly.