Error setting an adminhtml from a frontend path
-
10-03-2021 - |
Question
I'm using a third-party which set an appendPaymentBlock
Observer method
<adminhtml>
<events>
<payment_info_block_prepare_specific_information>
<observers>
<realex_payment_information>
<type>singleton</type>
<class>realex/observer</class>
<method>appendPaymentBlock</method>
</realex_payment_information>
</observers>
</payment_info_block_prepare_specific_information>
...
</events>
...
</adminhtml>
Basically, this method set a template:
public function appendPaymentBlock(Varien_Event_Observer $observer)
{
...
$paymentInfoBlock
->setPayment($payment)
->setPaymentInfo($paymentData)
->setTemplate('realex/payment/info/payment-info.phtml');
$block->append($paymentInfoBlock);
}
payment-info.phtml
script is at app/design/adminhtml/default/default/template/
path.
This is causing me the following critical error:
CRIT (2): Not valid template file:frontend/base/default/template/realex/payment/info/payment-info.phtml
How I can get this template from adminhtml and not from frontend folder?
Solution
Most likely the $paymentInfoBlock class extends
Mage_Core_Block_Template
and not Mage_Adminhtml_Block_Template
.
Specifically to your extension, replacing
$blockType = 'core/template';
with
$blockType = 'adminhtml/template';
should do the trick.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange