Jump to content

[Free Module] Export Customers With Address


PhpMadman
 Share

Recommended Posts

This is ExportCustomers
 
It was the second module i made for PrestaShop.
As of January 2015, this module has been completely rewritten, and now features a UI in the configuration page.
It is based on Willem's export module located here: http://www.prestasho...ers-export-csv/

NOTE: Since it's built / based on Willem's module, it's named the same, and will replace willem's module, if installed.
 
post-465501-0-41555500-1420394928.jpg

Version 2.0

[-] Fixed module not beeing placed under Export tab in BO
[*] Moved export code to it's own function
[+] Added tabbed GUI
[~] Removed posibilty to export address id_customer
[+] Added upgrade code to auto-install database
[+] Automerge of fields with same name, disregards position
[+] Added option to set encoding
[+] Added code to replace new lines with / so csv won't break - thanks rufovi
[+] Added option only export customers / guests / both
[+] Added option to only export with newsletter
[+] Added option for gender text
[+] Added option to replace country id with name
[+] Added option to only export active customers
[+] Added logo

Version 2.0.1
[-] Fixed mysql error on install
[-] Fixed missing $this on _setSwitchType

Version 2.0.2
[-] Fixed undefined $input variable
[-] Tabs don't work on 1.5. Added a Scroll And Die interface

Version 2.0.3
[+] Added uninstall function to completely remove all data and settings
[+] Added options to delete the special commands

Version 2.0.4
[+] Added option to export customers with / without address
[*] Minor text updates



 
The module is also available at my webshop.
http://madmodules.pswebshop.com/free-modules/4-export-customer-with-address.html
At the bottom at the page there is an option to donate energydrinks to keep me running...
 

exportcustomers.zip

Edited by PhpMadman (see edit history)
  • Like 13

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 1 month later...
  • 3 weeks later...

Hello,

 

I am trying to make a small change to this script, but can not get it to work.

I want the first and lastname combined into 1 exported field which will be the customer id for accounting reasons.

 

$this->_html = '<hr><h2>'.$this->displayName.'</h2>';

$this->_html.= '<p>'.$this->l('This module allow to make a customers csv file.').'</p>';

 

$delimiter = "\t";

$toExport = array(

array('c.firstname . c.lastname','Firstname'),

array('a.firstname','aFirstname'),

array('a.lastname','aLastname'),

array('a.address1 . a.address2','Address1'),

array('a.postcode','Postcode'),

array('a.city','City'),

array('a.id_country','Country'),

array('c.email','Email'),

array('c.website','Website'),

);

 

with this I only get an empty .csv file.

Could somebody help me out?

 

Sanne

Share this post


Link to post
Share on other sites

Hi.

 

Sorry for the late replay. Been busy,

What i found on Google, if you write

array("CONCAT_WS(' ','c.firstname','c.lastname')'",'Fullname'),

My code shoudle be able to handle that, but it's untested. But it should write Firstname Lastname in to the column Fullname.

syntax is CONCAT_WS(seperator,column,coulmn,...)

Share this post


Link to post
Share on other sites

  • 4 months later...

Hi there,

Thanks for this module, tested and approved on presta 1.5.4.1.

One minor bug fix though : caracters with accents (ie: é,è,à) are not correctly encoded in the exported csv, for example :
"Sébastien" is exported as "Sébastien".

It's not a deal breaker at all since the module is free :-), however do you have plan or suggestion to fix this ? ths a lot

Regards

Share this post


Link to post
Share on other sites

Hi. I don't have that problem. I export my name Björn without a problem.

However. I'm just gonna assume that you use Windows or another OS that uses ISO encoding by default.

I personally run Linux Mint with an utf8 encoding.

 

But anyway. I have made an small update.

 

Version 1.3

It's now possible to override next customernumber to export

2 Files are created. export_customers_utf8.csv (previously know as export_customers.csv) and export_customers_iso.csv

Module now automatically exclude customers and addresses that are deleted.

exportcustomers.1.3.zip

  • Like 2

Share this post


Link to post
Share on other sites

  • 1 month later...

Hi. I don't have that problem. I export my name Björn without a problem.

However. I'm just gonna assume that you use Windows or another OS that uses ISO encoding by default.

I personally run Linux Mint with an utf8 encoding.

 

But anyway. I have made an small update.

 

Version 1.3

It's now possible to override next customernumber to export

2 Files are created. export_customers_utf8.csv (previously know as export_customers.csv) and export_customers_iso.csv

