Magento Review stars showing Empty in product - magento

After reviewing the product I've just approved and on a single product page it shows comments but the rating star is not showing.
<?php $_votes = $_review->getRatingVotes(); ?>
<?php if (count($_votes)): ?>
<table class="ratings-table">
<col width="1" />
<col />
<tbody>
<?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; ?>
</tbody>
</table>

Related

Display 5 stars for adding ratings instead of radio buttons

default magento will display the ratings as below image
but i want to change like this :
i am using default magento code
form.phtml [app/design/frontend/rwd/theme/template/review/form.phtml]
<?php if( $this->getRatings() && $this->getRatings()->getSize()): ?>
<h4><?php echo $this->__('Your Rating') ?> <em class="required"></em></h4>
<span id="input-message-box"></span>
<table class="data-table review-summary-table ratings" id="product-review-table">
<col width="1" />
<col />
<col />
<col />
<col />
<col />
<thead>
<tr>
<th> </th>
<th>
<div class="rating-box">
<span class="rating-number">1</span>
<span class="rating nobr" style="width:20%;"><?php echo $this->__('1 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">2</span>
<span class="rating nobr" style="width:40%;"><?php echo $this->__('2 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">3</span>
<span class="rating nobr" style="width:60%;"><?php echo $this->__('3 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">4</span>
<span class="rating nobr" style="width:80%;"><?php echo $this->__('4 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">5</span>
<span class="rating nobr" style="width:100%;"><?php echo $this->__('5 star') ?></span>
</div>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->getRatings() as $_rating): ?>
<tr>
<th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?></th>
<?php foreach ($_rating->getOptions() as $_option): ?>
<td class="value"><label for="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>"><input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" /></label></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="validate_rating" class="validate-rating" value="" />
<script type="text/javascript">decorateTable('product-review-table')</script>
<?php endif; ?>
please help me to find solution
Thanks in advance
I recently dealt with it and my code looks something like this:
form.phtml
<?php foreach ($this->getRatings() as $_rating): ?>
<tr>
<th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?>: </th>
<?php foreach ($_rating->getOptions() as $_option): ?>
<td class="value">
<label for="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>">
<input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" />
<i class="fa fa-star"></i>
</label>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
*.css
.review-summary-table tbody td label input {
display: none;
}
// default
.review-summary-table tbody td label input + .fa {
color: #E6E6E6;
}
// hover, clicked, ...
.review-summary-table tbody td label:hover input + .fa,
.review-summary-table tbody td label input:checked + .fa,
.review-summary-table tbody td.active label input + .fa,
.review-summary-table tbody tr:hover td.tmp-active label input + .fa {
color: #50A4CF;
}
*.js
var reviewTable = $('#product-review-table');
if (reviewTable.length > 0) {
reviewTable.each(function() {
$(this).find('tbody tr').each(function() {
var row = $(this),
tdValues = row.find('td.value');
tdValues.each(function(index) {
$(this).find('label').hover(function() {
tdValues.removeClass('tmp-active');
tdValues.slice(0, index + 1).addClass('tmp-active');
}).click(function() {
tdValues.removeClass('active');
tdValues.slice(0, index + 1).addClass('active');
});
});
});
});
}

DataTables warning: table id=datatable - Requested unknown parameter '1' for row 0

can someone tell me what's wrong with my code? been stuck here for hours... it always says that "DataTables warning: table id=datatable - Requested unknown parameter '1' for row 0."
here's my code:
<table id="datatable" class="table table-bordered table-striped dataTable">
<thead>
<tr>
<th>Name</th>
<th></th>
</tr>
</thead>
<tbody>
<?php echo $this->session->flashdata('message'); ?>
<?php $offset = $this->uri->segment(3, 0) + 1; ?>
<?php foreach ($query->result() as $row): ?>
<tr>
<td><?php echo $row->manufacturer_name; ?></td>
<?php echo "<form method='post' action='asset_management/updateForm'>";?>
<input type="hidden" name="manufacturer_id" value="<?php echo $row->manufacturer_id;?>"/>
<?php echo form_open('asset_management/updateForm');
echo form_submit('p_submit', 'Update', "class='btn btn-warning btn-xs'"); ?>
<?php echo form_close(); ?>
</form>
<a class="btn btn-danger btn-xs" onclick="javascript:deleteConfirm('<?php echo site_url('asset_management/deletemanu/' . $row->manufacturer_id); ?>');" deleteConfirm href="#">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Thank you so much!
no. of table heading may not matches with no. of td in the table.
It shows the mentioned error.
visit https://www.datatables.net/

Call a phtml template in a static block

I want to call the "view.phtml" template in the tab "SPECIFICATION" (located in a static block), so that I can show a table of the grouped products.
Within that tab in the block content, I add following commands:
{{block type="catalog/product" template="catalog/product/view.phtml"}}
But nothing happens. I know the view.php located in catalog/product folder. Is there anything wrong with this command?
FYI,
in the "view.phtml", there is only one setence:
<?php echo $this->getChildHtml('product_type_data') ?>
And below is my "grouped.phtml", which is nothing but a table:
<?php $this->setPreconfiguredValue(); ?>
<?php $_product = $this->getProduct(); ?>
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<div class="grouped-items-table-wrapper" style="border:0px;">
<table class="data-table grouped-items-table" id="super-product-table" style="width:75%;margin-left:10px;">
<tbody>
<tr style="background-color:#091f36;color:white;">
<td class="" colspan="2">
<p>
XCEL Part <br/>
No.
</p>
</td>
<td class="">
<p>
Fence <br/> H'
</p>
</td>
<td class="">
<p>
Fence <br/> W'
</p>
</td>
<td class="">
<p>
Fence<br/> H/mm
</p>
</td>
<td class="">
<p>
Fence <br/>W/mm
</p>
</td>
<td class="">
<p>
Pickets <br/>Qty.
</p>
</td>
<td class="">
<p>
Rails<br/> Qty.
</p>
</td>
<td class="">
<p>
Rings<br/> Qty.
</p>
</td>
<td class="">
<p>
Panel <br/>LB
</p>
</td>
<td class="">
<p>
Panel <br/>KG
</p>
</td>
</tr>
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_item): ?>
<?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
<tr>
<td class="" colspan="2">
<p>
<?= $_item->getSKU() ?>
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('height') ?>
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('width') ?>
</p>
</td>
<td class="">
<p>
<?= $var=ceil(($_item->getAttributeText('height'))/0.0032808) ?>
</p>
</td>
<td class="">
<p>
<?= $var=ceil(($_item->getAttributeText('width'))/0.0032808) ?>
</p>
</td>
<td class="">
<p>
20
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('rail') ?>
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('ring') ?>
</p>
</td>
<td class="">
<p>
<?= $var=round($_item->getWeight(), 2) ?>
</p>
</td>
<td class="">
<p>
<?= $var=round((($_item->getWeight())/2.2046),2) ?>
</p>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<script type="text/javascript">decorateTable('super-product-table')</script>
{{block type="catalog/product_view" template="catalog/product/view.phtml"}}
As you mention you have defined inside catalog->product->view->view.php
In your block type you have defined "catalog/product_view" so your view.php file should be inside catalog->product->view.php

show text field attribute of a configurable product magento

I have added configurable product and added textarea attribute to it, I want to show the attributes at front end in my custon view, how can I show ?
you can use this code
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<h2><?php echo $this->__('Additional Information') ?></h2>
<table class="data-table" id="product-attribute-specs-table">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<tr>
<th class="label">
<?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data">
<?php echo $_helper->productAttribute($_product, $_data['value'],
$_data['code']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>
Catalog -> Attribute -> Manage Attribute -> Select your attribute -> Visible on Product View Page on Front-end -> Select "YES"
Does this solve your problem?

Magento: How to show unset attributes as empty not "No" / "N/A"?

Magento has done great job on showing empty attributes as "No" or "N/A", but
I need them to show up as empty table cells.
I know this code hides empty attributes completely:
<?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; ?>
Source: http://www.magthemes.com/magento-blog/empty-attributes-showing-na-fix/
but as I am new to php, I don't really know how to modify it to show them empty.
I know I could go to core files and modify Attributes.php, but thats a bad practice and I wanted to do it right.
Thanks in advance!
You can write a extension thar rewrites Mage_Catalog_Block_Product_View_Attributes::getAdditionalData. But this requires much more knowledge than is necessary to modify the template.
Modify template. Your code is already done. Only few modifications need
<?php foreach ($_additional as $_data): ?>
<?php
$_attribute = $_product->getResource()->getAttribute($_data['code']);
$_isEmpty = (!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 if (!$_isEmpty) { echo $_helper->productAttribute($_product, $_data['value'], $_data['code'])} ?> </td>
</tr>
<?php endforeach; ?>
P.S. Code can contain errors, have not tested :)
ALT+0160
Use the above keyboard shortcut as the attribute value when you edit your product.
How?
On Windows, at least, do the following:
Hold ALT key and type the numbers 0160 on your keypad. Now release the ALT key.
Basically a whitespace character appears that is not a space character. This will register as a non-null value for your product field and the engine will render the character which, fortunately for us humans, is a whitespace that we won't see.
It's not elegant, but it will help those who aren't able to modify template code.
i try with this options to remove "No or N/A" and ok remove this words but donĀ“t remove atribute name. i use this code:
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<div class="akordeon-item-head">
<div class="akordeon-item-head-container">
<div class="akordeon-heading">
<?php echo $this->__('Additional Information') ?>
</div>
</div>
</div>
<div class="akordeon-item-body">
<div class="akordeon-item-content">
<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']);
$_isEmpty = (!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 if ($_isEmpty) { echo $_helper->productAttribute($_product, $_data['value'], $_data['code']);} ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
</div>
</div>
<?php endif;?>
i find this anwerd and work for me
<?php foreach ($_additional as $_data): ?>
<?php if ($_data['value'] == 'No') {continue;} ?>
<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>

Resources