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.

Comments

BradM’s picture

Status: Active » Needs review

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 prices
  amazon_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

asb’s picture

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

BradM’s picture

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

MGParisi’s picture

Status: Needs review » Needs work

I believe It doesn't change the current $node to include the new data

MGParisi’s picture

The patch is applied to http://drupal.org/node/289780#comment-945539

The node update issue is not yet solved:( This will remain open

MGParisi’s picture

Status: Needs work » Fixed

fixed, should be in dev

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.