Module now automatically exclude customers and addresses that are deleted.

 

Thanks you for your module

 

And customers passwords don´t is possible export?

 

best regards

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Hello.

 

I made a module that exports customers to a csv file.

 

It is based on Willem's export module located here: http://www.prestasho...ers-export-csv/

 

Tested on PS 1.5.3.1

 

To export, go to configure and press the export button.

If you wish to edit the fields that is exported, edit modules/exportcustomers/exportcustomer.php

It contains a toExport table.

 

Here is an example

		$toExport = array(
			array('c.id_customer','Id'),
			array('c.firstname','Firstname'),
			array('a.lastname','Lastname'),
This will export the customers id and firstname from the customer table.

And customers lastname from the address table.

In the csv it will have the columns. Id,Firstname,Lastname

If you want to change the order of the csv file, for example to: Id,Lastname,Firstname

 

Then toExport should like this.

		$toExport = array(
			array('c.id_customer','Id'),
			array('a.lastname','Lastname'),
			array('c.firstname','Firstname'),
It will also only export new customers.

Configuration page will inform you what id number the next customer to be exported has.

 

NOTE: Since it's built / based on Willem's module, it's named the same, and will replace willem's module, if installed.

 

attachicon.gifexportcustomers.zip

 

 

Can be set to be done the info by categories?

Share this post


Link to post
Share on other sites

  • 2 months later...

I have uploaded version 1.4. Give that a try.

I changed the dl link to use inbuilt prestashop functions.

 

Thx for sharing. :) I really like your module, but I don't find this version 1.4.

 

Anyway, I'd like to suggest to use either a semicolon (which is ANSI standard) or tab character (works with both ANSI and unicode) as delimiter. In contrast to  a comma delimiter this forces both Excel and Open Office Calc to display the correct format at once just by double clicking the file.

Share this post


Link to post
Share on other sites

Comme on peut ajouter:  (product_name- Titre de la Commande), et la quantité de commande????

 

$toExport = array(

array('c.id_customer','Id'),
array('c.company','Company'),
array('a.firstname','aFirstname'),
array('a.lastname','aLastname'),
array('a.address1','Address1'),
array('a.address2','Address2'),
array('a.postcode','Postcode'),
array('a.city','city'),
array('a.id_country','country'),



i need  add:

product_name, et la quantité

Help Me Please!   ;)

Edited by Axel444 (see edit history)

Share this post


Link to post
Share on other sites

Please write in english. But what I understand of your post, you want to add product name and the qty ordered.

That would require a different but similar module. This one focus on exporting customers. You would need one that focus on exporting orders.

Share this post


Link to post
Share on other sites

  • 2 months later...

It's explained in first post.

Edit the php file and add

array('c.id_gender','Gender'),

 

To the toExport table. This will give you ID of the gender.

 

If I have time, i'll make an update for 1.6 on this module.

And then move the settings of toExport in to PrestaShop's interface..

No need to edit php file.

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hey !

 

I love this module but i cannot have what i want :

 

Export the country ID is good, but can i export the Country Name instead ?

 

i tested some stuffs but it does not work :

 

array('c.country','Country'),

array('a.country','Country'),

array('c.name_country','Country'),

array('c.country_name','Country'),

 

 

???

 

Thx for the help :)

Share this post


Link to post
Share on other sites

Hello.

It's not really supported but this should work:

 

if you don't use the ps_ prefix, you need to change that. And id_lang should be changed to your language (ID is found under Localization > Languages)

 

array('(SELECT name FROM ps_country_lang WHERE id_country = a.id_country AND id_lang = 1)','Country'),

 

But whenever I get the time to make an version for 1.5-1.6 i'll include support for this.

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 2 weeks later...

Can u help me. If Im interested only in one customer group for example male (id - 6) how to export only male type customers?

 

Hello.

I made a module that exports customers to a csv file.

It is based on Willem's export module located here: http://www.prestasho...ers-export-csv/

Tested on PS 1.5.3.1

To export, go to configure and press the export button.
If you wish to edit the fields that is exported, edit modules/exportcustomers/exportcustomer.php
It contains a toExport table.

Here is an example



