Failure to import sample csv

This topic contains 6 replies, has 3 voices, and was last updated by  Paolo 9 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #8729

    physicaltherapistcom
    Full Member
    Post count: 35

    I’ve trying to import the unmodified sample CSV file with no luck:

    Data inserted successfully.
    Total of 0 records inserted.
    Total of 3 records not inserted due to invalid address.

    What could be causing the sample to not import correctly?
    We are using GeoDirectory v1.1.6.

    #8731

    Guust
    Moderator
    Post count: 29970

    Can you review this post
    https://wpgeodirectory.com/support/topic/import-csv/#post-7753
    and let us know how you went.
    I am not sure the latest version already incorporated that improvement.

    #8732

    physicaltherapistcom
    Full Member
    Post count: 35

    I replaced the admin_funcitons.php but still get the same results.

    Any other options?

    *Edit* – As a side note, the admin_functions.php file from the post is identical to the one shipped with v1.1.6

    #8738

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    did you created the categories present in the sample file before trying to upload it?

    That’s the only mandatory thing to do before a CSV upload, make sure all CSV mandatory fields aren’t empty and that categories have been previously created.

    Thx

    #8811

    physicaltherapistcom
    Full Member
    Post count: 35

    Stepping through the debugger, it’s actually happening here (lines 1218-1247):

    
    
    $location_result = geodir_get_default_location();
    if($location_result->location_id == 0 ){
    
        if((!isset($gd_post_info['post_city']) ||
            strtolower($gd_post_info['post_city']) != strtolower($location_result->city)) ||
            (!isset($gd_post_info['post_region']) ||
            strtolower($gd_post_info['post_region']) != strtolower($location_result->region)) ||
            (!isset($gd_post_info['post_country']) ||
            strtolower($gd_post_info['post_country']) != strtolower($location_result->country)) ||
            (!isset($gd_post_info['post_address']) ||
            $gd_post_info['post_address']=='') ||
            (!isset($gd_post_info['post_latitude']) ||
            $gd_post_info['post_latitude'] == '') ||
            (!isset($gd_post_info['post_longitude']) ||
            $gd_post_info['post_longitude'] == '')){
        $address_invalid++;
        continue;
    
            }
    
        }else{
    
            if((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address']=='') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')){
    
                $address_invalid++;
                continue;
    
            }
    
    }

    The sample upload matched the first long “if isset” conditional, increments $address_invalid and continues.

    If I’m looking at it correctly, talking about the sample file:
    It pulls the default location, which I have set.
    Then it compares data pulled from the csv and fails if one of the location keys do not exists (which they do) or if the city, region or country key does not equal the default location.

    Pretty sure thats whats getting it. Why does each imported record need to match the default location?

    #8848

    physicaltherapistcom
    Full Member
    Post count: 35

    Now I see…

    It looks like with a default install of just the GEODirectory plugin, the default location gets a location_id equal to 0. Which causes the first if statement listed above to be true which then, based on the logic, will causes any imported places to fail if they are not at the default location.

    When the GEODirectory Location Manager is installed, the default location’s location_id gets set to 1 which skips that check.

    I would propose either the message generated from the import when not using the Location Manager is revised and notify the user that the imported items were not at the default location and possibly give them a hint to install the location manager.

    You may also want to give some type of hint near the sample csv download to let users know it only works if the location manager is installed.

    #8862

    Paolo
    Site Admin
    Post count: 31206

    Hi @physicaltherapistcom,

    yes you are correct, there is a validation to make sure places are imported only for default location in case multilocation isn’t installed.

    We will add better error messages to avoid confusion.

    I’ve flagged this for the developers.

    thanks for the suggestions!

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket