Steps to reproduce
1. Add a Amazon CCK field to content type
2. Make new content of that content type and fill in 1591840562 for the Amazon ID
3. Submit
4. A message will show up: "No Amazon product with the ID 1591840562 could be located."
Check the contents of the mysql database and the content for id 1591840562 is present. Furthermore the test
Furthermore if you go to
admin/settings/amazon/test
and fill in 1591840562 as the ID it works fine.
The error popups in asin.module
foreach ($items as $delta => $item) {
if (is_array($item)) {
if (!empty($item['asin']) && empty($results[$item['asin']])) {
form_set_error($field['field_name'] .']['. $delta .'][asin', t('%name : No Amazon product with the ID %id could be located.', array('%name' => t($field['widget']['label']), '%id' => $item['asin'])));
}
}
}
I think empty($results[$item['asin']]) is not correct and should be empty($results[$delta]['asin']). In that case I don't get the error message but the amazon data doesn't show up
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | amazon.array_merge.patch | 725 bytes | Robrecht Jacques |
| #3 | amazon.zip | 5.62 KB | Arinaya |
Comments
Comment #1
najibx commentedwhat's the different Amazon CCK item - Text Field and Lookup by Title?
when using admin/settings/amazon/test,
it shows the actual books, and array. I will then use the field of that array to create my field, field_AMAZON_FIELD
For example i use the field "asin" (which become field_asin CCK field ) for the ISBN.
but always getting ISBN : No Amazon product with the ID 1584794747 could be located.
Another question is, what happen for books not listed in Amazon? So I shall have 2 ISBN type?
Comment #2
amccann commentedI'm seeing the same thing but it is inconsistent - some products work, some don't.
Comment #3
Arinaya commentedOk, I was running into the same bug, so here is a fix.
This seems to affect any book whose ISBN begins with '1'. When adding these ISBNs as an array key, PHP automatically converts it to an integer, even though it was a string to start with. Then, when array_merge() is called at the end of amazon_item_lookup(), the ISBN is lost entirely (array_merge() sees a numeric index, and so resets it to 0, as far as I can tell).
So I replaced the call to array_merge() with a for loop that takes care of merging the two arrays. This seems to fix the issue, at least for the cases I have tested.
In other words, I replaced
with this:
Sorry, I don't know how we're supposed to submit code changes, I am attaching an updated amazon.module file as a .zip
Edit: the attached amazon.module is from 6.x-1.0-beta5, so if you're running a different version you may just want to copy-paste the above lines into the end of amazon_item_lookup().
Comment #4
scott859 commentedSame problem here...
Thanks for the patch, I will try it.
Scott
Comment #5
bomarmonk commentedArinaya, I tried your version of the module, but I get "warning: Invalid argument supplied for foreach() in /home/mysite.com/sites/all/modules/amazon/amazon.module on line 275."
Comment #6
bomarmonk commentedHmmm... I switched to my own Amazon API key, and now things seem to work. Maybe the problem was with the default key when the module is first installed?
Comment #7
Jaap Haitsma commentedThanks your proposed fix works for me
Comment #8
Robrecht Jacques commentedPatch attached. Tested and ready to commit.
Comment #9
Anonymous (not verified) commentedWorks for me too, thanks.
Comment #10
qmaria commentedI believe this is the same problem in this other issue
http://drupal.org/node/302721
The other issue has a patch that is only a one line change and is easier to apply.
The patch is available in comment 1 of that thread.
Comment #11
gregglesAgreed - duplicate of #302721: Amazon field rejects any product ID. Amazon API test feature works fine though.