hello,
i was wondering if there's a way to auto-populate the ASIN field based on the Title field of a node. for example if i had a node with title "American Heritage Dictionary" i would love to be able to auto populate the ASIN with the first Amazon product search result for that string, so that for my hundreds or thousands of nodes i could grab the closest ASIN matches without having to look up and type each one in by hand. i know it wouldn't work perfectly each time, but this would be an amazing feature.
thanks!
Comments
Comment #1
rfayNo, nothing like this right now. It would be a nice feature.
Comment #2
wxman commentedI did the opposite of what you want. People just type the ASIN and the rest of the form populates itself.
Comment #3
rfay@wxman, please share your entire recipe here, and probably on the documentation page. Thanks!
@wrb123, patches and improvements are welcome.
Thanks,
-Randy
Comment #4
wxman commentedI'll do it as soon as I can. Right now I'm working on having a stroke, because four people wanted me to redesign their sites at the same time, and make them Drupal sites. If I survive, I'll let you see what I have.
Comment #5
wrb123 commentedi'd love to implement this if i knew how... is there any way you can just post the code on here wxman, and maybe one of us can try to interpret and/or reverse it to do what i was asking or provide a patch for this module? keep it open source! :D and keep an aspirin nearby.
Comment #6
wrb123 commentedSOLUTION:
this isn't really necessary in a module! Amazon has an awesome way to automate this, sort of, using some Javascript!
go to https://widgets.amazon.com/Widget-Source/
and you can play around with different settings and use the Preview button to see the different widgets, you change the value amzn_wdgt.tag= to your referral id thing so you get paid if they click your link and buy something from amazon, and using the table farther down that page you can see that amzn_wdgt.keywords = can be set to a string value IF you set amzn_wdgt.WidgetType='SearchAndAdd'; (you can just add that line in the code box, or any other lines you want that are compatible with the amazon format as noted in the table they provide).
so then you can put the resulting javascript it generates for you into a Block and do something like
$thisnode=node_load(arg(1)); $searchstring=$thisnode->title; $shortenedsearchstring=substr($searchstring,0,60);and then you can use the value $shortenedsearchstring to set amzn_wdgt.keywords = $shortenedsearchstring; in the javascript Amazon generates, this will take the current node where the Block is being loaded, search amazon for the first 60 characters of the node title (if it's that long or longer - amazon limits the search you can use in their javascript widget to 60 characters, but this should get a decent result) and return the result to the widget!hopefully everyone understands that... you have to make sure your Block has a javascript and php capable input format, if you need to you can create a new input format in your drupal settings (under Site Config.->Input Formats i think) and just check the PHP box, name it whatever you want like 'javascript format', make sure only the site admin can use it, save the input format, and then select it when youre creating the block.
if anyone has any questions getting this working let me know... you can probably do a little more with this with some more clever coding.
Comment #7
davidneedhamIs there an easy way to have the results from an Amazon search populate CCK fields? For example:
1. Textbook content type has the Amazon field, as well as fields for the appropriate values returned from Amazon (book title, edition, author, etc).
2. User creates a new node by entering the AISN or ISBN.
3. Information from Amazon populates the other fields.
4. Fields can be overridden by changing the field after the information is populated.
I had originally thought this might be possible by using multistep - putting the Amazon field on the first step, then the populated fields on step two. I had intended to use the CCK field's default value (php) to pull in the Amazon information stored in the node, but the default values are created when the node is created - before the Amazon information exists.
Any ideas?
Comment #8
rfayI think you might find some ways of creating a CCK field from a view, which might work. Not thinking of anything else off the top of my head.
Comment #9
rfayComment #10
queryblitz commentedThank you, wrb123, very much for this info! I used your instructions to set it up on www.Lickitornot.com and I also went ahead and posted a tutorial if you want to check it out.