简体   繁体   中英

Magento: overriding Adminhtml template causes memory limit exhaustion

I'm trying to override a phtml file within Magento's admin area. Specifically, the file I'm trying to override is: app/design/adminhtml/default/default/template/catalog/form/renderer/fieldset/element.phtml

In app/code/local/CompanyName/Website/etc/config.xml , I have:

<rewrite>
    <catalog_form_renderer_fieldset_element>CompanyName_Website_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element</catalog_form_renderer_fieldset_element>
</rewrite>

The overriding block PHP file I have placed into app/code/local/CompanyName/Website/Block/Adminhtml/Catalog/Form/Renderer/Fieldset/Element.php . This file contains:

<?php

class CompanyName_Website_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
{
    public function _construct()
    {
        parent::_construct();

        $this->setTemplate('catalog/form/renderer/fieldset/element.phtml');
    }
}

Finally, the overriding template file is at app/design/frontend/enterprise/CompanyName/template/catalog/form/renderer/fieldset/element.phtml and contains the actual template I'm overriding.

I get a white screen and in the log there's this error: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 227543041 bytes) in /var/www/html/gold/lib/Varien/Object.php on line 569

Any thoughts? Am I extending the right class? Files placed correctly? Etc. There are other <rewrite> blocks inside the same config.xml file which work just fine so I must be making a mistake!

Thanks.

This is odd for a couple of reasons.

It seems that you are merely interested in changing the template of this block. Why not just override its default template 'widget/form/renderer/fieldset/element.phtml'?

Are you sure you don't have something like print_r($someObject->getData()); somewhere in your constructor or template?

Further Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element::_construct() merely sets the template file, so probably no reason to call parent::_construct().

Have you set some error_log()'s around in your constructor and template file to make sure they are being called? What is the full path to that template? Namely is it something like /app/design/adminhtml/default/default...? or /app/design/adminhtml/company/...? If the later, I assume you have the suitable config in place to allow for adminhtml template override?

What is going on in line 569 of /lib/Varien/Object.php? (mine must be a different version because that line is in a comment and its around stuff that doesn't seem relevant)


EDIT: To override an adminhtml template. Add this to the < config > node in /app/etc/local.xml

<stores>
    <admin>
        <design>
            <package>
                <name>default</name>
            </package>
            <theme>
                <default>companyname</default>
            </theme>
        </design>
    </admin>
</stores>

Now make a folder in /app/design/adminhtml/default/ named 'companyname' and put 'template', 'layout' etc. folders inside it as you would any theme. eg /app/design/adminhtml/default/companyname/template/widget/form/renderer/fieldset/element.phtml for your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM