looking to show product reviews in sidebar on product page magento - magento

I'm looking to show the most recent reviews for a product (maybe 3 or 4) in the sidebar on that products page in magento.
Showing the first 10 or 15 words of the review, the star bar and a link to the reviews page to see all the reviews..
any advice or pointers greatly appreciated,
Thanks,
Johnny

As ElGabby said, creating a extension would be the way to go.
But you can do this by editing your current layout.
Go to the file catalog.xml in /app/design/frontend/default/[your theme]/layout/ or /app/design/frontend/base/[your theme]/layout/
find the section:
<catalog_product_view>
in there you proberly have a section like:
<reference name="right">
in that section add:
<block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />
the section in my example look like this:
<reference name="right">
<block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>
save the file and create a new file in:
/app/design/frontend/default/[your theme]/design/review/rightbar.phtml
content of that file would be something like:
<?php $collection = $this->getReviewsCollection(); ?>
<?php if(count($collection) > 0):?>
<?php foreach ($collection as $rating):?>
<?php echo $rating->title //title of the rewiev?>
<?php echo $rating->detail //content of the rewiev?>
<?php echo $rating->created_at //data rewiev is created?>
<?php endforeach;?>
<?php endif;?>

I would create an extension.
Using layout.xml place your block that should extend core/template block in left/right sidebar of the product page
Within that block class you should have methods that will retrieve from the database the reviews you wish to display. So say for instance you would need a method getReviews()
In the template call $this->getReviews() and iterate the result and display the reviews as you would like. The star bar might be a bit of a hassle but if you look at other template files where they are used you should be able to get the gist of it :)
HTH :)

Related

How to add custom content on Magento Catalog page under each product name?

I have created a custom module that attaches some information to each product. Now, I want to show the custom information on Catalog page under product name.
Here is snapshot to show you what I am trying to do.
Here is my layout xml
<?xml version="1.0"?>
<!--
/**
* Custom module
*/
-->
<layout>
<catalog_category_default translate="label">
<reference name="name.after">
<block type="catalog/product_list" name="custom_content" template="custommodule/default.phtml"/>
</reference>
</catalog_category_default>
</layout>
But this is not working. Is it possible to render custom content under product name without modifying any .phtml files?
Many Thanks!
I'm aware that this is a quick and dirty hack that more diligent magento devs will sneer at, but it will give you the result you want and is easy for you to impliment
The 'correct' solution probably involves writing a custom block and calling it in the foreach loop of your app/design/frontend/YourPackage/YourTheme/template/product/list.phtml - however, I can offer you a quick and dirty hackaround that shouldn't tax you too much. You can do it very easily by abusing the product attributes system.
First create a new product attribute in the attribute set used by your product.
We'll use this to store the custom content we want to inject between your product name and price. For the sake of this example we'll call it customcontent. Make sure you set the attribute's Visible on "Product View Page on Front-end" value to 'No'.
Edit your product and set this new attribute equal to your desired custom content - it's fine you use html tags in here too. By default, product attributes have (for some reason) an arbitrary limit of 30 characters but if you need it to hold a longer string you can easily change this by editing app/code/mage/eav/model/entity/Attribute.php and changing the value of ATTRIBUTE_CODE_MAX_LENGTH.
Then in your app/design/frontend/YourPackage/YourTheme/template/product/list.phtml and find the following line of code somewhere around line 49
<?php foreach ($_productCollection as $_product): ?>
directly after it insert the following:
<?php $_customcontent =$_product->getResource()->getAttribute('customcontent')->getFrontend()->getValue($_product);?>
You've now stored the string from your products customcontent attribute in a variable called $_customcontent
So if you find the following line in your list.phtml
<h2 class="product-name"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></h2>
you can easily add a new paragraph or heading beneath it and populate it with your custom content using
<?php echo $_customcontent ?>
I know this probably represents a deeply unorthodox solution, but it does work and can be acheived very quickly, and without requiring you to know anything about writing your own custom blocks.
Can you try :
<catalog_categoryd_default>
<reference name="content">
<block type="catalog/product_list" name="custom_content" template="custommodule/default.phtml" after="nameofTheNameBlock"/>
</reference>
</catalog_categoryd_default>

How can I add a new tab in product page in magento

