Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Review Helper Block Rewrite
 
SwiftCol
Sr. Member
 
Total Posts:  85
Joined:  2008-05-22
 

I have the following code in one of my module’s config files:

<blocks>
    <
catalog>
        <
rewrite>
            <
navigation>MyCompany_Catalog_Block_Navigation</navigation>
        </
rewrite>
    </
catalog>
    <
review>
        <
rewrite>
            <
helper>MyCompany_Review_Block_Helper</helper>
        </
rewrite>
    </
review>
</
blocks>

The Catalog/Block/Navigation is rewriting just fine. The Review/Block/Helper is not. I have the files in place in the same way that I do for the Navigation block, but by all my tests, Magento isn’t even reading the file where my rewrite class is at all. No errors, it just plain doesn’t work.

Anybody know why?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michae1
Enthusiast
 
Total Posts:  826
Joined:  2007-08-31
 

Try to change it in the following way:

<blocks>
    <
catalog>
        <
rewrite>
            <
navigation>MyCompany_Catalog_Block_Navigation</navigation>
        </
rewrite>
    </
catalog>
</
blocks>
<
helpers>
     <
review>
            <
helper>MyCompany_Review_Helper</helper>
    </
review>
</
helpers>

Though I’m not sure in what are you trying to do and if it helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
SwiftCol
Sr. Member
 
Total Posts:  85
Joined:  2008-05-22
 

Thank you, but unfortunatly that didn’t work. What i’m trying to change ins’t a helper, is a block of the review module called Helper. (Poor name choice if you ask me.) All i’m trying to do is change the phtml files so that I can customize the design of the Review summary on the product page, but for some reason just adding the files to my design folder isn’t working. I thought maybe I could over write the code for the module and force it to use another template file, but thats not working either. No matter how I try to over write it, it doesn’t work. (using the same method that i’ve used on 10 or so other blocks and modules.)

Any other ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

Hi swiftcol,

I’m actually trying to do the same thing than you, I’m trying to write a template file to display products reviews on a product page.
If I succeed I’ll post the code here.

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

I’m trying to make a template like review/product/detailed.phtml but to be displayed directly on a product page.
For the moment I didn’t succeeded to get reviews of a product.

For example I tried the method :

$this->getReviewData()->getNickname()

and

$this->getReviewData()->getDetail()

but it displays comments that are about another product.....

 
Magento Community Magento Community
Magento Community
Magento Community
 
SwiftCol
Sr. Member
 
Total Posts:  85
Joined:  2008-05-22
 

The review module is weird. The summary review section on the catalog product view page is not a block controllable by layout files, it is directly added by the block code. And for some reason as I said above, I can’t seem to over write the block’s code.

As far as trying to use trying to use the code that you tried, it doesn’t work because $this isn’t pointing to any of the review module code. You should be able to fix this by adding the review view block to the content block of the catalog product view page, but I can’t get that to work either. I tried this:

<catalog_product_view>
    <
reference name="content">
        <
block type="review/view" name="review_view"/>
    </
reference>
</
catalog_product_view>

Can anyone get this working?

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

Hi there,

because of a lack of time, I’ve made a provisional solution, very “dirty”.
I putted a function directly at the top of the catalog/product/view.phtml template file. This is not matching at all with the MVC pattern but I had to implement quickly for my client a solution to have the products comments on the products pages. I hope I will find a cleaner solution but with the poor documentation about magento, I don’t know when.

In your catalog/product/view.phtml template file, put this code where you want reviews to be displayed :

getProductReviews($_product->getId());

where $_product->getId() is the id of the current product. We would have to send the store id to the getProductReviews() function too, in order to have product comments for the current store view only.

Here is the function :

function getProductReviews($prod_id)
{
    $resource 
Mage::getSingleton('core/resource');
    
$read $resource->getConnection('catalog_read');
    
    
$select $read->select('rev.created_at','det.title')
        ->
from( array('rev'=>'review'),
                array(
'rev.created_at''det.title''det.detail''det.nickname')
        )
        ->
join( array('det'=>'review_detail'), 'rev.review_id=det.review_id', array())
        
        ->
where('status_id=1')
        ->
where('entity_pk_value=' $prod_id);
        
    
$res $read->fetchAll($select);
    
    
$html "<ul>";
    
    foreach(
$res as $review){
        
        $html 
.= "<li>";
        
$html .= $review['nickname'];
        
$html .= "</li><li>";
        
$html .= $review['detail'];
        
$html .= "</li>";
    
    
}
    
    $html 
.= "</ul>";
    
    echo 
$html;
}

Please notice that’s a very dirty solution, use this if you know what you do.
 
Magento Community Magento Community
Magento Community
Magento Community
 
retif
Sr. Member
 
Total Posts:  171
Joined:  2008-08-16
Odessa, Ukraine
 
Michael - 21 July 2008 11:31 PM

Try to change it in the following way:

<blocks>
    <
catalog>
        <
rewrite>
            <
navigation>MyCompany_Catalog_Block_Navigation</navigation>
        </
rewrite>
    </
catalog>
</
blocks>
<
helpers>
     <
review>
            <
helper>MyCompany_Review_Helper</helper>
    </
review>
</
helpers>

Though I’m not sure in what are you trying to do and if it helps.

<helpers>
     <
review>
        <
rewrite>
            <
helper>MyCompany_Review_Helper</helper>
        </
rewrite>
    </
review>
</
helpers>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top