magento summary rating of customers review - magento

I'm using Magento and I want to accomplish the following:
Customers can write a review an rate my product. They can rate several options as price, quality etc.
When they rate the product the review and rating shows at the productpage. For each rate options i see that stars for the rating but what I want is a summary total of the rating of that customer.
So this total rating has to become the same as the total rating on the product listing.
I hope someone can help me with this one.
Thanks in advance!

In *magento/app/design/frontend/base/[your_theme]/template/review/product/view/list.phtml*
You will see the following foreach loop:
<?php foreach ($_votes as $_vote): ?>
<tr>
<th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
</div>
</td>
</tr>
<?php endforeach; ?>
This loops through each vote and outputs it as a star rating.
Change it to the following:
<?php
$_percent = 0;
foreach ($_votes as $_vote) {
$_percent = $_percent + $_vote->getPercent();
}
$_percent = $_percent / count($_votes);
?>
<tr>
<th>Aggregate rating:</th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_percent ?>%;"></div>
</div>
</td>
</tr>
Instead of displaying each vote, you're now calculating the aggregate percentage, and only outputting one vote.

Related

Outputting the product atribute table within the product page (catalog/product/view.phtml)

I'm attempting to place the product attribute table within a div on my product page, seperately from the content of the usual collateral tabs.
I've located the code from my attributes.phtml and i've tried to just copy and paste this code into the appropriate part of my view.phtml, resulting in the following:
<div class="spec-table">
<?php if($_additional = $this->getAdditionalData()): ?>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>
</div>
When this didn't work, I tried invoking the attributes.phtml from within my view.phtml using:
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/view/attributes.phtml')->toHtml();?>
but sadly neither of these approaches seems to work, and I just end up with a blank div.
What's the best way to inject my attributes.phtml (or for that matter, the contents of any given .phtml file) into my product page at some arbitrary point?
Managed to get this to work using the following
<?php echo $this->getLayout()->createBlock('catalog/product_view_attributes')->setTemplate('catalog/product/view/attributes.phtml')->toHtml();?>

Display delivery time in magento

I want to display delivery time of products along with IN STOCK on my magento(1.7) based shopping cart.
For eg: "Delivered in 2-3 business days."
Is there any such option available in Magento community version?
One way that you can implement this is to add a new attribute to the product with all the different delivery options available.
You can then populate this and use the data to update the front end store. Emails etc.
This will be working for regular products.
<?php if ($qtyStock = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty()>0):{?>
<p class="availability in-stock">
<span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
<span class="value"><?php echo $this->helper('catalog')->__('In stock') ?></span>
<span class="value"><p>Delivery Time:</p>
<div id="delivery_time"><p>Delivered in 2-3 business days.</p></div></span>
</p>
<?php } else: { ?>
<p class="availability out-of-stock">
<span class="label"><?php echo $this->helper('catalog')->__('Availability:') ?></span>
<span class="value"><?php echo $this->helper('catalog')->__('Out of stock') ?></span>
</p>
<?php } endif; ?>

Fetch the entered quantity box values from multiple quantity box to cart page in magento

I am new to Magento.
I am displaying the attributes in table format using foreach in product detail page.
Problem i am facing is when i enter the value in any quantity box, it takes the last quantity value to the cart page since i am using foreach loop to display the quantity box.I need to display the exact value which i have entered in the quantity box.
Code:
<table border="1" style="width:100%;">
<thead>
<tr>
<th>Fabric</th>
<th>Color</th>
<th>Required Qty</th>
<th>Total Cost</th>
<th>Cart</th>
</tr>
</thead>
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'fabric');
$buttonTitle = $this->__('Add to Cart');
$i=0;foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$i++;
if($i==1) continue;
?>
<tbody>
<tr>
<td>
<?php echo $attributeArray[$option['value']] = $option['label'];
?>
</td>
<td>
<select name="color" id="color">
<option>Select Color</option>
<?php
$color = Mage::getModel('eav/config')->getAttribute('catalog_product', 'fabric_color');
$j=0;foreach ( $color->getSource()->getAllOptions(true, true) as $option_color){
$j++;
if($j==1) continue;?>
<option value="<?php echo $option_color['value'];?>" price="<?php echo $option_color['price'];?>"><?php echo $option_color['label'];?></option>
<? }
?>
</select>
</td>
<td>
<?php if($_product->isSaleable()): ?>
<div class="add-to-cart">
<?php if(!$_product->isGrouped()): ?>
<label for="qty"><?php echo $this->__('Qty:') ?></label>
<div class="qty_pan">
<input type="text" name="qty" id="qty<?=$i;?>" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</td>
<td ><span class="qty<?=$i;?>" id=""><?php echo $_product->getPrice();?></span></td>
<td>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<!-- <span id='ajax_loader' style='display:none'><img src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/></span>-->
<?php //echo $this->getChildHtml('', true, true) ?>
</td>
</tr>
</tbody>
<?php }?>
</table>
Screenshot:
https://imageshack.us/scaled/large/12/detailpage.png
Any help is appreciated!.
I Got The solution.
We can use Query String to fetch the quantity values to cart.
Yourdomain.com/checkout/cart/add?product=getId();?>&qty=1
You can use the above querystring in href.
Hope this Helps.

