Forums / All Other Contributions/Addons / Converting call from application_top to autoloader! Auction Cron Job

Converting call from application_top to autoloader! Auction Cron Job

Locked

Views: 1,067

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
27 Jun 2010, 9:47 PM
#1
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Converting call from application_top to autoloader! Auction Cron Job

I've got most of the other suggextions done, but the code change for application_top was wipe from the email.

How do I convert this from application_top to autoloader!

if (AUCTION_CRON_ENABLE == '0') {
  require(DIR_WS_CLASSES . 'class.productauction.php');
  productAuction::checkAuctionStatuses();
  }
```The way it was used is to check date and time for any closed auctions then process them if true.  The switch is to allow for a CRON Job and not do a check on each page load.  I've setup the config.auction.php in the auto_loaders folder like so...

$autoLoadConfig[0][] = array('autoType'=>'class',
'loadFile'=> 'class.productauction.php');

$autoLoadConfig[170][] = array('autoType'=>'classInstantiate',
'className'=>'productauction',
'objectName'=>'checkAuctionStatuses');


Also, Is their another way to do the switch?

Dave
Always forward thinking... Lost my mind!

29 Jun 2010, 4:53 AM
#2
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Re: Converting call from application_top to autoloader! Auction Cron Job

OK.... fiddled around with it enough for it to work...

$autoLoadConfig[0][] = array('autoType'=>'class',
                                'loadFile'=> 'class.productauction.php');
                                
   $autoLoadConfig[170][] = array('autoType'=>'classInstantiate',
                                'className'=>'productAuction',
                                'objectName'=>'productAuction');
```  Worked, className and objectName needed to be the same, copying the function in class productAuction from checkAuctionStatuses() to productAuction() worked.  Then I used the CRON switch in productAuction()...  The CRON would call the checkAuctionStatuses()

Dave
Always forward thinking... Lost my mind!

29 Jun 2010, 8:45 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Converting call from application_top to autoloader! Auction Cron Job

davewest:

The way it was used is to check date and time for any closed auctions then process them if true. The switch is to allow for a CRON Job and not do a check on each page load.

Also, Is their another way to do the switch?
But ... the way you used the switch previously caused it to operate like this:
a) if run from cron job, then it checked statuses
b) if run by customer click firing application_top, and switch was '0' (which suggests "off"), then it checked statuses.

So, a runs if cron is on, and b runs if cron is off. So, that means it always runs. Thus there's no point for a switch.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

29 Jun 2010, 1:36 PM
#4
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Re: Converting call from application_top to autoloader! Auction Cron Job

DrByte:

But ... the way you used the switch previously caused it to operate like this:
a) if run from cron job, then it checked statuses
b) if run by customer click firing application_top, and switch was '0' (which suggests "off"), then it checked statuses.

So, a runs if cron is on, and b runs if cron is off. So, that means it always runs. Thus there's no point for a switch.
The thought behind the switch was to turn it off if the user could create a CRON Job to run the checks at a set time instead of every page load. Thinking that on a heavy accessed site with lots of auctions, having the checks run on each page load would slow things down. If both are used, then it would double the checks.

I don't use it at all on my site, but I don't have allot of auction items yet.

Dave
Always forward thinking... Lost my mind!

29 Jun 2010, 5:22 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Converting call from application_top to autoloader! Auction Cron Job

Then I guess the code should have been checking for the switch == '1' instead of '0'. Of course, that would change the suggestions as well.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.