Question

how to add another rating stars to a product bay admin, nearby the customer rating stars. this stars should be different by Magento default rating stars. i mean i want two kinds of stars to be shown for one product. one of theme for admin to put his rating and one of theme for customers.

i created an attribute with admin_rating attribute Code and with global Scope and Catalog Input Type for Store Owner set to text field and Input Validation for Store Owner set to integer number and admin name set to AdminRating. then i assigned this attribute to default attribute set. then i created a product with admin_rating number 30. after that i edited this file where my current ratting is:

app/design/frontend/fortis/default/template/review/helper/summary_nolinks.phtml

default summary_nolinks.phtml content:

?>
<?php if ($this->getReviewsCount()): ?>
    <div class="ratings">
        <?php if ($this->getRatingSummary()):?>
            <div class="rating-box">
                <div class="rating" style="width:<?php echo $this->getRatingSummary() ?>%"></div>
            </div>
        <?php endif;?>
        <p class="rating-links">
            <a id="goto-reviews" href="#product-tabs"><?php echo $this->__('%d Review(s)', $this->getReviewsCount()) ?></a>
            <span class="separator">|</span>
            <a id="goto-reviews-form" href="#review-form"><?php echo $this->__('Add Your Review') ?></a>
        </p>
    </div>
<?php elseif ($this->getDisplayIfEmpty()): ?>
    <p class="no-rating"><a id="goto-reviews-form" href="#review-form"><?php echo $this->__('Be the first to review this product') ?></a></p>
<?php endif; ?>

and i added this line under line 6 :

<div class="rating" style="width:<?php echo $_product->getAdminRating();?>%;"></div>

summary_nolinks.phtml content after making changes:

?>
<?php if ($this->getReviewsCount()): ?>
    <div class="ratings">
        <?php if ($this->getRatingSummary()):?>
            <div class="rating-box">
                <div class="rating" style="width:<?php echo $this->getRatingSummary() ?>%"></div>
                <div class="rating" style="width:<?php echo $_product->getAdminRating();?>%;"></div>
            </div>
        <?php endif;?>
        <p class="rating-links">
            <a id="goto-reviews" href="#product-tabs"><?php echo $this->__('%d Review(s)', $this->getReviewsCount()) ?></a>
            <span class="separator">|</span>
            <a id="goto-reviews-form" href="#review-form"><?php echo $this->__('Add Your Review') ?></a>
        </p>
    </div>
<?php elseif ($this->getDisplayIfEmpty()): ?>
    <p class="no-rating"><a id="goto-reviews-form" href="#review-form"><?php echo $this->__('Be the first to review this product') ?></a></p>
<?php endif; ?>

but my whole template messed up and no admin rating is showing.

Was it helpful?

Solution

A simple solution is to create an attribute like admin_rating and assign it to the attribute set, then edit each product if you want different for each product OR bulk update the attributes from product grid and enter a digit for this attribute from 0 to 100, one star is equal to 20, so suppose you want 3 stars, enter value as 60 and then use the following code to get stars for each product at frontend:

<div class="rating-box">
 <div class="rating" style="width:<?php echo $_product->getAdminRating();?>%;"></div>
</div>

you will have to edit the template file of your theme
\app\design\frontend\your package \your theme\template\catalog\product\view.phtml and place the code in it.
Note that this is the default rating method/design used by Magento, if you are using a customized one then you will have to amend it accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top