diff --git CHANGELOG.txt CHANGELOG.txt index e03076f..5f8ce28 100644 --- CHANGELOG.txt +++ CHANGELOG.txt @@ -3,8 +3,15 @@ $Id$ 6.x-1.2 release =============== +If you were using the Customer Reviews feature in a view or otherwise, you'll +have a broken view, since Amazon has dropped customer review data from their API. +Instead, there is now a data item called "Customer reviews iframe" which is a +link to customer review information provided by Amazon suitable for placement +in an iframe. + - [#869286] by rfay: Add a configurable default image. Sponsored by fortmifflin.com - Thanks! - [#929748] by OV2: Expired data was being received from the database. +- [#905198] by the_g_bomb, rfay: Amazon no longer providing customer review data. - [#758630] by rfay: Views title should link to Amazon Store. - [#879830] by rfay, carpenoctum414: Amazon price does not show outside US. diff --git amazon.admin.inc amazon.admin.inc index d5ec8a2..13d2940 100644 --- amazon.admin.inc +++ amazon.admin.inc @@ -162,12 +162,11 @@ function amazon_storage_settings_form() { $form['details']['amazon_core_data'] = array( '#type' => 'checkboxes', '#title' => t('Store extended product data'), - '#default_value' => variable_get('amazon_core_data', array('creators', 'images')), + '#default_value' => variable_get('amazon_core_data', array('creators', 'images', 'editorial_reviews')), '#options' => array( 'creators' => t('Book authors, film actors, etc.'), 'images' => t('Product images'), 'editorial_reviews' => t('Editorial reviews'), - 'customer_reviews' => t('Customer reviews'), ), ); diff --git amazon.install amazon.install index 2cce35f..87df28e 100644 --- amazon.install +++ amazon.install @@ -78,6 +78,7 @@ function amazon_schema() { 'amazonpriceformattedprice' => array('type' => 'varchar', 'length' => 32), 'productgroup' => array('type' => 'varchar', 'length' => 255), 'producttypename' => array('type' => 'varchar', 'length' => 255), + 'customerreviews_iframe' => array('type' => 'varchar', 'length' => 255), 'invalid_asin' => array('type' => 'int', 'default' => 0), 'timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), ), @@ -118,17 +119,6 @@ function amazon_schema() { 'indexes' => array('asin' => array('asin')), ); - $schema['amazon_item_customer_review'] = array( - 'fields' => array( - 'asin' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE), - 'rating' => array('type' => 'numeric'), - 'date' => array('type' => 'varchar', 'length' => 11), - 'summary' => array('type' => 'text'), - 'content' => array('type' => 'text'), - ), - 'indexes' => array('asin' => array('asin')), - ); - $schema['amazon_item_node'] = array( 'fields' => array( 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), @@ -341,4 +331,16 @@ function amazon_update_6014() { $ret[] = update_sql('UPDATE {amazon_item} SET timestamp = 0;'); drupal_set_message(t('If you have enabled a default image, you may need to wait for a few cron runs (or run cron a few times) before all images are properly set up.')); return $ret; +} + +/** + * Amazon has stopped providing customer review data; now we only get an + * iframe link where Amazon will provide the data, so we need to drop the table + * that was used for customer reviews and add the new iframe link. + */ +function amazon_update_6015() { + db_add_field($ret, 'amazon_item', 'customerreviews_iframe', array('type' => 'varchar', 'length' => 255)); + db_drop_table($ret, 'amazon_item_customer_review'); + $ret[] = update_sql('UPDATE {amazon_item} SET timestamp = 0;'); + return $ret; } \ No newline at end of file diff --git amazon.module amazon.module index 2ce1cb6..be92a21 100644 --- amazon.module +++ amazon.module @@ -9,7 +9,7 @@ * save configuration and setup. */ -define('AMAZON_ECS_SCHEMA', '2009-03-31'); +define('AMAZON_ECS_SCHEMA', '2010-09-01'); define('AMAZON_PARTICIPANT_TYPES', 'Author,Artist,Actor,Director,Creator'); // Other common sizes include SwatchImage, TinyImage, and ThumbnailImage. @@ -117,8 +117,8 @@ function amazon_preprocess_amazon_item(&$variables) { $variables['type'] = _amazon_clean_type($item['producttypename']); $variables['detailpageurl'] = check_url($item['detailpageurl']); - $variables['editorialreview'] = !empty($item['editorialreviews']) ? filter_xss($item['editorialreviews'][0]['content']) : ''; - $variables['customerreview'] = !empty($item['customerreviews']) ? check_markup($item['customerreviews'][0]['content']) : ''; + $variables['editorialreview'] = !empty($item['editorialreviews']) ? check_markup($item['editorialreviews'][0]['content']) : ''; + $variables['customerreviews_iframe'] = !empty($item['customerreviews_iframe']) ? check_url($item['customerreviews_iframe']) : ''; $variables['invalid_asin'] = !empty($item['invalid_asin']) ? 1 : 0; if (!empty($variables['theatricalreleasedate'])) { @@ -525,14 +525,7 @@ function amazon_item_clean_xml($xml) { // And the customer reviews. if (isset($xml->CustomerReviews)) { - foreach($xml->CustomerReviews->Review as $data) { - $item['customerreviews'][] = array( - 'rating' => (string)$data->Rating, - 'date' => (string)$data->Date, - 'summary' => (string)$data->Summary, - 'content' => (string)$data->Content, - ); - } + $item['customerreviews_iframe'] = (string)$xml->CustomerReviews->IFrameURL; } // Give other modules an opportunity to pull out other bits of Amazon data @@ -625,16 +618,6 @@ function amazon_item_insert($item) { } } } - // Save the customer reviews if they exist. - if (in_array('customer_reviews', variable_get('amazon_core_data', array('creators', 'images')))) { - if (isset($item['customerreviews'])) { - foreach($item['customerreviews'] as $data) { - $review = array('asin' => $item['asin'], 'rating' => $data['rating'], 'date' => $data['date'], 'summary' => $data['summary'], 'content' => $data['content']); - drupal_write_record('amazon_item_customer_review', $review); - } - } - } - module_invoke_all('amazon_item_insert', $item); } @@ -650,7 +633,6 @@ function amazon_item_delete($asin) { db_query("DELETE FROM {amazon_item_participant} WHERE asin = '%s'", $asin); db_query("DELETE FROM {amazon_item_image} WHERE asin = '%s'", $asin); db_query("DELETE FROM {amazon_item_editorial_review} WHERE asin = '%s'", $asin); - db_query("DELETE FROM {amazon_item_customer_review} WHERE asin = '%s'", $asin); } /** diff --git includes/amazon.views.inc includes/amazon.views.inc index 270fcdc..94c0799 100644 --- includes/amazon.views.inc +++ includes/amazon.views.inc @@ -136,10 +136,11 @@ function amazon_views_data() { _amazon_make_simple_text_field($data, 'amazon_item', 'lowestpriceformattedprice', 'Lowest price (formatted)', 'The lowest available price.'); _amazon_make_simple_number_field($data, 'amazon_item', 'amazonpriceamount', 'Amazon Price (numeric)', "Amazon's current price for the item"); _amazon_make_simple_text_field($data, 'amazon_item', 'amazonpriceformattedprice', 'Amazon price (formatted)', "Amazon's current price for the item."); + _amazon_make_simple_text_field($data, 'amazon_item', 'customerreviews_iframe', 'Customer reviews iframe', "A link to an customer reviews provided by Amazon which is suitable for placement in an iframe"); _amazon_make_simple_boolean_field($data, 'amazon_item', 'invalid_asin', 'Invalid ASIN', 'If nonzero, the ASIN is invalid or discontinued by Amazon'); unset($data['amazon_item']['listpriceformattedprice']['argument']); - unset($data['amazon_item']['lowestformattedprice']['argument']); - unset($data['amazon_item']['amazonpriceformattedprice']['argument']); + unset($data['amazon_item']['lowestformattedprice']['argument']); + unset($data['amazon_item']['amazonpriceformattedprice']['argument']); // Define the base group of this table. Fields that don't // have a group defined will go into this field by default. @@ -211,21 +212,7 @@ function amazon_views_data() { ), ); _amazon_make_simple_text_field($data, 'amazon_item_editorial_review', 'source', 'Editorial review source', 'The source of this editorial review. Since there may be more than one review for each product, your view will produce one row per review.'); - _amazon_make_simple_markup_field($data, 'amazon_item_editorial_review', 'content', 'Editorial content', 'Content of an editorial review. Since there may be more than one review for each product, your view will produce one row per review.'); - - $data['amazon_item_customer_review']['table']['group'] = t('Amazon'); - $data['amazon_item_customer_review']['table']['join'] = array( - // customer review links to amazon_item directly via asin. - 'amazon_item' => array( - 'left_field' => 'asin', - 'field' => 'asin', - ), - ); - _amazon_make_simple_number_field($data, 'amazon_item_customer_review', 'rating', 'Customer Rating', "Numeric rating of this product. Since there is normally more than one review for each product, your view will produce one row per review."); - _amazon_make_simple_date_field($data, 'amazon_item_customer_review', 'date', 'Customer Rating Date', 'Date the product was rated. Since there is normally more than one review for each product, your view will produce one row per review.'); - _amazon_make_simple_text_field($data, 'amazon_item_customer_review', 'summary', 'Customer Review Summary', 'Summary of the review. Since there is normally more than one review for each product, your view will produce one row per review.'); - _amazon_make_simple_text_field($data, 'amazon_item_customer_review', 'content', 'Customer Review Content', 'Customer review content. Since there is normally more than one review for each product, your view will produce one row per review.'); - + _amazon_make_simple_text_field($data, 'amazon_item_editorial_review', 'content', 'Editorial content', 'Content of an editorial review. Since there may be more than one review for each product, your view will produce one row per review.'); return $data; }