I'm busy with changing the product view.phtml file but I want to do it in a way to override the current view.phtml. This because there might be a possability that the file gets overwritten during an update.

Is there anyone with an example on how this can be done in my custom extension?

Many thanks again.



2 Answers 2


Overriding the view.phtml with a custom module doesn't give us much to go off, however, if you're looking to just override what a certain function or add a function to the product page, you can look to extend the core View.php file in the following path:


to do this using a custom module (Sounds like this is what your trying to do) create a config.xml file for your module and rewrite the View Block like so:

<?xml version="1.0"?>

Thats the config out the way, it is pretty self explanatory, declare your module name / version, and then inside the Global node declare the Block(s) you wish to overwrite, in our case its Mage_Catalog_Block_Product_View, notice how our class uses the same Class name just with out Namespace_Module replacing the core.

So you now want to create your block file which will be in:


Here you will extend the core class, therefore inheriting the functionality, now we can add/change functions declared in the core file. To change a function in the core file, for example if you wanted to rewrite the function for getProductDefaultQty() you would do the following:


class Some_Module_Block_Product_View extends Mage_Catalog_Block_Product_View

    public function getProductDefaultQty($product = null)
        some code to do what you want

    public function customFunction()
        look this is my own function which i can now call inside view.phtml!


As you can see above its pretty easy to over write a core file and either rewrite a core function or even add your own.

Couple of last things your module requires to work, you will need to create a module file within app/etc/modules which will be named Some_Module.xml and will contain the following:

<?xml version="1.0" encoding="UTF-8"?>

This is telling magento that your module is active and inside the codePool node its telling Magento our module is at app/code/local it can also be set to community, simply telling magento to look in app/code/community.

There is a whole lot more you can do when overriding and i have only touched on it, you could add your own layout file to declare a new template file for View.phtml if you really wanted to, this is all very easy and can be achieved by adding a couple more line to your modules config.xml file.

There is plenty out there for further reading, Alan Storm is a great help to any Magento developer starting out, we all know it can be a steep learning curve, check his articles out on his site:

Alan Storm

Another top site for tutorials and further reading on Magento is Inchoo:


Hope this has helped you on conquering the beast which is Magento, if you need any help just comment, i'll be glad to help,



this is the very magento-Standard

Go to System > Configuration > Design

Type a package name let's say "mytheme"

In file structure open a folder called "mytheme" in /app/design/frontend/

copy the path structure down to the desired .phtml file.

That's roughly about it. This procedure is well documented here: http://info2.magento.com/rs/magentoenterprise/images/magentodesignguide.pdf

  • Hi guys, Thanks for answering. I wil check the info out and post back. Cheers, Steve Commented Jan 28, 2016 at 23:39

Your Answer

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

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