Magento view is not showing proper prices

This file (frontend/base/default/template/catalog/product/list.phtml) was edited, now is not showing the proper prices,
http://www.personalproducts4u.co.uk/hotel-toiletries/au-lait
I changed the third table tag (ONLY THE THIRD TABLE TAG)on the file above AND THE PRICES ARE SHOWING ALL THE SAME (ON DISCOUNTED PRICES)
any ideas?
this is the code I changed:(pasted it on the third table tag of the lists file)
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<th class="buy_heading">Buy</th>
<td class="buy_pay_content">1</td>
<?php
/*foreach($tierPrices as $key=>$value)
{
echo "<td class='buy_pay_content'>".number_format($tierPrices[$key]['price_qty'],0)."</td>";
} */
?>
<?php
if(count($tierPrices)):
foreach($tierPrices as $key=>$value)
{
echo "<td class='buy_pay_content'>";
echo number_format($tierPrices[$key]['price_qty'],0);
if($key == $count-1)
{
echo "+";
}
echo "</td>";
}
else:
echo '<td class="buy_pay_content">5</td>
<td class="buy_pay_content">10+</td>';
endif;
?>
<td class="buy_pay_content">Quantity</td>
</tr>
<tr>
<th class="pay_heading">Pay</th>
<td class="buy_pay_content"><?php echo $this->getPriceHtml($_product) ?><?php //echo Mage::helper('core')->currency($_product->getPrice()) ; ?>
<?php //echo Mage::helper('core')->currency($_product->getPrice()) ; ?> <?php //echo $this->getPriceHtml($_product, true)
?>
</td>
<?php
$specialprices = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice();
if($specialprices)
{
$specialprice =$specialprices;
}
else
{
$specialprice = 0;
}
if(count($tierPrices)):
foreach($tierPrices as $key=>$value)
{
if($specialprice < $tierPrices[$key]['price'] && $specialprice != '0'):
//echo 'special less'.$specialprice;
?>
<td class='buy_pay_content'><div class="price-box">
<p class="old-price"><span id="old-price-182" class="price"> <?php echo Mage::helper('core')->currency($tierPrices[$key]['price']) ?> </span> </p>
<p class="special-price"> <span id="product-price-182" class="price"><?php echo Mage::helper('core')->currency($specialprice) ?></span></p>
</div></td>
<?php
else:
?>
<td class='buy_pay_content'><?php echo Mage::helper('core')->currency($tierPrices[$key]['price']) ?></td>
<?php
endif;
?>
<?php }
else:
echo "<td class='buy_pay_content'>".$this->getPriceHtml($_product, true)."</td>";
echo "<td class='buy_pay_content'>".$this->getPriceHtml($_product, true)."</td>";
endif;
?>
<td class="buy_pay_content"><input type="text" class="input-text qty" title="Qty" value="" maxlength="12" id="qty" name="qty"></td>
</tr>
</table>
Well the issue seems to be the fact that getSpecialPrice() returns what ever is in the Special Price field. I could be mistaken but I don't believe you can supply special tiered prices in Magento. You can still add a static special price but as you have already experienced it will display the same price for each iteration.
You will probably need some sort of custom extension or template logic to display such sales properly.
I am not sure how you currently manage your tiered pricing, but if it is a fixed percentage for each tier you could set your tiered prices to the calculated sale prices and calculate and display the original tier prices by dividing each tiered discount percentage and display that number.

What is causing my rating in Magento to duplicate?

Why is my rating having a duplicate values?
below is my view.phtml look like. I'm using Magento "ver. 1.6.0.0"
<?php if( $this->getRating() && $this->getRating()->getSize()): ?>
<h3><?php echo $this->__('Product Rating:') ?></h3>
<table class="ratings-table">
<?php foreach ($this->getRating() as $_rating): ?>
<?php if($_rating->getPercent()): ?>
<tr>
<th><?php echo $this->__($this->escapeHtml($_rating->getRatingCode())) ?></th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo ceil($_rating->getPercent()) ?>%;"></div>
</div>
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</table>
</dl>
<?php endif; ?>
this seems to be a problem in your database. If you started with sample data and deleted those reviews in the admin panel, the tables aren't deleted. So the 'review_id' is written two times to the database.
After taking a backup of your database follow these steps:
First of all delete all sample reviews from the table 'review_detail'. Keep the 'review_id' of the deleted reviews in mind.
Now delete all lines with the list of 'review_id' from above in the table 'rating_option_vote'.
did you check your configuration in backend? Under Catalog -> Reviews and Ratings -> Manage Rating. Maybe they are double configured. Otherwise it seems to be a data problem.
cheers

Resources