1

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.

  • this question is too broad to answer. – Rajeev K Tomy Sep 15 '14 at 5:56
  • Question carified – Moh3n Sep 15 '14 at 8:30
1

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.

| improve this answer | |
  • thanx question renewed – Moh3n Sep 15 '14 at 8:20
  • the code I mentioned is for product/view.phtml not for your custom file summary_nolinks.phtml you need to use a product object like $_product is on product/view.phtml – MTM Sep 15 '14 at 10:38
  • how can i change its template because i want two ratings to show different? – Moh3n Sep 15 '14 at 11:44
  • and how can i put a tex or link next to this stars? – Moh3n Sep 15 '14 at 11:55
  • you can do it like a normal html. – MTM Sep 15 '14 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.