What is causing my rating in Magento to duplicate? - magento

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

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();?>

magento output custom options

Is it possible to output the available list of custom options onto the view.phtml page within Magento? Obviously the drop down lists allow you to filter down but I need to list them in a html table and allow the customer to add to cart on each item.
I will show you how to convert dropdown and multi-select options into table format. This is the code that do the trick.
<?php
$product = Mage::Registry('current_product');
$options = $product->getOptions();
//check for option exists
if($options):
foreach ($options as $option) :
//table format allows only for select options
if($option->getType()== Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN ||
$option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE):
$require = ($option->getIsRequire()) ? ' required-entry' : '';
if($option->getType()== Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN):
$value_name = 'options['.$option->getid().']';
else:
$value_name = 'options['.$option->getid().'][]';
endif;
?>
<table border="1" style="width:500px;margin-bottom:30px">
<thead>
<tr<?php if ($option->getIsRequire()) echo ' class="required"' ?>>
<th><?php echo $option->getTitle() ?></th>
<th><?php if ($option->getIsRequire()) echo '<em>*</em>' ?></th>
</tr>
</thead>
<tbody id="<?php echo 'select_'.$option->getId() ?>" class="<?php echo $require.' product-custom-option' ?>">
<?php
foreach ($option->getValues() as $values) :
$value = $values->getOptionTypeId();
$value_title = $values->getTitle();
?>
<tr>
<td>
<?php
if($option->getType()== Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN):
?>
<input type="radio" name="<?php echo $value_name; ?>" class="radio_option" id="<?php echo 'radio_option_'.$value ?>" value="<?php echo $value; ?>" />
<?php
else:
?>
<input type="checkbox" name="<?php echo $value_name; ?>" class="checkbox_option" id="<?php echo 'checkbox_option_'.$value ?>" value="<?php echo $value; ?>" />
<?php
endif;
?>
</td>
<td><?php echo $value_title; ?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
<?php
endif;
endforeach;
endif;
?>
Here for dropdown options, we are using radio button to show their values. For multiselect options, checkbox inputs are used. So if checkbox appears in the table, that means it a multi select option and hence more than one checkboxes can have tick at a time. Since radio buttons are used for dropdown options, it is important to make sure that, only one radio button is checked at a time. (We need to use javascript for ensure this).
So if we are set some custom options for a product through admin like this..
The output correspond to our code will be look like this
Note: Please note that, the code is in very basic format. You may require additional css and javascripts make it more user frontly. This is for giving you a basic idea and additional css, js are hence out of box topic.
For more information about code, check out my blog
Hope it helps

Joomla List All Categories

