Dev Mod CSV Bulk Auction Importer

Discussion in 'Modding/Theme Help' started by renlok, Jan 10, 2013.

  1. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    Ok so I looked at DatatypeTrait.php on line 67 and saw that shortly below it had information about needing PHP 5.5.
    I was using a PHP 5.4 version..
    I switched to PHP 5.5
    (now I have no clue if other errors are going to happen around my site, so if I didnt have to switch, let me know and I'll switch back to 5.4)
    So using PHP 5.5, (Note: I didn't reinstall anything from scratch, just flipped a php version script switch on the hosting panel)..
    I tried reuploading the csv file and got this error.

    Fatal error: Cannot use object of type global_class as array in /srv/disk6/2117321/www/staticcolonies.com/testauction/admin/bulk/functions_bulk.php on line 1350
     
  2. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    I looked at functions_bulk.php, line 1350, which is:

    return $this->sys['SETTINGS']['maxpictures


    I removed all images from the CSV file, and I still get that error.
    I also tried it with images using the option:

    Overide Additional Image Limit
    Ignores 'maxpictures' setting and allows upload of more images if found

    I'm not sure what to do. Error log on the site is currently empty so.. that seems good.
     
  3. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Hi Grimus,
    that is an experimental class I started working on so does not do anything.
    Been testing on PHP 7 and 7.2.
    To stop the error you could replace the Validation class around line1338 in functions_bulk.php with the below

    PHP:
    //Validations
    class Validation
    {
        public 
    $errors = array();
        protected 
    $settings;
       
        public function 
    getMaxpictures() {
            global 
    $system;
            return 
    $system['SETTINGS']['maxpictures'];
        }

        public function 
    validate($data$rules)
        {

            
    $valid true;
            
    $this->errors = array();

            foreach (
    $rules as $fieldname => $rule)
            {
                
    $callbacks explode('|'$rule);

                foreach (
    $callbacks as $callback)
                {
                    
    $value = isset($data[$fieldname]) ? $data[$fieldname] : null;
                    if (
    $this->$callback($value$fieldname) == false)
                        
    $valid false;
                }
            }
            return 
    $valid;

        }

        public function 
    int_val($value$fieldname)
        {
            
    $valid = (int)$value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> needs to be a valid number";
            return 
    $valid;

        }
       
        public function 
    text_val($value$fieldname)
        {
            global 
    $system;
            
    $valid $system->cleanvars($valuefalse);

            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> is empty or contains invalid characters";
            return 
    $valid;

        }
       
        public function 
    title($value$fieldname)
        {
            
    $valid validate_title($value);

            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> is empty or contains invalid characters";
            return 
    $valid;

        }
       
        public function 
    time_val($value$fieldname)
        {
           
            
    $valid $value;
             

            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> number was not valid";
            return 
    $valid;

        }
       
        public function 
    starts($value$fieldname)
        {
           
            
    $valid $value;
             

            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> number was not valid";
            return 
    $valid;

        }
       
        public function 
    ends($value$fieldname)
        {
           
            
    $valid $value;
             

            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> number was not valid";
            return 
    $valid;

        }
       
        public function 
    image_val($value$fieldname)
        {
            
    $whitelist = array(".jpg",".jpeg",".gif",".png");
            
    $file_ext strrchr($value'.');
            if (!(
    in_array($file_ext$whitelist))) {
                
    $valid false;
            } else {
                
    $valid validate_image($value);
            }
           
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> extension was not valid";
            return 
    $valid;


        }
       
        public function 
    float_val($value$fieldname)
        {
            
    $valid = (float)$value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }

        public function 
    digitnory_val($value$fieldname)
        {
            if (
    $value != "2"$value "1";
            
    $valid $value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }
        public function 
    digityorn_val($value$fieldname)
        {
            if (
    $value != "1"$value "0";
            
    $valid $value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }

        public function 
    pay_val($value$fieldname)
        {
            
    $value validate_payment_method($value);
            if (
    $value == ''$value '0, 1';
            
    $valid $value;

            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not a payment method";
            return 
    $valid;

        }

        public function 
    yorn_val($value$fieldname)
        {
            
    $value strtolower($value);
            if (
    $value!= "y"$value "n";
            
    $valid $value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }
       
        public function 
    wordfilter($value$fieldname)
        {
            global 
    $system;
            
    $valid $value;
            if (
    $system->SETTINGS['wordsfilter'] == 'y') {
                    
    $valid $system->filter($value);
            }
           
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was prevented by the wordfilter";
            return 
    $valid;

        }
       
        public function 
    category($value$fieldname)
        {
            
    $valid $value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }
       
        public function 
    secondcat($value$fieldname)
        {
            
    $valid $value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }
        public function 
    suspended($value$fieldname)
        {
            
    $valid $value;
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> was not valid";
            return 
    $valid;

        }
       
       
        public function 
    required   ($value$fieldname)
        {
            
    $valid = !empty($value);
            if (
    $valid == false)
                
    $this->errors[] = "<b>$fieldname</b> is required";
            return 
    $valid;

        }
        public function 
    notrequired($value$fieldname)
        {
            
    $valid = empty($value);
            if (
    $valid == true)
                
    $this->errors[] = "<b>$fieldname</b> is optional";
            return 
    $valid;

        }
       
        public function 
    options($optionname)
        {
            
    $valid = !isset($optionname);
            if (
    $valid == false)
                
    $this->errors[] = "No option selected";
            return 
    $valid;

        }
       
    }
     
  4. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Yes csv parser needs PP 5.5 and above:
     
  5. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    Alright, so I added a single auction into the site, and then exported the auction to a csv file. I was able to add 30 copies (with numerical additions to add some unique data) of the auction into the site. According to the csv importer.

    The site currently does not show these new items while browsing, or listed in the category.

    They do however show when I go to the urls like:

    testauction/item.php?id=1
    testauction/item.php?id=2
    testauction/item.php?id=3

    Maybe the site needs to do a refresh or a cron or whatever.. not sure. I will check back on it later.

    I'm just happy that I was able to do an import so far even if the results are a little rickety
     
  6. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Nice one, it won't be the moderation setting as I have not added this yet. It might be that the user needs to pay if they have gone over their balance?
     
  7. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    What version of WeBid are you trying it on? If you are experimenting ramp the php up to latest if you can. You should be able to specify version of php for each domain/subdomain
     
  8. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    WeBid Version: 1.2.2.2
    PHP version 5.5.38
    MySQL version 5.7

    I thought maybe it was because I forgot to add the auction times. But added auction times and reuploaded but didn't notice a difference.
    I also changed titles around seeing if it would overwrite. I don't think it overwrote (like, changing prices, titles, descripts).

    Battery on laptop about to run out.

    Need to go charge..

    ttyl
     
  9. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    Updated to:
    Webid: 1.2.2.2
    PHP: 7.2.7
    MySQL version 5.7


    Ok, I don't think it is getting the catagories correct. When I export, one of the categories is correct, the other is marked as 0.
    When tried to correct, nothing seemed to happen. It imported "fine" but did not import to the website to be seen as browsable.
    Noticed when importing, when trying to give it an ID.. sometimes it would import it with a differed ID number.
    Example: Said for column 1 for have it as ID: 147 and in the database, and created url, it is item 183
    I wish I knew how to test it better but I can't get it right even if I'm doing text only. Where is your settings set up differently so that it works for you??
     
  10. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    Do you think setting it up for only 1 category would make it work?
     
  11. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    The Auction ID's are self created by the database. It uses autoincrement so if you delete any auctions that will continue to assign above its highest ever created. You will not be able to control that as , it is how webid works adding new auctions. You would not want to play with the ID's.
    On the categories it looks like you have items under no category (ALL CATEGORIES = 0 ) - the item does not belong in any category apart from ALL categories wich should not be possible?
    Go to you site front end and click to view all categories.
    When you hover over a category or click you will see the address is (your site/browse.php?id=75).
    That id is the category id. That corresponds to ALL_CATEGORIES/collectables/.
    You do not need to play with the auction id but the category id. If it is not found to be valid it will not upload the auction.
     
  12. Grimus

    Grimus New Member

    Joined:
    May 22, 2018
    Messages:
    21
    Likes Received:
    0
    This importer won't allow me to update prices on a bunch of auctions using a CSV.. correct? Once it is imported, it can't be edited by importing over it. Right?
     
  13. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    No, the importer will not let you overide existing or other uploaded auctions. Each one added will have a new Auction ID and will not affect any others.
    Any aucution ID in a csv file is never touched. Webid will assign its own id as the auctions are entered. Once uploaded editing is possible the standard Webid way.
     
  14. alexandratrese

    alexandratrese New Member

    Joined:
    Jun 28, 2018
    Messages:
    25
    Likes Received:
    0
    It seems like being able to upload an update CSV would be a good use case for some, myself included. Ex: you want to change the starting bid price or buy now price of the same auction. Being able to overwrite using the UIN (auction ID) could be a good idea. Just my 2c.
     
  15. alexandratrese

    alexandratrese New Member

    Joined:
    Jun 28, 2018
    Messages:
    25
    Likes Received:
    0
    Maybe it's better to ask the question here instead of having my own biases: If I need to bulk-modify auctions, is it better to create new auctions and archive the old ones or just modify the existing ones. Not a programmer, just using logic here, so go easy if I misuse words and jargon.

    Use case:
    I am selling used phones weekly. there are 500 discrete phones from last week that did not sell, so I'd like to put them up for auction again this time with lower starting bid prices and lower buy now prices. I have all the details in a csv file. Along with the 500 phones, I have 300 new phones for sale and 200 phones that were sold through another channel, so I need to reflect that these phones are now sold. My CSV File now has 1000 rows: 500 phones to alter, 300 to add and 200 to suspend/ archive/ mark sold.

    Proposed solution:
    Have logic that says
    If Phone UIN already exists then just modify the fields.
    If a field mark_sold = 1 then archive/ mark auction as completed.
    Keep a history of modifications, in case needed.
    If Phone UIN does not exist, then create new entry, and make auction live.

    Why is this better than creating a new auction?
    1. Potentially allows editing of the auction even if there are bids existing already (I get that there are other issues here too)
    2. Keeps history as 1:1 between phone and auction. Probably not a big thing. Not sure.

    Any comments/ thoughts?
     

Share This Page