Magento - product options view or controller file - magento

In the file $MAGENTO_PATHapp/design/frontend/base/default/template/catalog/product/view/options/wrapper.phtml, I see the following line of code:
<?php echo $this->getChildHtml('', true, true);?>
This is responsible for printing the product options on the product page. I want to understand and modify the html content that this line of code produces, but I can't seem to locate the view or controller relevant to it. For example, let's say I want to programmatically add the characters to the innerHTML of each option element in a drop down, which phtml, php or html file do I edit?
I'm hoping an answer to this question will help me understand how to retrieve product options, which in turn will help me solve this more immediate problem:
Magento - Query for Product Options

When passing an empty value to any of the getChild functions all the children are used. In this case getChildHtml(''... returns the result of each of their toHtml outputs.
To find out what it's children are we need to refer to the catalog.xml layout file:
<block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label">
<label>Info Column Options Wrapper</label>
<block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/>
<block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
<action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action>
<action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action>
<action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action>
<action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action>
</block>
<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
</block>
You might be able to see from that jumbled mess that your wrapper block has an 'options' grandchild which has several renderers for the different types of possible options. For the drop-down you'll probably need to edit catalog/product/view/options/type/select.phtml.

Related

How to display category post on custom template in Magento Fishpig?

I'm having two post categories in my project, and both categories are using different views. I'm using fishpig plugin to add and categorize post, But both the category posts are using the same view.phtml template for displaying the post.
<wordpress_post_view>
<reference name="content">
<block type="wordpress/post_view" name="wp.post.view" template="wordpress/post/view.phtml">
<block type="core/text_list" name="post.content.before" as="before_post_content" />
<block type="core/text_list" name="post.content.after" as="after_post_content">
<block type="wordpress/post_meta" name="wp.post.view.meta" as="meta" after="-" template="wordpress/post/meta.phtml">
<action method="setDisplayPreviousNextLinks"><display>1</display></action>
</block>
</block>
<block type="wordpress/post_view_comment_wrapper" name="wp.post.view.comments" as="comments" template="wordpress/post/view/comment/wrapper.phtml">
<block type="wordpress/post_view_comments" name="wp.post.view.comments.list" as="comment_list" template="wordpress/post/view/comments.phtml" />
<block type="wordpress/post_view_comment_pager" name="wp.post.view.comments.pager" as="pager"/>
<block type="wordpress/post_view_comment_form" name="wp.post.view.comments.form" as="form" template="wordpress/post/view/comment/form.phtml">
<block type="core/text_list" name="wp.post.view.comments.form.before_end" as="before_form_end" />
</block>
</block>
</block>
</reference>
</wordpress_post_view>
Is there any way to split up the post view?
The best way to do this would be to use 2 different post types rather than splitting the posts by category. This would allow you to have a separate template for each post type quite easily.
If you want to use categories, you would need to customise the view.phtml and add a check to see what category the current post is in and then display the appropriate content.

How to get Product item count in layered navigation on advanced search result page?

Actually I want display product attributes item count on product list page but when I call
<block type="catalog/layer_view" name="catalog.leftnav" template="catalog/layer/view.phtml">
XML block in advanced search result page in catalogsearch.xml I got wrong item count on left side. Please suggest me how to get proper count of attributes?
I think you can load category model using categoryId and then call getProductCount function like this:
$categoryData = Mage::getModel('catelog/category')->load($categoryId)->getProductCount();
echo $categoryData;
This shall print your product count in this particular category. You can use block or your template to run your code, or in run-time you may also use your controller using an AJAX call.
Follow this steps:
Open catalogsearch.xml from your theme's layout directory.
Search the keyword catalogsearch_advanced_result
Set below code between opening and closing tag of catalogsearch_advanced_result
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>

get error messages in content area on cart page Magento

HI i have made a module in which i have a controller which adds product to the cart through url . I have add a error messages from controller if the product is not valid.
The problem is the error message is shown above the content area .I need to show those in the content area.I have also tried to add these blocks in
checkout.xml in content area
<reference name="content">
<block type="checkout/cart" name="checkout.cart">
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
but still it not loads the messages in the content area and show above the content area. Can you please suggest me how can i do this.
What are you using to generate these errors - default magento handlers? they generate errors just above the breadcrumb area.
One option would be to give it a id/class and manipulate through javascript.
OR,
Generate custom errors.
You can either unset/re-add blocks as needed with the following methods:
<action method="unsetChild"><name>global_notices</name></action>
<action method="unsetChild"><name>global_messages</name></action>
<action method="unsetChild"><name>messages</name></action>
<block type="page/html_notices" name="global_notices" as="global_notices" template="page/html/notices.phtml" />
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
If adding these as needed using template hints to confirm does not work, find the following line in
app\design\frontend\base\default\template\checkout\cart.phtml
<?php echo $this->getMessagesBlock()->toHtml() ?>
And comment it out/move it to where you wish to render it.

Magento: Show two products on the product page

I would like to show two different products on the product view page. Basically, after displaying the first product like it normally would, the page should then show another product with all it's details, images and of course the "Add to Cart" button.
Both products should be fully displayed on the product view page, so I can't use any of the existing blocks like catalog/product_list_related or catalog/product_list_upsell.
My idea was to simply add another catalog/product_view block to the catalog_product_view layout definition, like so:
catalog.xml:
<layout version="0.1.0">
...
<catalog_product_view translate="label">
...
<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
...
</block>
</reference>
...
<!-- Changes start here -->
<reference name="content">
<block type="catalog/product_view" name="product.info2" template="catalog/product/view.phtml">
<action method="setProductId"><product_id>123</product_id></action>
</block>
</reference>
</catalog_product_view>
However, this does not seem to work. Various elements of the block don't seem to load correctly, as you can see on this screenshot:
All the product images are missing as well as the price and the buttons. Also, my call to setProductId() doesn't seem to have any effect.
You can delete this catalog.xml, then magento usa base catalog.xml

Adding Cart to top.menu in Magento

I'm building a navigation bar that includes the user menu and cart along with the wishlist but trying to figure out how one would add it in the xml mockup to include it using the getChildHtml function.
XML file: page.xml
<block type="page/html_header" name="header" as="header">
I have
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
Now as far as I can see I have to include the following somewhere or extend the block or something not really sure, please help me in the right direction or even point me to a developers guide that would cover this.
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
Create a file local.xml in your theme folder app/design/frontend/your_package/your_theme/layout/
add the following lines and save the file.
<layout version="0.1.0">
<default>
<reference name="top.menu">
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
</reference>
</default></layout>
Don't forget to clear magento cache(System->Cache management) after applying the change.
In order to learn more about Magento blocks ,layouts ,templates there is an official magento guide check it here

Resources