How can I Import Stores using CSV Sheet?

Adding stores into your store locator can be done with the “Add New Store” page. However, if you have a long list of stores you can quickly import them using CSV Sheet Import. Furthermore, the plugin has a template that the admin can follow by adding all his/her stores’ details.

For more information on how to import or export stores’ data onto Agile Store Locator, please see the following article.

The columns for CSV sheet import are the following:

title, description, street, city, state, zip, country, lat, lng, phone, fax, email, website, is_disabled, logo_name, categories, marker_id, logo_image, description_2, open_hours, (any custom field)

In addition, you can also include any custom fields that you have created, in the CSV sheet. This is done by adding custom columns to the CSV sheet.

Custom Field Manager in ASL Settings
Custom Field Manager in ASL Settings
Field Name
title
description
street
city
state
postal_code
country
lat
lng
phone
fax
email
website
is_disabled
logo_name
categories
marker_id
logo_image
description_2
open_hours
Columns of the CSV file

It is absolutely critical to keep the header as the first row, and the header must be in the smaller case without any extra spacing.

If you have coordinates missing, the import tool will fetch them from the Google Geo-Encoding API. Furthermore, the mandatory columns are the city, state, and zip code columns to get accurate coordinates.

Please make sure the Google Server API key has been added and validated, by clicking over the “Validate API Key” button, before you proceed with the import.

Validate API Key Button on Import/Export Page
Validate API Key Button on Import/Export Page

Can I update stores using a CSV file? #

Yes, you can update the stores using a CSV file with the same import process, all you need is to make sure that the CSV file has a column named update_id that will contain the store id it will perform an update operation instead of the insertion, so to get that file to update the existing records, you need to export it with “Export with Store IDs” enabled, and then click on the Export button.

export with store ids

In case the update_id is not there, it will simply perform insertion and it may duplicate your stores if you will import it twice.

blank
CSV file with update_id column to update stores

Generating CSV File with Update_ID Column for Store Updates #

To obtain a CSV file containing the necessary update_id column for store updates, follow these steps:

  1. Navigate to the export functionality within the Import/Export tab.
  2. Before exporting, locate and activate the “Export with Store IDs” switch. This action ensures that the exported CSV file will include the required update_id column.
  3. Once the switch is enabled, proceed to click on the Export button.
  4. The exported CSV file will now contain the update_id column, which corresponds to the store ID. This column serves as a unique identifier for updating existing rows during subsequent imports.
export stores csv file

By adhering to these steps, you can generate a Stores CSV file with the update_id column, facilitating seamless updates to your store data within the Agile Store Locator plugin.

How I Can Change the Update Key from Store ID to some Other Field? #

By default, the update_id must be the store id but in case you want it from other another attribute, you can utilize the following filter to change the update_id column attribute and add the following code to your functions.php file, the asl_csv_update_key filter is available since version 4.8.32.

// To change the update key from store id to some other field
add_filter('asl_csv_update_key', function($update_key){

	//	change the update key to description, custom fields are not supported for the update key
	$update_key = 'description';

	return $update_key;
});

After adding the above code to your functions.php file, the update operation will try to match the description value for the update instead of the store id.

List of the supported fields for the above update key (update_id).

title, description, street, city, state, zip, country, lat, lng, phone, fax, email, description_2
Insert Store for Missing key #

Starting from version 4.10.5, we have introduced an option through which the row will be imported even if it has a value in the update_id column, so first it will try to find the existing update_id is available in the database, in case it is not available, it will go for insertion.

You need to define a constant in your wp-config.php to enable this feature.

define( 'ASL_INSERT_ON_UPDATE', '1' );
blank

This feature should be used with the default fields only, that are supported for update_id column.

How can I Add Categories Through Import? #

The import tool will automatically create categories and will assign them to stores. Moreover, you must add a pipe character “|” in-between multiple categories if you want to assign multiple categories to a single store.

import categories

How I Can Add a Logo Using the Import Tool? #

You can add your logo name and logo image to these columns: “logo_name” and “logo_image”. You have to upload the logo images which can be in these formats (jpg, png, jpeg, gif, jpg) through FTP service in the “Logo” folder under this directory location.

"/wp-content/uploads/agile-store-locator/Logo"

The import method will only consider the logo_image field if the store logo_name doesn’t exist in the store locator logos. If you want to create a new logo make sure you have already uploaded a logo image into the following folder:

"/wp-content/uploads/agile-store-locator/Logo"

In addition, the logo_name must be unique and shouldn’t exist in the existing Logo list.

What is the Store(s) Hours Format in the CSV Sheet? #

You can feed multiple slots of timing for each day, the format that you will feed in the open_hours columns will be as shown below:

mon=1|tue=0|wed=7:00 AM-9:00PM|thu=0|fri=7:00 AM-9:00PM,7:00 AM-9:00PM

Where you can see that days are separated by the ‘|’ sign, while multiple time slots are separated by the comma sign.

Why the “0 rows updated” Message? #

In case you are importing a CSV file and it reports that no rows are being imported, there are a few possible reasons behind it which are as follows.

1- Please make sure that the CSV file has the same format that is provided in the template of the Store Locator Import/Export page, if the headers are missing or in a capital case, it will not be considered.

2- Another key point is to make sure that the update_id column is empty as it will try to update rows instead of the insertion, and those stores might not be in the database to be updated.

3- Please check the delimiters of the CSV file, they must be comma-separated, you can verify them by uploading them into Google Spreadsheet.

Import Action Events #

Since version 4.8.32, we have provided two WordPress actions that are executed before and after the import file. These events are triggered using the following:

Before Import:

do_action( 'asl_before_stores_import' );

You can use this action to perform any custom operations or modifications before the store’s CSV file is imported.

Example code can be added to the functions.php file of your theme.

add_action('asl_before_stores_import', function() {
  
  // Do Something
});

After Import:

do_action( 'asl_after_stores_import' );

This action allows you to execute additional tasks or actions after the store’s CSV file has been successfully imported.

By utilizing these actions, you can extend the functionality of the import process and integrate any necessary customizations or additional operations as per your requirements.