refreshing prices
BradM - May 6, 2008 - 14:56
| Project: | Amazon associate tools |
| Version: | 5.x-1.5 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Just checking to see if anyone has had success in refreshing prices under the manage tab. About 90% of my prices are marked as stale, but even setting to 1 pass (10 items), the prices do not update...the same # remains marked as stale. Nothing shows up in the logs after the attempt so no errors seem to be occurring.

#1
Fixed this one. I've set it so now each time an amazon node is viewed, (a) it runs the built-in price refresher to check for stale prices, and (b) updates the node itself if it is old -- before it displays the actual data. It shouldn't weigh too heavily on the server as the refresher itself only updates 10 stale prices at a time.
This has also fixed the problem with a ton of images that are no longer available due to Amazon changing the way they name images.
In the function
theme_amazon_node, insert this code before any of the existing code:// do an amazon cron run to update some stale pricesamazon_cron();
// refresh item if older than a week
$stale_price_date = date('Y-m-d', time() - 604800); //604800 is a week of seconds
if ($node->pricedate <= $stale_price_date) {
$ASIN_update = _amazon_product_data_from_Amazon($node->asin);
// update the amazonitem record
if (count($ASIN_update) > 0) {
foreach($ASIN_update as $ASIN_data) {
_refresh_amazonitem_data($ASIN_data);
}
}
}
Brad
#2
Hi Brad,
nice work!
I applied this code in "amazon.module" directly below the "function theme_amazon_node($node) {" statement;
* pros:
** (a) site and module seem not to break (very good!);
** (b) images and pricing data are refreshed when editing and saving the node ;-)
* cons:
** (a) prices and images are not refreshed when simply loading a node, but after refreshing the node;
** (b) this fix seems not to have any effect for images/data embedded in blocks provided by AAT like "We recommend".
** (c) Also, this fix seems to to correct data from the AAT node type "amazon-node".
However, this fix helps greatly refreshing AAT data - even when it will take some time to repair 25.000 nodes ;-)
Thanks again & greetings, -asb
#3
LOL yeah I did notice after posting that it refreshes after the fact...but at least it's updating. ;) I'm not exactly sure why, as I thought I put it in a logical place. But I'm just a hack so the fact that it's working is a surprise in itself. ;)
EDIT> just a thought, maybe it doesn't update on its own because Drupal is displaying a cached page? Don't know enough about the inner workings to make sense of it all.
It doesn't update blocks, as that is in a separate section I believe. Try adding the same code in the function
amazon_block... not exactly sure where to place it though. I just figured I'd wait till the fix trickled through my db, as I only have about 4000 items to refresh. It shouldn't take too long -- it's been 2 days since I implemented it, and it's refreshed about 3000 items. On a busier site, it will probably go faster than that.Brad
#4
I believe It doesn't change the current $node to include the new data
#5
The patch is applied to http://drupal.org/node/289780#comment-945539
The node update issue is not yet solved:( This will remain open
#6
fixed, should be in dev
#7
Automatically closed -- issue fixed for two weeks with no activity.