Your approach is almost correct.
Two things:
1. Set a new template instead of instantiating a new block
Instead of just assigning a different template to the product.info
block, you are creating a new instance with the same name, replacing the original instance, and then the new template is set on that. Instead use this:
<mymodule_product_index>
<update handle="catalog_product_view" />
<reference name="product.info">
<action method="setTemplate">
<template>mymodule/product.phtml</template>
</action>
</reference>
</mymodule_product_index>
That should take care of the product view template in a clean way.
2. Handle processing order
If you look at where the view block product.info.bundle
for the bundled products is declared, you will see it happens in the bundle.xml file, in a layout update handle called <PRODUCT_TYPE_bundle>
.
Your code is referencing the block from the <[route]_[controller]_[action]>
layout handle, i.e. <mymodule_product_index>
.
The thing to be aware of here is the processing order of layout handles.
Roughly it is:
<default>
<[route]_[controller]_[action]>
<custom_handles>
The <PRODUCT_TYPE_bundle>
handle belongs to the third type of layout handles, which means it is processed after the <mymodule_product_index>
handle.
In essence, you are referencing the block product.info.bundle
before it has been declared.
To fix this you will need to use the <PRODUCT_TYPE_bundle>
handle as well. Of course this will effect every bundled product display. Using layout XML only there is no clean way around that.
Here are a few suggestions how to solve that problem.
You could create a separate route in your module to show the bundled products, and then include the <PRODUCT_TYPE_bundle>
handle using an update
directive for that page, too.
In your custom action controller, you could add another layout update handle that is processed after <PRODUCT_TYPE_bundle>
.
You could use an event observer to set the template on the product.info.bundle
block if it is instantiated. One possibility would be the event controller_action_layout_generate_blocks_after
.
You get the idea, there are many ways to work around this, but they require PHP.
You are getting no errors when uncommenting because Magento just doesn't try to call the block :) So this a silent error...
Indeed, as says the error, Magento is trying to reach file frontend/base/default/template/cartonplugin/cartondisplay.phtml which means that your design configuration is (I guess) not correct if the file frontend/default/nationwide/template/cartonplugin/cartondisplay.phtml really exists.
So, are you sure your package / theme is correctly configured in the system configuration, design tab? Make sure that package is "default" and theme templates is "nationwide".
Something like the picture below is a good configuration to tell Magento to call templates that reside in frontend/default/nationwide/template/ instead of frontend/base/default/template/ (may need some fine tuning depending on your existing configuration and store views)
Best Answer
For understanding more about magento block types following are some built-in block types which are widely used in layout.
core/template
: This block renders a template defined by itstemplate
attribute. The majority of blocks defined in the layout are of type or subtype ofcore/template
.page/html
: This is a subtype ofcore/template
and defines the root block. All other blocks are child blocks of this block.page/html_head
: Defines the HTML head section of the page which contains elements for including JavaScript, CSS etc.page/html_header
: Defines the header part of the page which contains the site logo, top links, etc.page/template_links
: This block is used to create a list of links. Links visible in the footer and header area use this block type.core/text_list
: Some blocks likecontent
,left
,right
etc. are of typecore/text_list
. When these blocks are rendered, all their child blocks are rendered automatically without the need to call thegetChildHtml()
method.page/html_wrapper
: This block is used to create a wrapper block which renders its child blocks inside an HTML tag set by the actionsetHtmlTagName
. The default tag is<div>
if no element is set.page/html_breadcrumbs
: This block defines breadcrumbs on the page.page/html_footer
: Defines footer area of page which contains footer links, copyright message etc.core/messages
: This block renders error/success/notice messages.page/switch
: This block can be used for the language or store switcher.This is a list of only commonly used block types. There are many other block types which are used in advanced theme implementations.