(The Amazon module issue is at #905198: Customer reviews no longer in Amazon API after 8 Nov 2010

Dear Product Advertising API Developer,

On November 8, 2010 the Reviews response group of the Product Advertising API will no longer return customer reviews content and instead will return a link to customer reviews content hosted on Amazon.com. You will be able to display customer reviews on your site using that link. Please refer to the Product Advertising API Developer guide found here for more details. The Reviews response group will continue to function as before until November 8 and the new link to customer reviews is available to you now through the Product Advertising API as well.

Thank you for advertising products for sale on Amazon.com.

Comments

the_g_bomb’s picture

I will look into the Amazon module as well, but I think until we can work around that fact that the only review data that will be sent by Amazon is an iframe url, as a temporary work around to stop the feature disappearing on the 8th Nov we could add:

if (empty($item->CustomerReviews->Review)) {
  if ($item->CustomerReviews->IFrameURL) print '<iframe src="'. $item->CustomerReviews->IFrameURL .'" />';
}
else {
  ... current template file ...
}

to the amazon_store_item_reviews_panel.tpl.php

I will try to create a patch to this effect once I have looked into the Amazon module requirements

the_g_bomb’s picture

For any one else interested details of the Product Advertising API Developer Guide can be found at:
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/

And more general information about the various releases of that document:
http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryI...

The specific information regarding this issue can be found in the PA API DG under Programming guide > Motivating Customers to Buy about a third of the way down the page is Getting Customer Reviews.:
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/CHAP_Mot...

or on the page about Reviews Response Group which shows the current return:
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/RG_Revie...

the_g_bomb’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
StatusFileSize
new2.43 KB

First patch attempt.

It will display the iframe url, if the iframeURL is provided, but the actual data ($item->CustomerReviews->Review) is not.

This should stand as a backup for when the change over occurs, at least this way something will be displayed in the worst case scenario. Hopefully, I can create a patch for the Amazon module before this is needed. I propose to scrape the iframeURL page and populate the database with the same data that is currently populating it. That way when this file gets called the data will be there and this patch will become irrelevant.

rfay’s picture

Status: Active » Needs review

I prefer to do 7.x first on these, so we can remember what's been done, but I'll see if I can give this a look this week. Thanks for the effort here!

-Randy

rfay’s picture

+++ amazon_store_item_reviews_panel.tpl.php	3 Oct 2010 18:52:26 -0000
@@ -5,28 +5,33 @@
+  if ($item->CustomerReviews->IFrameURL) print '<iframe src="'. $item->CustomerReviews->IFrameURL .'" />';

Please don't use the single-line conditional; always use braces.

Powered by Dreditor.

rfay’s picture

@the_g_bomb, so sorry I took so long to review this. I was teaching a couple of those weeks, recovering the weeks in between, and.... well I very much appreciate your contribution here and hope you'll continue.

Here's my take on it. The way I read it they are going to rip out *everything* but the URL, so we should just take all the other stuff out.

Unfortunately the result is quite ugly, so I removed it from the default item display. If you can figure out how to make it look better, I don't mind it being there. People can still use panels to place it if they want it.

Looking forward to your review.

-Randy

the_g_bomb’s picture

I took a couple of looks over the patch file and it looks good.

Patch applied and installed fine, module working as expected, minus the customer reviews obviously.

I did wonder if we might want to add a checkbox into the admin settings offering the user the choice of whether to display the iframe or not.
Something like this might do:

// add to function amazon_store_admin_form() in amazon_store.module
<?php
      'amazon_store_show_customer_reviews_iframe_url' => array(
        '#type' => 'checkbox',
        '#title' => t('Display customer reviews iframe on the item page'),
        '#default_value' => variable_get('amazon_store_show_customer_reviews_iframe_url', 0),
      ),
?>

and also:

// add to amazon_item_detail.tpl.php
<?php
<?php if (($item->CustomerReviews->IFrameURL) && (variable_get('amazon_store_show_customer_reviews_iframe_url', 0))) : ?>
  <div id="bottom-section" class="column">
  <h3>Customer Reviews</h3>
  <iframe src="<?php print $item->CustomerReviews->IFrameURL; ?>" />';
  </div>
<?php endif; ?>
?>

What would your thoughts be on this?

rfay’s picture

I'm open to it. A simpler approach is just to put commented-out code in the .tpl.php file.

Can you make some code that even makes it look halfway decent? I had it in there and ripped it out because it was just awful. There's no good way to know how big it ought to be, and then you get scrollbars, etc. My expectation is that this will no longer be useful to Amazon API customers.

the_g_bomb’s picture

Yeah, fair point, it did look like it was kind of crammed into a tiny box and I don't think my ideal solution would be to have the iframe their either.

I did originally have a quick look to see where the iframe size was set but couldn't find the responsible code. I'll have another play with it too see what I can come up with.

The other alternative is to scrape the iframe and save the data back to the database and display the reviews as before, but this may outwith the scope of this module. Perhaps we should hang off doing anything else to see what kind of responses there are if there are any requests to put the customer reviews back in.

rfay’s picture

Storing Amazon data longer than 24 hours (I think it is) also violates the license agreement. But you're right; we don't even have to scrape the data; we could just drupal_http_request() it, and we'd have it. So that is probably a better solution if we're going to do anything. However, then we have absolutely no control over the formatting or anything.

the_g_bomb’s picture

I have been looking at setting height and width on the iframe. Setting the width to 100% seems to work ok, then I started trying to see if it would be possible to use: $amazon_item->CustomerReviews->TotalReviews to work out a potential height that the iframe may need to be. The URL seems to display 3 reviews with a link to more if they exist.

From what I can see, using the Garland theme (not sure yet if that makes a difference) we have:
150px top (logo and averages)
approx 300-400px per review
55px bottom (create your own link and see all reviews)

based on this we could:

    <?php 
  if ($amazon_item->CustomerReviews->TotalReviews > 3) {
    $height = 205 + (400 * 3);
  }
  else {
    $height = 205 + (400 * $amazon_item->CustomerReviews->TotalReviews);
  } ?>
<iframe height="<?php print $height; ?>px" src="$amazon_item->CustomerReviews->IFrameURL" />

its possible to throw a scrolling = no in there as well if you want,
but this is a kinda messy solution and I'm still not convinced its worth spending alot of time ironing out all the kinks in it, such as page resizing, font resizing etc.

It could also be possible to use jQuery to grab the height of the IFrameURL page then set the iframe height with that, probably a tidier solution.

rfay’s picture

Don't forget that *everything* in CustomerReviews except IFrameURL is going away! At least that's the way I read the docs.

the_g_bomb’s picture

Your absolutely right on that. Only the IFrameURL will be returned in future.

the_g_bomb’s picture

And on top of that jQuery is out too.

Javascript will not work on iFrames accessing content from a different domain since the window object i.e. the IFrameURL cannot be accessed from the item page due to JavaScript security restrictions.

So, I think you are correct to just remove this as formatting this will probably just end up looking awful. What a shame.

rfay’s picture

OK, here's a reroll against DRUPAL-6--2. I'll commit this one.

rfay’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Committed to DRUPAL-6--2: http://drupal.org/cvs?commit=444814

Now we have to do D7.

Please test the dev version and make sure everything is OK.

rfay’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.6 KB

Here's the D7 version

rfay’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.