Search code examples
getjson

How to make an API call to get the reviews in bazaarvoice extension?reviews.phtml code is mentioned below


<?php if ($this->getIsEnabled()):?>
    <?php $doShowContentJs = Mage::getStoreConfig('bazaarvoice/rr/do_show_content_js');
    $seoContent = $this->getSEOContent();
    ?>
    <div id="BVRRContainer">
    <?php echo $seoContent ?>
    </div>
    <script type="text/javascript">
    $BV.ui( 'rr', 'show_reviews', {
    doShowContent : function () {
      <?php echo $doShowContentJs ?>
    }
    });    
    </script>
<?php endif; ?>

Solution

  • This answer here provides an example of how to retrieve the reviews, but I'll provide a snippet:

    $(document).ready(function(){
        $.ajax({
            url: "https://stg.api.bazaarvoice.com/data/reviews.json?apiversion=5.4&passkey=***ENTER PASSKEY HERE***&filter=productid:***PRODUCTID***",
        data: "json",
        success: function(data){
            console.log(data);
          for (i in data['Results']){
            var info = data['Results'][i];
            console.log(info.AuthorId + " || " + info.ReviewText);
          }
        }
      })
    });