0

I want to modify the backend template design/adminhtml/default/default/template/sales/order/create/totals.phtml

Its gonna be part of a module so I've implement the rewrite in the modules layout update file (app/design/adminhtml/default/default/layout/xentas_sales.xml)

<?xml version="1.0"?>
<layout version="0.1.0">

    <!-- Backend create order -->
    <adminhtml_sales_order_create_index>
        <!-- Overwrite totals template -->    
        <reference name="data">
                <block type="adminhtml/sales_order_create_totals" name="totals">
                    <action method="unsetChild"><name>totals</name></action>
                    <action method="setTemplate">
                        <template>xentas_sales/sales/order/create/totals.phtml</template>
                    </action>
                </block>
        </reference>
    </adminhtml_sales_order_create_index>
</layout>

But the new template only shows up if I refresh the "create new order" page in backend. It does not show up when I load the page in the first place.

I experience the same issue if I overwrite app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Totals.php and add to its _construct method setTemplate('...');

So it looks like there is some kind of sort order issue? How can I override an adminhtml template without creating my own admin theme and make sure its get overwritten by page load and not only by page refresh?

Thanks!

2

If you want to change only template. There are no need to change rewrite block class.

As per as,magento by reference <reference name=""> name you can change template file.So no need to rewrite block class.

<adminhtml_sales_order_create_index>
        <!-- Overwrite totals template -->    
        <reference name="totals">
                    <action method="setTemplate">
                        <template>xentas_sales/sales/order/create/totals.phtml</template>
                    </action>
        </reference>
</adminhtml_sales_order_create_index>

Also there are two handlers,this phtml are called ,so you should need to changes also there .

<adminhtml_sales_order_create_load_block_totals>
        <reference name="totals">
                    <action method="setTemplate">
                        <template>xentas_sales/sales/order/create/totals.phtml</template>
                    </action>
        </reference>
</adminhtml_sales_order_create_load_block_totals>
<adminhtml_sales_order_create_load_block_data>
        <reference name="totals">
                    <action method="setTemplate">
                        <template>xentas_sales/sales/order/create/totals.phtml</template>
                    </action>
        </reference>
</adminhtml_sales_order_create_load_block_data>

Most Important thing

You need to define xentas_sales.xml file at config.xml

  • You are awesome Amit. Thanks a lot for your detailed answer. Learned a lot. Works perfectly! – Stefan May 18 '16 at 18:53
  • Great shout Amit, had a similar problem with the address templates on create order via admin, your post helped me realise the template was defined multiple times! +1 from me :) – cygnus digital Apr 28 '17 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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