The default tabs in my product page are Product Description, Reviews and Tags (which was changed for testing purposes to -> Hello there). So I've managed to change the default name of one of the tabs, but i don't seem to remember where I made the change. Also I think there could be a more "Cleaner" way to achieve the same.
Regardless of the way to achieve it, I'd like to know how to add a new custom tab with custom product attributes to it.
You can find my sample product page here.
For example if you want to add tabs that will give you main description, a secondary description and then another tab that will have specific vehicle fitment data.
it's pretty easy. First of all you need to create phtml file for your new tab. Let it be info.phtml. Then add tab init section to xml file (as described in the article):
<action method="addTab" module="catalog" translate="title">
<alias>info</alias>
<title>Info</title>
<block>catalog/product_view_attributes</block>
<template>catalog/product/view/info.phtml</template>
</action>
Inside of the phtml file you need to call:
<?php $product = $this->getProduct() ?>
Now you are able to output any product's attribute in this file:
Description:
<?php echo $product->getDescription() ?>
Special Price:
<?php echo $product->getSpecialPrice() ?>
if you want to read in detail you can go throw link
Here is a good explanation about how to create additional tabs on product page : http://www.atwix.com/magento/adding-tabs-on-the-product-page/
To rename something on frontend, the easiest way is to set "Enabled for Frontend" in "System -> Configuration -> Advanced -> Developer -> Translate inline" to "yes" and then go to frontend and translate whatever you want, including tab names.
PS: translate inline doesn't work in Chrome.
you can check your app\design\frontend[your project]\default\layout\catalog.xml
in magento 1.9 you can see the xml like this
<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Description</value></action>
</block>
and you can add another like this
<block type="catalog/product_view_description" name="product.new.tab" as="new.tab" template="catalog/product/view/description.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>New Tab</value></action>
</block>
and remeber this
template="catalog/product/view/description.phtml"
it is location for your html view on app\design\frontend[your project]\default\template
you can check your app\design\frontend[your project]\default\layout\catalog.xml & Find this line.
<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Description</value></action>
</block>
under this line. Add this code
<block type="catalog/product_view_attributes" name="product.sizes" as="sizes" template="catalog/product/view/sizes.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Store Locator</value></action>
And create your own size.phtml file & save catalog/product/view/sizes.phtml & add this code.
<?php $_product = $this->getProduct();
$attribute = $_product->getResource()->getAttribute('store_locator');
if ( is_object($attribute) ) {
$identifier = $_product->getData("store_locator");
}?>
<?php if ($_sizeBlock = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($identifier)): ?>
<div class="std">
<?php echo $_sizeBlock->toHtml() ?>
</div>
<?php endif; ?>
clear cache & Reload your browser Now See finally your own tab But your code is not see yet becoz you need to create attribute & which static block want to see put identifier name in attribute.
Adding your custom tab to magento is not very difficult need to play with attributes, block and phtml you can get a brief description
here
Hope this will help.

Magento: how to add content to <?php echo $this->getChildHtml('outer-right') ?>

I'm still struggling with magento.
I have a 3 column layout but want to place yet another
widget in the outer right of the content with
<?php echo $this->getChildHtml('outer-right') ?> .
How do I create a .phtml file with the stuff to be output
when <?php echo $this->getChildHtml('outer-right') ?>
is invoked?
Thanks.
You just need to add/stuff your blocks via your layout.xml file inside a block called 'outer-right' in the correct layout handle. When your layout handle is active you will be able to fetch its html by getChildHtml('outer-right')
<cms_index_index>
<block type="core/template" name="outer-right" template="xyz.phtml">
<block type="core/template" name="inside-outer-right-1" template="inside.phtml"/>
<block type="core/template" name="inside-outer-right-2" template="inside2.phtml"/>
</block>
</cms_index_index>

Magento - moving extension from left/right column to main

I try to move an ext: Customers who bought this product also purchased from default left/right column to main column under the product, but I don't know how to do this.
I try to change the line <product_detail_leftposition translate="label"> to <product_page translate="label"> in system.xml file but it doesn't help.
Any suggestions?
Thanks for any help!
You can do this by adding it to the Products view page section inside your layout XML. Add the block inside the content reference block, somewhere at the bottom.
Make sure it's inside the handle as this defines the structure used on the product view page.
app/design/frontend/[namespace]/[themename]/layout/catalog.xml
<catalog_product_view translate="label">
...
<reference name="content">
...
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<!-- Other blocks etc here.. add at the bottom -->
<block type="module/block" name="yourblock" as="yourblock" />
</block>
</reference>
</catalog_product_view>
This should automatically output the block for you if you add it in here, although that depends on the theme you are using.
if it doesn't automatically show, you may need to add a line to your view to display the block:
app/design/frontend/[namespace]/[themename]/template/catalog/product/view.phtml
<?php // use the block name used in the XML config.. ?>
<?php echo $this->getChildHtml('yourblock') ?>

Hide toolbar elements on specific Magento category page

I have a custom homepage on my Magento store which displays the latest 150 added products, with the most recent first.
The paging on the toolbar is needed here (30 per page, 5 pages) but the "sort by" and the "Show" number to display are both irrelevant.
The page is constructed using Tridian New Arrivals code (google it), with a minor tweak to sort the collection by entity_id descending, as the created_at sort (suggested in the article) seems to not work correctly.
So this is basically a home page redirect to a category page, which has an over-ride in place to display a specific product collection (the new arrivals).
Could someone show me how to hide those two select lists on just this page please?
Cheers,
Rob
Theoretically this is possible with a layout update in the category design, but it has not been so easy:
http://www.magentocommerce.com/boards/v/viewthread/46823/#t331000
You can create a new theme that consists of just the files needed to be changed to get rid of the toolbar (hacked phtml file) and then set the custom design for this category to this theme. It will use your default theme to fill in the gaps, e.g. header, footer etc.
I resolved this in code, in toolbar.phtml, as follows:
First I set a current category variable at the start of the code (mine is at line 36).
<?php
if (Mage::registry('current_category') != NULL) {
$curr_category = Mage::registry('current_category')->getName();
$curr_category = strtolower($curr_category);
} else {
$curr_category = '';
}
?>
Then I test the variable value in an IF statement around the code blocks that build and output the select lists.
<?php if($curr_category != 'new arrivals'): ?>
--- Select list code here ---
<?php endif; ?>
I hope that helps someone!
Cheers!
I did this and it worked for me. Copy /app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml and put it in your /app/design/frontend/default/[your template]/template/catalog/product/list/ as toolbar_new.phtml .
Create a cms page and add this to the layout update :
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/ga_gallery.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbarnosort.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
<action method="setCategoryId"><category_id>76</category_id></action>
</block>

Resources