Batch load of Products table (Import)

A place to discuss and receive support for the Web Auction application.

Batch load of Products table (Import)

Postby Karonthe » Thu Oct 23, 2008 2:56 am

Hello,

I'm a newbie to webauction, just starting to analyze it for customization.

The problem indeed may be due to my approach and don't know if I'm trying to use a hammer for something that is not intended for.

My periodic auctions (quarterly, maybe) would be opening and closing at specific dates/times, so the products (about 1000) would be all available for bidding or none at all. I'd also need the ability to send mass-mail to the winning bidders, one for each of them, listing all the stuff they have won. But this will be a further problem.

My first need is to populate the Products table in a batch way, maybe importing records from an Excel sheet or a plain text file. I can prepare such file as needed.

I think the "Import" feature would be the right way, but it seems to be locally customized. I've read How to write an import filter but don't know how to specify/send/transfer/write the product images. What should I do? Where should I write the import method (delegate classes)?

I'd appreciate your help. Thanks in advance.
Karonthe
 
Posts: 9
Joined: Tue Oct 21, 2008 6:03 am

Postby shannah » Thu Oct 23, 2008 9:21 am

My periodic auctions (quarterly, maybe) would be opening and closing at specific dates/times, so the products (about 1000) would be all available for bidding or none at all.


You can set the opening/closing dates in the auction settings. These would be the default opening and closing dates for all products that you add. You are also able to batch updates if you need to set the date for all products at once, using the "Update Set" command (admin only).

I'd also need the ability to send mass-mail to the winning bidders, one for each of them, listing all the stuff they have won. But this will be a further problem.

The auction already does send an email to the winner of each auction. The only key difference between the way that this works and the way you describe your mass email function is that one email per product is sent, rather than one email per winner. I.e. if a person wins 3 items, he'll receive 3 emails.

If you want to change how this works you may want to create a custom action.

Another important note is that if you have a lot of items all closing at the same time, you will want to make a change to how the auction works. Currently it checks for newly closed auctions on every page request and sends out the necessary emails. This is a problem if there are a thousand emails that need to go out at once.

The correction is fairly simple (and I've been meaning to add it to the distibution for a while).

Add the following to the include/functions.inc.php file:

Code: Select all
/**
* Obtain a mutex (to make sure we aren't running multiple instances
* of this script concurrently.
*
* This function will return true if it succeeded in obtaining the mutex
*   (i.e.  no other instance of this script is running.  And false otherwise.
* @param string $name The name of the mutex to acquire.
*/
function mutex($name){
   global $mutex;
   $path = dirname(__FILE__).'/../templates_c/'.$name.'.mutex';
   $mutex = fopen($path, 'w');
   if ( flock($mutex, LOCK_EX | LOCK_NB) ){
      register_shutdown_function('clear_mutex');
      return true;
   } else {
      return false;
   }
   
}

/**
* Clears the most recently acquired mutex.
*/
function clear_mutex(){
   global $mutex;
   if ( $mutex ){
      fclose($mutex);
   }
}


Then in the conf/ApplicationDelegate.php file, in the getPreferences() method, find a line:
Code: Select all
closeAuctions();


Change it to:

Code: Select all
if (mutex('closeAuctions')){
    closeAuctions();
}


This will ensure that if multiple requests come in at the same time, they won't both try to close the auctions.

My solution for the next distribution to solve this problem will be more complete, but this will handle it for now.

I've read How to write an import filter but don't know how to specify/send/transfer/write the product images. What should I do? Where should I write the import method (delegate classes)?


An import filter isn't that hard to write, but if you have it as a spreadsheet you could easily just import it using PHPMyadmin or another standard mysql administration tool.

As for the images, all images are stored in the tables/products/product_image directory. The name of the image is stored in the products table. So you can just copy the bunch of images into the correct directory and make sure their names are in your spreadsheet for import.

There are other fancier solutions you could come up with like importing a zip file that contains a spreadsheet and images.

Or you could base64encode your images in your spreadsheet.

Lots...

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Karonthe » Fri Oct 24, 2008 6:56 am

I'll follow your pointers and work a little deeper into them. I'm affraid I will come back to ask again :twisted:

Thank you very much for such a quick and complete answer, Steve :D
Karonthe
 
Posts: 9
Joined: Tue Oct 21, 2008 6:03 am


Return to Web Auction Discussion

Who is online

Users browsing this forum: No registered users and 15 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved