0

I want to override the standard phtml when you edit a product in magento admin.

File to override: C:\wamp64\www\regimeproteine\app\design\adminhtml\default\default\template\catalog\form\renderer\fieldset\element.phtml

I have created a module:

File: C:\wamp64\www\regimeproteine\app\etc\modules\Pro10_Adminshopscope.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Pro10_Adminshopscope>
            <active>true</active>
            <codePool>local</codePool>
        </Pro10_Adminshopscope>
    </modules>
</config>

File: C:\wamp64\www\regimeproteine\app\code\local\Pro10\Adminshopscope\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Pro10_Adminshopscope>
            <version>1.0</version>
        </Pro10_Adminshopscope>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <catalog_form_renderer_fieldset_element>Pro10_Adminshopscope_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element</catalog_form_renderer_fieldset_element>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

> The file that will override the original:

C:\wamp64\www\regimeproteine\app\code\local\Pro10\Adminshopscope\Block\Adminhtml\Catalog\Form\Renderer\Fieldset\Element.phtml

This result in a blanco page, if I remove or rename the target, the default element.phtml is used.

I changed these files for mor info about the error

C:\wamp64\www\regimeproteine\app\code\core\Mage\Core\Model\Layout.php C:\wamp64\www\regimeproteine\app\code\core\Mage\Core\Model\Config.php

the log files:

exception 'Mage_Core_Exception' with message 'invalid block type: Pro10_Adminshopscope_element' in C:\wamp64\www\regimeproteine\app\Mage.php:597

3 Answers 3

0

Method 1 If you want to change phtml file, you can define your own admin theme in app\code\local\Pro10\Adminshopscope\etc\config.xml

<config>
    <stores>
        <admin>
            <design>
                <package>
                    <name>default</name>
                </package>
                <theme>
                    <default>your_theme</default>
                </theme>
            </design>
        </admin>
    </stores>
    <modules>
        <Pro10_Adminshopscope>
            <version>1.0</version>
        </Pro10_Adminshopscope>
    </modules>
    <!-- and so on -->
</config>

Then copy original app\design\adminhtml\default\default\template\catalog\form\renderer\fieldset\element.phtml to app\design\adminhtml\default\your_theme\template\catalog\form\renderer\fieldset\element.phtml

Method 2 If you need to change something in the block Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element, then your config will look something like this:

<config>
    <modules>
        <Pro10_Adminshopscope>
            <version>1.0</version>
        </Pro10_Adminshopscope>
    </modules>
    <global>
        <blocks>
            <adminshopscope>
                <class>Pro10_Adminshopscope_Block</class>
            </adminshopscope>
            <adminhtml>
                <rewrite>
                    <catalog_form_renderer_fieldset_element>Pro10_Adminshopscope_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element</catalog_form_renderer_fieldset_element>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>   
</config>

In your block app\code\local\Pro10\Adminshopscope\Block\Adminhtml\Catalog\Form\Renderer\Fieldset\Element.php, you should set the template like so:

class Pro10_Adminshopscope_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
{
    protected function _construct()
    {
        return $this->setTemplate('adminshopscope/catalog/form/renderer/fieldset/element.phtml');
    }
}

Lastly, you need to create the file app\design\adminhtml\default\default\template\adminshopscope\catalog\form\renderer\fieldset\element.phtml

1
  • Thanks Kiatng, I used solution 2, and it works. Only 1 remark: file: "Element.php" <?php class Pro10_Adminshopscope_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element { protected function _construct() { return $this->setTemplate('adminshopscope/catalog/form/renderer/fieldset/element.phtml'); } } ?> You forgot "class" Apr 30, 2018 at 12:23
0

Small adustment:

Element.php: app\code\local\Pro10\Adminshopscope\Block\Adminhtml\Catalog\Form\Renderer\Fieldset\Element.php, "class" forgotten before Pro10_Admin....:

class Pro10_Adminshopscope_Block_Adminhtml_Catalog_Form_Renderer_Fieldset_Element extends Mage_Adminhtml_Block_Catalog_Form_Renderer_Fieldset_Element
{
    protected function _construct()
    {
        return $this->setTemplate('adminshopscope/catalog/form/renderer/fieldset/element.phtml');
    }
}
0

other question: how can I use a custom style.css file in this case?

edit file app\code\local\Pro10\Adminshopscope\etc\config.xml?

1
  • You use method 1 to set the package and theme for the admin layout area. Then you add the file skin\adminhtml\default\your_theme\boxes.css. Note that the file name is not style.css. However, you can add additional style file in your layout xml file if you wish. You can google on how to do that.
    – kiatng
    May 2, 2018 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.