I use for a menu-item the style "List All Categories".
I want to edit the code, however I cannot find this file anywhere!
I supposed it should be in components/com_content/views/category but no file I find there seems to be related to the html output.
This is an example of the HTML output:
<div class="categories-list">
<div class="category-item first">
<h3 class="page-header item-title"><a
href="/joomla/index.php/browse/8-eat-meet">
EAT&MEET</a>
</h3>
<img src="/joomla/images/cat1.jpg"/>
</div>
<div class="category-item">
<h3 class="page-header item-title"><a
href="/joomla/index.php/browse/9-dreaming">
DREAMING</a>
</h3>
<img src="/joomla/images/cat2.jpg"/>
</div>
Does anyone know where I can find this file?
Thank you.
That's because categories are generally attached to existing extensions, the majority use case being articles. My assumption here is these are the categories you are referring to. If you selected the "List all categories" menu option from the Articles sub-group, then the assumption is correct. The path is:
components/com_content/views/categories/tmpl
If you would like to change these files, I HIGHLY recommend not editing the core files but using template overrides to customize. See link below for specifics.
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
If it is the categorIES layout that you want that will be in the components/com_content/views/categories/tmpl categories folder (I'm assuming you are talking about in the front end).
The layout files are in the tmpl folder.
In Joomla 3.2 you will find that these files reference the files layouts/content/categories_default.php and layouts/content/categories_default_items.php.
This is because the core layouts are the same for all categories (and they can be used by any component that uses categories).
You can override both the tmpl files and the layouts in the html folder of your template.
Update
Here is the code block in the categories_default_items layout that produces the title, image and description HTML
<h3 class="page-header item-title">
<a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($item->id));?>">
<?php echo $this->escape($item->title); ?></a>
<?php if ($this->params->get('show_cat_num_articles_cat') == 1) :?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::tooltipText('COM_CONTENT_NUM_ITEMS'); ?>">
<?php echo $item->numitems; ?>
</span>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0) : ?>
<span class="icon-plus"></span>
<?php endif;?>
</h3>
<?php if ($this->params->get('show_description_image') && $item->getParams()->get('image')) : ?>
<img src="<?php echo $item->getParams()->get('image'); ?>"/>
<?php endif; ?>
<?php if ($this->params->get('show_subcat_desc_cat') == 1) :?>
<?php if ($item->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $item->description, '', 'com_content.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>

Magento Export Search Terms and Synonyms

Is there a way to export to csv Search Terms and Synonyms from a current Magento site? I need to then be able to upload to a new Magento site. I am very new to Magento and at this point I have not been able to find anything in the Admin. Other than I was able to export the Search Terms from the reports section of the Admin.
We are using Magento Connect
Thank you in advance.
please have a look at magento commerce guideline for this:
http://www.magentocommerce.com/knowledge-base/entry/popular-search-terms
then to disaply you can use following code as a start point
<h3><?php echo $this->__('Popular Search Terms') ?></h3>
<?php if( sizeof($this->getTerms()) > 0 ): ?>
<div class="box base-mini mini-product-tags">
<div class="content">
<ul class="bare-list">
<?php foreach ($this->getTerms() as $_term): ?>
<li><?php echo $this->htmlEscape($_term->getName()) ?></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php else: ?>
<div class="note-msg">
<?php echo $this->__('There are no search terms available.'); ?>
</div>
<?php endif ?>
Hope this helps
Also you might need to use following
$searchCollectino=Mage::getModel('catalogsearch/query')->getCollection()
->setPopularQueryFilter()
->setPageSize($limit);

remove news item from the joomla newsflash

I am using the joomla newsflash in order to display the 5 most recent items in my home page. the newsflash is attached to my news & events category. now I need that one of the news & events items will not be displayed in my home newsFlash. is it possible?, thanks
For Joomla 1.5.26, a template override might be your best bet. See here for how that's done: http://forum.joomla.org/viewtopic.php?t=145996
In your case, you'd create a new file at
/templates/your_template/html/mod_newsflash/_item.php
You'd put the following code in that file. Be sure to replace "99" with the id of your article. You can get that from the Article Manager table.
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<?php
$my_article_id = $item->id;
if ($my_article_id !== '99') :
if ($params->get('item_title')) : ?>
<table class="contentpaneopen<?php echo $params->get( 'moduleclass_sfx' ); ?>">
<tr>
<td class="contentheading<?php echo $params->get( 'moduleclass_sfx' ); ?>" width="100%">
<?php if ($params->get('link_titles') && $item->linkOn != '') : ?>
<a href="<?php echo $item->linkOn;?>" class="contentpagetitle<?php echo $params->get( 'moduleclass_sfx' ); ?>">
<?php echo $item->title;?></a>
<?php else : ?>
<?php echo $item->title; ?>
<?php endif; ?>
</td>
</tr>
</table>
<?php endif; ?>
<?php if (!$params->get('intro_only')) :
echo $item->afterDisplayTitle;
endif; ?>
<?php echo $item->beforeDisplayContent; ?>
<table class="contentpaneopen<?php echo $params->get( 'moduleclass_sfx' ); ?>">
<tr>
<td valign="top" ><?php echo $item->text; ?></td>
</tr>
<tr>
<td valign="top" >
<?php if (isset($item->linkOn) && $item->readmore && $params->get('readmore')) :
echo '<a class="readmore" href="'.$item->linkOn.'">'.$item->linkText.'</a>';
endif; ?>
</td>
</tr>
</table>
<?php endif; ?>
The relevant code is in the second and final PHP tags, where I've inserted an IF check which looks for your article ID and skips it if it matches.

Resources