I am trying to extend Mage_Adminhtml_Block_Customer_Edit_Tab_View
class in order to pass in some functions and display them using a layout update in
adminhtml/default/default/template/namespace/mymodule/edit/tab/view.phtml
I've used a rewrite in my config.xml
<blocks>
<mymodule>
<class>Mymodule_Customer_Block</class>
</mymodule>
<adminhtml>
<rewrite>
<customer_edit_tab_view>Mymodule_Customer_Block_Adminhtml_Customer_Edit_Tab_View</customer_edit_tab_view>
</rewrite>
</adminhtml>
</blocks>
And here is the View.php
file
class Mymodule_Customer_Block_Adminhtml_Customer_Edit_Tab_View extends Mage_Adminhtml_Block_Customer_Edit_Tab_View
{
public function getCredit(){
$customerId = $this->getCustomer()->getId();
$model = Mage::registry('current_customer');
$customerId = $model->getId();
$data = $model->getData();
$helper = Mage::helper('customercredit');
$creditValue = (float)$helper->getCreditValue($customerId, $model->getWebsiteId());
return $creditValue;
}
}
Whenever I go to view the customer edit view tab in magento admin I get an error:
Wrong tab configuration.
I must have missed something out of my setup but I am not sure what?
Any one have any idea please let me know…
Best Answer
You'll need to do a little detective work. It's very possible a different change is responsible for the error you're seeing, or that something about your replacement triggers this error.
To start, I'd remove any custom functions you have in
Mymodule_Customer_Block_Adminhtml_Customer_Edit_Tab_View
and concentrate on getting the class rewrite working without aWrong tab Configuration
exception — that way if the error is tied to a method you've added, you'll know which one when you add your methods back one by one.The exception you're seeing comes from this method
And occurs when Magento can't instantiate a tab from information passed into
addTab
. My guess is your error comes from this bit of layout XML incatalog.xml
Although adding some temporary debugging to the
addTab
method above will help with thatIf that's the case, it sounds like Magento may be having trouble instantiating your new block class. I'd try running the following code
and looking for instantiation errors (each call should return a block object).
My best guess as to why this is happening is you have your
View.php
file forMymodule_Customer_Block_Adminhtml_Customer_Edit_Tab_View
created in the wrong folder.Good luck!