When I enter a valid Amazon product ID in a node's amazon field, I'm told:
Amazon ID : No Amazon product with the ID 1842779079 could be located.
However, I can search for the same product ID using the test feature of the module (path admin/settings/amazon/test). That works fine.
I don't understand the workings of the module, but the validate operation of the asin_field will always fail.
$results = _asin_load_items($items);
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'])));
}
}
}
return $items;
The _asin_load_items function returns an array that is not indexed by ASIN, so empty($results[$item['asin']]) is always true.
Comments
Comment #1
Anonymous (not verified) commentedThe problem appears to originate in the amazon_item_lookup function. It also may only affect PHP 5.
The function is returning a merged array. The array_merge function though destroys numeric keys on merged arrays.
see http://php.net/array_merge
I don't know if it's possible to force the array_merge function to treat the keys as strings instead of numerals.
Comment #2
Shai commentedI had the same problem. I've tested the patch on it solved the problem perfectly for my installation.
Just to make things clear for folks about when the problem will occur. ISBNs or ASINs that begin with a zero will be processed without problem by the module (php sees that as a string). The problem comes when the product identifier number does not begin with a zero.
It would be great if a few more people could test the patch so that we could get this committed.
Thanks so much bangpoud.
Comment #3
tcblack commentedFWIW it does not break for ISBN's that start with 0's either. I haven't tested for other ISBN's yet though I can confirm that it still does not work with ISBN13
Comment #4
Anonymous (not verified) commentedPlease rename the issue title if it might help people find it. I didn't realize I was working exclusively with ISBN13.
Comment #5
conniec commentedI can second that confirmation that the patch doesn't work with 13 digit ISBNs.
I wrote a PHP script written to change 13 digit ISBNs to 10 digit ISBNs. I have no idea how to incorporate it into a patch so it's not really doing me much good except to convert my ISBNs so I can manually enter the shorter ones.
If anyone wants the script to use in a patch, let me know.
Connie
Comment #6
mleicester commentedI've added some EAN / 13 digit ISBN support to the CCK field / testing interface in a patch on #288577: 13 digit ISBNs / EAN support / converting to ASINs.
Comment #7
joemoraca commentedThe code in the patch worked for me. I just tried four books before I applied the patch it found none and then updated the code and it found all of the books -- I was just using the 10 digit ISBN
Comment #8
bomarmonk commentedbangpound, I tried your initial patch and the other patches listed in this post. I still get "warning: Invalid argument supplied for foreach() in /home/.muckl/mysite.com/sites/all/modules/amazon/amazon.module on line 269." Also see my post here http://drupal.org/node/269335 and a duplicate support request from someone else here: http://drupal.org/node/293826
Comment #9
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 #10
smscotten commentedI'm using beta5 but applied the patch from bangpound, which fixed the issue for me.
More information if it is helpful: I did not encounter rejection on all products, and the one that I encountered was an ISBN-10, not 13.
I think it would be great if the patch were to be rolled in to the module distribution. It's a pretty simple patch.
Comment #11
bomarmonk commentedI am still having trouble with the CCK field: it doesn't display anything after inputting the ISBN...
Comment #12
rburr49 commentedJust a bump to say that this patch still seems to be necessary :(
RB
Comment #13
tonyn commentedSame issue.
1590597559 works on test
But on node: ASIN : No Amazon product with the ID 1590597559 could be located.
Comment #14
Shai commentedI had the same problem. ISBN numbers that begin with "1" did not work as described in the initial post. I applied the patch found in comment #1 to the latest dev version. It applied cleanly and fixed the problem.
Shai
Comment #15
Anonymous (not verified) commentedI'm going to RTBC this, because it's really been ages...
Comment #16
EloE commentedThanks a lot for that patch, bangpound. Works perfectly for me.
Comment #17
gregglesAgreed, tested and works for me.
Comment #18
asb commentedSame issue here; bangpounds patch from #1 works for me and solves the problem. Could we please get this into a release?
Thanks & greetings, -asb
Comment #19
eaton commentedCommitted to the current branch. Thanks for the fix, sorry it's taken so long to get this one in place.
Comment #20
asb commented@eaton:
Thank you. It's great to have you back ;)
Greetings, -asb
Comment #21
eaton commentedIt's great to be back. ;-) I realized I hadn't been receiving amazon module issue emails, and hadn't done a thorough manual scan of my issue queue for a while.
Comment #23
calebm12 commentedI dont know if maybe i am using an edition that already has the patch incorporated into it or not. But i was getting the same error people are talking about here. What i noticed is that if you Copy and Paste the ISBN number from Amazon it actually copies a blank space after the last digit in the ISBN. If you remove the space....or if you copy the number very carefuly from amazon before pasting it.....everything works fine.
Comment #24
vinoth.3v commentedany updates?
even with valid ASIN, it says
ASIN : No Amazon product with the ASIN "B0035ER236" could be located
Comment #25
rfayI would say you're probably using a locale that doesn't have that ASIN. I just checked that ASIN and it's valid in the UK locale, but not in the US or France locales.
This issue is long-since closed, and nobody has reported more trouble with this. In this issue, the test feature worked, but other lookups didn't.