2

hope someone can help.

I'm trying to set up a 3rd party review platform (TrustPilot) for our Magento 1.9 CE store, using Ultimo theme. There is a product review box which will display individual product reviews on product pages. The code to display this box looks pretty simple, but it requires us to add the variable for the product sku and product name.

Here's the code (I've added in capitals where the two bits of data need to go);

<!-- TrustBox widget --> <div class="trustpilot-widget" data-locale="en-GB" data-template-id="5717796816f630043868e2e8" data-businessunit-id="51cd30a800006400054f735a" data-style-height="700px" data-style-width="100%" data-theme="light" data-sku="MY SKU CODE GOES HERE" data-name="MY PRODUCT NAME GOES HERE"> <a href="https://uk.trustpilot.com/review/valueincontinence.co.uk" target="_blank">Trustpilot</a> </div> <!-- End TrustBox widget -->    

This code works fine if I hard code in the actual SKU (i.e. H12345). I was expecting to be able to replace the 'MY SKU CODE GOES HERE' with something like;

<?php echo $_product->getData('sku') ?>

...but that doesn't work.

I first tried this from the admin backend CMS in a custom block/tab - if I hard code sku, it works fine, if I try anything else, the code still works, but doesn't show any of the product related reviews/details which is should (i.e. it just looks like the product has no reviews).

I thought this might be something to do with custom blocks needing something else, so I tried it just on the main product description page (i.e. not in a custom block/tab) but still no joy.

I also tried creating a phtml file seperately, but couldn't get that to work either. Have looked through lots of posts about calling variables in other scenarios, here and elsewhere, but still no joy.

I'd really appreciate any suggestions. Many thanks, Bill

  • Where do you want your review box to appear? In product page? in Category page? – Adarsh Khatri Jul 14 '16 at 23:30
  • Hi Adarsh, thanks for the reply. This will appear on the product detail page, ideally on a custom tab. – Bill V Jul 15 '16 at 8:32
  • Can you add extension's layout file too? Or how are you calling the review block within product page? – Adarsh Khatri Jul 15 '16 at 8:41
  • I'm not doing anything other than pasting in the review widget code from TrustPilot onto the product page. As mentioned in my post, I've tried pasting it in at the bottom of the product description on view.phtml and I've also gone to the admin area, gone to 'static blocks' and pasted the code into a static block which appears on a custom tab on the product page, but neither way will work properly when I try to dynamically insert the sku code into the TrustPilot code (it works if I just enter the actual sku). Isn't there a fairly universal way in Magento to call a variable such as sku? – Bill V Jul 15 '16 at 10:16
  • Did you ever solve the problem Bill? I'm in the same boat. – user44256 Sep 6 '16 at 15:41
0

I had trouble with this also for the product pages so made the following code to get the sku and name to fill in the gaps for data-sku and data-name in the Trustbox dynamically for each product page. It works on products pages not sure if will work for catalog and search results.

<?php
$current_product = Mage::registry('current_product');
if($current_product) {
    $_sku = $current_product->getSku();
    $_name = $current_product->getName();
   }
?>
<!-- TrustBox widget - Product Reviews MultiSource SEO -->
<div class="trustpilot-widget" data-locale="en-GB" data-template-id="XXXXXXXXXXXX" data-businessunit-id="XXXXXXXXXXXX" data-sku="<?php echo $_sku?>" data-name="<?php echo $_name ?>">
<a href="https://trustpilot.com/review/YOURDOMAIN" target="_blank" rel="noopener">Trustpilot</a>
</div>
<!-- End TrustBox widget -->
-1

Trustpilot suggest you use this to get the sku;

<?php echo $_product->getSku() ?>

Plus you need to make sure the 'getProduct' call is found by the widget, so add that directly before your widget code, making the whole thing like this;

<!-- TrustBox widget --><?php $_product = $this->getProduct(); ?><div class="trustpilot-widget" data-locale="en-GB" data-template-id="5717796816f630043868e2e8" data-businessunit-id="51cd30a800006400054f735a" data-style-height="700px" data-style-width="100%" data-theme="light" data-sku="<?php echo $_product->getSku() ?>" data-name="<?php echo $_product->getName() ?>" <a href="https://uk.trustpilot.com/review/valueincontinence.co.uk" target="_blank">Trustpilot</a> </div> <!-- End TrustBox widget -->    

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.