Some Amazon products do not have the "producttypename" set! Using an associative array variable with that key before checking to see if the variable is set first results in the following error message:

Warning: Illegal string offset 'producttypename' in _amazon_item_classes() (line 246 of ...\modules\amazon\amazon.module).

Here is the original code starting at line 238 in the amazon.module file that generates the error:

/**
 * Create name of the extra css class for an item.
 *
 * @param $item
 *   The amazon_item.
 */
function _amazon_item_classes($item) {
  return 'amazon-item amazon-item-' . str_replace('_', '-', _amazon_clean_type($item['producttypename']));
}

Here is the updated code that would resolve the issue which I would recommend:

/**
 * Create name of the extra css class for an item.
 *
 * @param $item
 *   The amazon_item.
 */
function _amazon_item_classes($item) {
  if (isset($item['producttypename'])) {
    return 'amazon-item amazon-item-' . str_replace('_', '-', _amazon_clean_type($item['producttypename']));
  } else {
    return 'amazon-item amazon-item-' . 'unknownproducttypename';
  }

Thanks in advance for implementing this fix!

Comments

frmcclurg created an issue.