$toExport = array(

array('c.id_customer','Id'),

array('c.firstname','Firstname'),

array('a.lastname','Lastname'),

This will export the customers id and firstname from the customer table.
And customers lastname from the address table.
In the csv it will have the columns. Id,Firstname,Lastname
If you want to change the order of the csv file, for example to: Id,Lastname,Firstname

Then toExport should like this.



$toExport = array(

array('c.id_customer','Id'),

array('a.lastname','Lastname'),

array('c.firstname','Firstname'),

It will also only export new customers.
Configuration page will inform you what id number the next customer to be exported has.

NOTE: Since it's built / based on Willem's module, it's named the same, and will replace willem's module, if installed.

attachicon.gifexportcustomers.zip

Share this post


Link to post
Share on other sites

That's not supported. It requires and edit of the WHERE statement.

 

 

 

*Update*

I said I would update it for 1.6.

But I currently involved in 3 diffrent projects on my freetime. So I don't simply have the time.

If anyone want's to help, the module is on github. https://github.com/PhpMadman/PrestaShop-MadModules/tree/exportcustomers

Edited by PhpMadman (see edit history)

Share this post


Link to post
Share on other sites

  • 5 weeks later...

I installed the module on Prestashop 1.6.0.5 and it works. But it does exactly what the Export feature does in Back Office - it exports in the same format:

Id;Firstname;Lastname;Email;Website;Orgnr;Company;aFirstname;aLastname;Address1;Address2;Postcode;Phone;Mobilephone

Is there any way you can have the data exported like this?

 

Id   Firstname    Lastname       Email                        Etc           Etc

1    John            Smithing         [email protected]  

 

Thanks,

Nicu.

Edited by nzecheru (see edit history)

Share this post


Link to post
Share on other sites

I'm guessing you want it tab separated.

It should be possible by editing this line

https://github.com/PhpMadman/PrestaShop-MadModules/blob/exportcustomers/exportcustomers/exportcustomers.php#L57

change the ";" to "\t"

 

Thank you for your quick reply. I changed the delimiter to "\t" and now it looks like this:

Id Firstname Lastname Email Website Orgnr Company aFirstname aLastname Address1 Address2 Postcode Phone Mobile

What I am trying to achieve is to have the data displayed as columns:

ID      FirstName

1       name1

2       name2

3       name3

4       name4

Share this post


Link to post
Share on other sites

You have to describe some more.

With \t you get columns. All data is separated by a tab.  If you need to increase the space between columns, just add more \t's to the delimiter.

If you still don't achieve what you want, can you provide a sample file of what exactly you want to do?

Share this post


Link to post
Share on other sites

  • 2 months later...

Hello,

 

I would like to export all the informations about my customers (as much as it's possible), such thing like this :

 

- Numbers of orders

- Numbers of cart

- Loyalty points

-

 

these specific datas to analyse more the customer behaviour.

 

Is it possible with Export Customers (powered by the best Madman :) ) ?

Share this post


Link to post
Share on other sites

  • 4 weeks later...
  • 5 weeks later...

How do I install this module? My Prestashop does not seem to have an "add module button".  When I go to export my customers in a CSV it brings all the information into one column and thus I cannot click on just the emails and I do not wish to wade through 3000 customers.  Does anyone have any suggestions?

Thanks,

 

post-871331-0-49700900-1415893296_thumb.png

Share this post


Link to post
Share on other sites

@wakeforest

 

I'm a bit confued by your post. It's like you are saying you can't install it, but then you say export does not work.

 

In Modules > Modules, in the top right corner there is a add module button.

After install then press the configure link to be able to export.

And if you open the file csv file after download, and get everything in one column, I'm gonna assume you use MS Office.

Then you need to change the delimiter. I highlighted the line in this github link. For MS you probably gonna need, and not default ;

https://github.com/PhpMadman/PrestaShop-MadModules/blob/excusv1.4.1/exportcustomers/exportcustomers.php#L57

 

@gingerling

 

I belive last connection is stored in connections tabel.

As the module is now, that is not supported.

And currently I don't have time to update this module. I need to focus on work, and support for my paid modules.

But I have a ToDo list for this module.

 

As an alternative, It is possible to write a sql in to the arrays.

See this post.

 

http://www.prestashop.com/forums/topic/220774-free-module-export-customers-with-address/?p=1655794

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Great module PhpMadman!!

 

Just if it helps anybody...

Testing the module, I've found a particular issue with the 'Other' field (Address table):

 

I've added the following line:

array('a.other','Other')

If a customer fills this field with carriage return (more than 1 line) the CSV is not well interpreted.

To skip this, I've used the str_replace function by adding 2 additional lines (1 at ISO generation code block, and 1 at UTF8 generation code block)

 

original:

$string = implode($delimiter, $orderline);

after adding str_replace:

$string = implode($delimiter, $orderline);
$string = str_replace(array("\n", "\t", "\r"), '/', $string);

You can replace the carriage return by any character, '/' in my example.

 

Be aware: These lines will replace any carriage returns and tabs existing in ALL the fields exported.

 

Hope this helps.

 

Best regards,

 

rufovi.

Share this post


Link to post
Share on other sites

I finnaly started working on version 2.0.

 

This is the first draft of the interface.

Genrell will contain the actuall export, and also settings like, pyferret's idea about a selecting to export only customer with newsletter or not. And what delimiter to use.

 

Active Fields, is where to setup what fields should be exported, and also what name they should have in the csv.

 

Positions will be used to sort the order of the fields.

 

I think that is the best soultions, since it's need to set if it's enabled, the name and position of every field.

 

post-465501-0-13191500-1418979917_thumb.png

Share this post


Link to post
Share on other sites

  • 2 weeks later...

I have a question.

 

Doe anyone use the last exported customer ID feature?

By default the module saves the last exported id, so you can export only the new customers after latest export.

Does anyone use that, or does most of you replace it with your own number?

 

I thinking of chaning this feature, and just save the number you manually entered in the config.

But if this feature is used alot, i'll keep it as it is.

 

 

And to keep you up to date.

The basic gui is finished, and export is working fine.

Now i'm working on adding the sweets, suchs as only export customer / guest / both, newsletter reg / not / both and so on.

I'm also looking in to how to make an option for replacing the gender id's with letters M / F / N, and alos replacing country id with a real name.

 

Another highlight is the automerge. If two fields have the same name, they will be used as one, using the position of the first field with that name. In theory you can merge how many field as you want.

Share this post


Link to post
Share on other sites

Hello, this module seems to be great, but I am not able to install it; error:

 

 

 

[PrestaShopDatabaseException]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NUL `expcusfield` VARCHAR(255) NOT NULL, `label` VARCHAR(255) NOT NULL, `n' at line 3
 

CREATE TABLE IF NOT EXISTS `ps_export_customer_fields` (
        `id` INT(10) NOT NULL AUTO_INCREMENT,
        `type` VARCHAR( 255 ) NOT NUL
        `expcusfield` VARCHAR(255) NOT NULL,
        `label` VARCHAR(255) NOT NULL,
        `name` VARCHAR(255) NOT NULL,
        `active` INT(10) DEFAULT 0,
        `position` INT(10) DEFAULT 0,
        PRIMARY KEY (`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

at line 607 in file classes/db/Db.php

 

601.             WebserviceRequest::getInstance()->setError(500, '
 '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
602.         }
603.         else if (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS'))
604.         {
605.             if ($sql)
606.                 throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
607.             throw new PrestaShopDatabaseException($this->getMsgError());
608.         }
609.     }

 

probably missing characters "L," after " `type` VARCHAR( 255 ) NOT NUL"

if this is the problem, where to correct it?

 

[sOLVED]: it was on line 94 in exportcustomers.php - then installed OK.

Edited by rivan11 (see edit history)

Share this post


Link to post
Share on other sites

Another problem:

 

 

Fatal error: Call to undefined function _setSwitchType() in /var/www/vhosts/domain.tld/httpdocs/modules/exportcustomers/exportcustomers.php on line 415 [PrestaShop] Fatal error in module exportcustomers:
Call to undefined function _setSwitchType()

when trying to config; any ideas?

Share this post


Link to post
Share on other sites

  • 5 months later...

hello, thanks for your work...

but you did a mess about compatibility 'cause you didn't develop with backward for 1.4 and you even use the HelperForm class...

your first versions were compatible with 1.4 ? can you do it or upload a working version? thanks

Share this post


Link to post
Share on other sites

hello, thanks for your work...

but you did a mess about compatibility 'cause you didn't develop with backward for 1.4 and you even use the HelperForm class...

your first versions were compatible with 1.4 ? can you do it or upload a working version? thanks

 

 

Hello.

 

My version was never for 1.4. I have only devolped for 1.5 and 1.6

You are thinking about the the orginal, made by willem https://www.prestashop.com/forums/topic/123145-customers-export-csv/

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi there,

 

           I have installed this module on localhost and prestashop 1.5.4.1 after trying couple of time to install directly from backoffice  prestashop kept telling module downloaded successfully but I was not able to find it back office. so unzipped copied unzipped folder into module folder of prestashop than module showed up in prestashop.

 

But when I clicked configure list is disorder I kindly request to take look at screen shot attached with this post.  how to fix this.

 

Even if you look screen shot 2 set position has only save button

 

I also tired to export data use few option it create a csv file but file is empty. Am i missing something are there any steps that need to be followed to make this work.

 

I have uninstalled and installed module couple of time

post-375930-0-76965500-1436192987_thumb.jpg

post-375930-0-92287400-1436193013_thumb.jpg

Share this post


Link to post
Share on other sites

Hi.

 

I don't know why you get an empty file.

Enable a simple thing as Customer ID, Check that you allow any type of customer, with / without newsletter and so,

 

As for the interface, I could not get a tabbed interface work properly, so instead I added a Scroll And Die interface, with shortcut buttons.

Share this post


Link to post
Share on other sites

I just tried and it did the magic. thank you so much. you are my hero. :wub::)

 

I would like to know what is set position used for when i started there no filed in that section only save button. Then it showed the filed i exported ID, Name , Last name and email after export. I used these filed for testing It where in set position section with some number like 1, 10,11,12

Edited by Zen_j1 (see edit history)

Share this post


Link to post
Share on other sites

  • 1 month later...

If you export the password, you need copy some string from your settings.php

I don't rember what exactly, but I know there are alot of guides for it.

Google something alon the lines, Move customers to a new PrestaShop.

Share this post


Link to post
Share on other sites

  • 1 month later...

I just wanted to thank you because your module has been very useful to me. Had no problem to make it work with Prestashop 1.6.1.0

 

I appreciated the listed fields in comments. I had a special case : retrieve the list of customer (only email, first and lastname) of user who had already ordered at least once. Here's the changes I did in the SQL request, if it can be useful to someone in the future :

$sql .= " FROM "._DB_PREFIX_."customer c, "._DB_PREFIX_."orders 
WHERE c.id_customer = o.id_customer AND o.id_customer > $cust_id AND c.deleted = 
ORDER BY c.id_customer ASC";

Share this post


Link to post
Share on other sites

  • 4 months later...

Hi! Thanks for ur work!

I installed the module and works, but i have a problem with Merge delimiter. I set to " to make the fields like "Customer ID","Customer Company".... but nothing changed when export.

Always exporte file has...  Customer ID,Customer Company,Customer Firstname,Customer Lastname,

I try to change delimiter to "," but the first column doesnt have in start, looks like Customer ID","Customer Company"... widthout first "

Any help? Sorry for bad english. Thanks!

Edited by xuban (see edit history)

Share this post


Link to post
Share on other sites

I installed the module and it works just fine, it's a great program, except it's not picking ALL the customers, I tried various settings but it didn't export the full list no matter what I did.

 

Any ideas ?

 

It is designed to pick only the customers that has address. Does the number of rows exported match the number of addresses stored in PrestaShop?

 

 

 

 

Hi! Thanks for ur work!

I installed the module and works, but i have a problem with Merge delimiter. I set to " to make the fields like "Customer ID","Customer Company".... but nothing changed when export.

Always exporte file has...  Customer ID,Customer Company,Customer Firstname,Customer Lastname,

I try to change delimiter to "," but the first column doesnt have in start, looks like Customer ID","Customer Company"... widthout first "

Any help? Sorry for bad english. Thanks!

 

It does not currently support adding " like that. The idea is to mimic PrestaShop's csv design for import, and that is without ", they only use ; as separator for fields.

Edited by PhpMadman (see edit history)

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Hi.

 

I fixed the bug that caused this.

Version 2.0.3 is available in the first post.

 

HOWEVER due to this bug, your install is completely screwed. So you need to do the following steps.

1. Upgrade files to version 2.0.3 (This is to get bug fix)

2. Uninstall module (Will remove ALL data for module, for each re-install made, mysql data was cloned)

3. Install Version 2.0.3 (All should now be fine)

Share this post


Link to post
Share on other sites

Now uninstal works fine, but when I try to export data (example ID customers & e-mail) I got file only with:

Customer ID;Customer Shop ID;Customer Firstname;Customer Lastname;Customer Email;Customer Password Hash;Customer Last Password Gen;Customer Secure Key;Customer Date Add;Address Alias;Address Company;Address Firstname;Address Lastname;Address Address1;Address Address2;Address Postcode;Address City;Address Other;Address Phone;Address Mobilephone

 

My prestashop is 1.6.1.4

Share this post


Link to post
Share on other sites

  • 2 months later...