Webcreta_Exportcustomers - Version 0.1.0

Version Notes

Fixed minor bugs

Download this release

Release Info

Developer WebCreta
Extension Webcreta_Exportcustomers
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Webcreta/Exportcustomers/Block/Exportcustomers.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Webcreta_Exportcustomers_Block_Exportcustomers extends Mage_Core_Block_Template
3
+ {
4
+
5
+ }
app/code/local/Webcreta/Exportcustomers/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_Exportcustomers_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ }
app/code/local/Webcreta/Exportcustomers/controllers/Adminhtml/ExportcustomersController.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Webcreta_Exportcustomers_Adminhtml_ExportcustomersController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ public function indexAction()
7
+ {
8
+ $this->loadLayout()->renderLayout();
9
+ }
10
+
11
+ public function exportcustomersAction() {
12
+ $data = $this->getRequest()->getPost();
13
+ try{
14
+ if(isset($data['filename'])){
15
+ $filename=$data['filename'];
16
+ }
17
+ else{
18
+ $filename="exportcustomers";
19
+ }
20
+ $resource = Mage::getSingleton('core/resource');
21
+ $readConnection = $resource->getConnection('core_read');
22
+ if($data['customers_type']=="all"){
23
+ $query = 'SELECT * FROM ' . $resource->getTableName('sales/order');
24
+ $results = $readConnection->fetchAll($query);
25
+ $email_arr=array();
26
+ $i=0;$j=0;
27
+ $filename=$_POST['filename'];
28
+
29
+ foreach($results as $r){
30
+ $email_arr[$i]=array($r['customer_email'],$r['customer_firstname'],$r['customer_middlename'],$r['customer_lastname'],$r['customer_suffix'],$r['customer_prefix'],$r['customer_dob'],$r['customer_gender'],Mage::getModel('customer/group')->load($r['customer_group_id'])->getCustomerGroupCode());
31
+ $i++;
32
+ }
33
+ $query2 = 'SELECT * FROM customer_entity';
34
+ $email_arr2=array();
35
+ $results2 = $readConnection->fetchAll($query2);
36
+ foreach($results2 as $r2){
37
+
38
+ $customer = Mage::getModel("customer/customer");
39
+ $customer->setWebsiteId(Mage::app()->getWebsite('admin')->getId());
40
+ $customer->load($r2['entity_id']);
41
+ $email_arr2[$j]=array($customer->getEmail(),$customer->getFirstname(),$customer->getMiddlename(),$customer->getLastname(),$customer->getSuffix(),$customer->getPrefix(),$customer->getDob(),$customer->getResource()->getAttribute('gender')->getSource()->getOptionText($customer->getData('gender')),Mage::getModel('customer/group')->load($customer->getGroupId())->getCustomerGroupCode());
42
+ $j++;
43
+
44
+ }
45
+ $array_both = array_merge($email_arr,$email_arr2);
46
+ $array_both = array_map("unserialize", array_unique(array_map("serialize", $array_both)));
47
+ $content="Email,First name,Middle name,Last name,Suffix,Prefix,Date of birth,Gender,Group"."\n";
48
+ foreach($array_both as $em){
49
+ $content.=$em[0];
50
+ $content.=",";
51
+ $content.=$em[1];
52
+ $content.=",";
53
+ $content.=$em[2];
54
+ $content.=",";
55
+ $content.=$em[3];
56
+ $content.=",";
57
+ $content.=$em[4];
58
+ $content.=",";
59
+ $content.=$em[5];
60
+ $content.=",";
61
+ $content.=$em[6];
62
+ $content.=",";
63
+ $content.=$em[7];
64
+ $content.=",";
65
+ $content.=$em[8];
66
+ $content.=",";
67
+ $content.=$em[9];
68
+ $content.="\n";
69
+ }
70
+ }
71
+ //echo $content;
72
+ if($data['customers_type']=="registered"){
73
+ $query2 = 'SELECT * FROM customer_entity';
74
+ $email_arr2=array();
75
+ $j=0;
76
+ $results2 = $readConnection->fetchAll($query2);
77
+ foreach($results2 as $r2){
78
+ $customer = Mage::getModel("customer/customer");
79
+ $customer->setWebsiteId(Mage::app()->getWebsite('admin')->getId());
80
+ $customer->load($r2['entity_id']);
81
+ $email_arr2[$j]=array($customer->getEmail(),$customer->getFirstname(),$customer->getMiddlename(),$customer->getLastname(),$customer->getSuffix(),$customer->getPrefix(),$customer->getDob(),$customer->getResource()->getAttribute('gender')->getSource()->getOptionText($customer->getData('gender')),Mage::getModel('customer/group')->load($customer->getGroupId())->getCustomerGroupCode());
82
+ $j++;
83
+ }
84
+ $content="Email,First name,Middle name,Last name,Suffix,Prefix,Date of birth,Gender,Group"."\n";
85
+ foreach($email_arr2 as $em){
86
+ $content.=$em[0];
87
+ $content.=",";
88
+ $content.=$em[1];
89
+ $content.=",";
90
+ $content.=$em[2];
91
+ $content.=",";
92
+ $content.=$em[3];
93
+ $content.=",";
94
+ $content.=$em[4];
95
+ $content.=",";
96
+ $content.=$em[5];
97
+ $content.=",";
98
+ $content.=$em[6];
99
+ $content.=",";
100
+ $content.=$em[7];
101
+ $content.=",";
102
+ $content.=$em[8];
103
+ $content.=",";
104
+ $content.=$em[9];
105
+ $content.="\n";
106
+ }
107
+ }
108
+ if($data['customers_type']=="guests"){
109
+ $query = 'SELECT * FROM ' . $resource->getTableName('sales/order');
110
+ $results = $readConnection->fetchAll($query);
111
+ $email_arr=array();
112
+ $i=0;
113
+ $filename=$_POST['filename'];
114
+ foreach($results as $r){
115
+ $email_arr[$i]=array($r['customer_email'],$r['customer_firstname'],$r['customer_middlename'],$r['customer_lastname'],$r['customer_suffix'],$r['customer_prefix'],$r['customer_dob'],$r['customer_gender'],Mage::getModel('customer/group')->load($r['customer_group_id'])->getCustomerGroupCode());
116
+ $i++;
117
+ }
118
+ $email_unique = array_map("unserialize", array_unique(array_map("serialize", $email_arr)));
119
+ $content="Email,First name,Middle name,Last name,Suffix,Prefix,Date of birth,Gender,Group"."\n";
120
+ foreach($email_unique as $em){
121
+ $customer = Mage::getModel('customer/customer');
122
+ $customer->setWebsiteId(Mage::app()->getWebsite('admin')->getId());
123
+ $customer->loadByEmail(trim($em));
124
+ if (!$customer->getId()) {
125
+ $content.=$em[0];
126
+ $content.=",";
127
+ $content.=$em[1];
128
+ $content.=",";
129
+ $content.=$em[2];
130
+ $content.=",";
131
+ $content.=$em[3];
132
+ $content.=",";
133
+ $content.=$em[4];
134
+ $content.=",";
135
+ $content.=$em[5];
136
+ $content.=",";
137
+ $content.=$em[6];
138
+ $content.=",";
139
+ $content.=$em[7];
140
+ $content.=",";
141
+ $content.=$em[8];
142
+ $content.=",";
143
+ $content.=$em[9];
144
+ $content.="\n";
145
+ }
146
+ }
147
+ }
148
+ $fp = fopen(Mage::getBaseDir('media'). "/exportcustomers/".$filename.".csv","wb");
149
+ fwrite($fp,$content);
150
+ fclose($fp);
151
+ Mage::getSingleton('adminhtml/session')->addSuccess('Customers are successfully exported. Click <a href="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'media/exportcustomers/'.$filename.'.csv" download>here</a> to download');
152
+ }catch (Exception $e) {
153
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
154
+ }
155
+ $this->_redirect('*/*/');
156
+ }
157
+ }
app/code/local/Webcreta/Exportcustomers/etc/config.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webcreta_Exportcustomers>
5
+ <version>0.1.0</version>
6
+ </Webcreta_Exportcustomers>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <exportcustomers>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Webcreta_Exportcustomers</module>
14
+ <frontName>exportcustomers</frontName>
15
+ </args>
16
+ </exportcustomers>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <menu>
21
+ <main_menu translate="title" module="exportcustomers">
22
+ <title>Webcreta</title>
23
+ <sort_order>70</sort_order>
24
+ <children>
25
+ <exportcustomers translate="title" module="exportcustomers">
26
+ <title>Export Customers</title>
27
+ <sort_order>100</sort_order>
28
+ <action>exportcustomers/adminhtml_exportcustomers</action>
29
+ </exportcustomers>
30
+ </children>
31
+ </main_menu>
32
+ </menu>
33
+ <acl>
34
+ <resources>
35
+ <all>
36
+ <title>Allow Everything</title>
37
+ </all>
38
+ <admin>
39
+ <children>
40
+ <system>
41
+ <children>
42
+ <config>
43
+ <children>
44
+ <exportcustomers>
45
+ <title>Webcreta - All</title>
46
+ </exportcustomers>
47
+ </children>
48
+ </config>
49
+ </children>
50
+ </system>
51
+ </children>
52
+ </admin>
53
+ </resources>
54
+ </acl>
55
+ <layout>
56
+ <updates>
57
+ <exportcustomers>
58
+ <file>exportcustomers.xml</file>
59
+ </exportcustomers>
60
+ </updates>
61
+ </layout>
62
+ </adminhtml>
63
+ <global>
64
+ <models>
65
+ <exportcustomers>
66
+ <class>Webcreta_Exportcustomers_Model</class>
67
+ </exportcustomers>
68
+ </models>
69
+ <blocks>
70
+ <exportcustomers>
71
+ <class>Webcreta_Exportcustomers_Block</class>
72
+ </exportcustomers>
73
+ </blocks>
74
+ <helpers>
75
+ <exportcustomers>
76
+ <class>Webcreta_Exportcustomers_Helper</class>
77
+ </exportcustomers>
78
+ </helpers>
79
+ </global>
80
+ </config>
app/design/adminhtml/default/default/layout/exportcustomers.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <exportcustomers_adminhtml_exportcustomers_index>
4
+ <update handle="exportcustomers_index"/>
5
+ <reference name="content">
6
+ <block type="adminhtml/template" name="exportcustomers" template="exportcustomers/exportcustomers.phtml"/>
7
+ </reference>
8
+ </exportcustomers_adminhtml_exportcustomers_index>
9
+ </layout>
app/design/adminhtml/default/default/template/exportcustomers/exportcustomers.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3>Export All Customers Now</h3></td>
5
+ <td class="a-right">&emsp;
6
+ </td>
7
+ </tr>
8
+ </table>
9
+ </div>
10
+ <div class="entry-edit">
11
+ <form id="edit_form" name="edit_form" method="post" action="<?php echo $this->getUrl('*/*/exportcustomers')?>">
12
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
13
+ <h4 class="icon-head head-edit-form fieldset-legend">Export Customers Form</h4>
14
+ <fieldset id="my-fieldset">
15
+ <table cellspacing="0" class="form-list">
16
+ <tr><td>Filename: <input type="text" name="filename"></td></tr>
17
+ <tr><td><input type="radio" name="customers_type" value="all" selected="selected"> All Customers</td></tr>
18
+ <tr><td><input type="radio" name="customers_type" value="guests"> Guest customers only</td></tr>
19
+ <tr><td><input type="radio" name="customers_type" value="registered"> Registered customers only</td></tr>
20
+ <tr><td><button onclick="editForm.submit()" class="scalable save" type="button"><span>Export Customers</span></button></td></tr>
21
+ </table>
22
+ </fieldset>
23
+ </form>
24
+ </div>
25
+ <script type="text/javascript">
26
+ var editForm = new varienForm('edit_form');
27
+ </script>
28
+ <style>
29
+ #my-fieldset td{padding:5px}
30
+ #my-fieldset select{min-height:150px;}
31
+ </style>
app/etc/modules/Webcreta_Exportcustomers.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Webcreta_Exportcustomers>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </Webcreta_Exportcustomers>
7
+ </modules>
8
+ </config>
doc/Exportcustomers.PDF ADDED
Binary file
media/exportcustomers/.DS_Store ADDED
Binary file
media/exportcustomers/exportcustomers.csv ADDED
File without changes
media/exportcustomers/guest.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ Email,First name,Middle name,Last name,Suffix,Prefix,Date of birth,Gender,Group
2
+ jaimin.webcreta@gmail.com,Jaimin,,Patel,,,,,General,
3
+ vd.webcreta@gmail.com,Vicky,,Darji,,,,,General,
media/exportcustomers/registered.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Email,First name,Middle name,Last name,Suffix,Prefix,Date of birth,Gender,Group
2
+ jaimin.webcreta@gmail.com,Jaimin,,Patel,,,,,General,
3
+ vd.webcreta@gmail.com,Vicky,,Darji,,,,,General,
4
+ jc.mca1985@gmail.com,Jignesh,,Chauhan,,,,,General,
5
+ jaimin.webcreta1@gmail.com,Jaimin,,Patel,,,,,General,
6
+ milan.webcreta@gmail.com,Milan,,Chauhan,,,,,General,
7
+ a@b.com,Nikunj,,Darji,,,,,General,
8
+ a@bc.com,Nikunj,,Darji,,,,,General,
9
+ a@cd.com,Nikunj,,Darji,,,,,General,
10
+ a@de.com,Nikunj,,Darji,,,,,General,
11
+ a@ef.con,Nikunj,,Darji,,,,,General,
12
+ nikunjs295@gmail.com,Nikunj,,Darji,,,,,General,
13
+ viky.031@gmail.com,Vicky031,,Darji031,,,,,General,
14
+ jai.031290@gmail.com,jai,,Darji,,,,,General,
15
+ viky.90@gmail.com,Vicky,,Darji,,,,,General,
media/exportcustomers/testing.csv ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Email,First name,Middle name,Last name,Suffix,Prefix,Date of birth,Gender,Group
2
+ jaimin.webcreta@gmail.com,Jaimin,,Patel,,,,,General,
3
+ vd.webcreta@gmail.com,Vicky,,Darji,,,,,General,
4
+ jaimin.webcreta@gmail.com,Jaimin,,Patel,,,,,General,
5
+ vd.webcreta@gmail.com,Vicky,,Darji,,,,,General,
6
+ jc.mca1985@gmail.com,Jignesh,,Chauhan,,,,,General,
7
+ jaimin.webcreta1@gmail.com,Jaimin,,Patel,,,,,General,
8
+ milan.webcreta@gmail.com,Milan,,Chauhan,,,,,General,
9
+ a@b.com,Nikunj,,Darji,,,,,General,
10
+ a@bc.com,Nikunj,,Darji,,,,,General,
11
+ a@cd.com,Nikunj,,Darji,,,,,General,
12
+ a@de.com,Nikunj,,Darji,,,,,General,
13
+ a@ef.con,Nikunj,,Darji,,,,,General,
14
+ nikunjs295@gmail.com,Nikunj,,Darji,,,,,General,
15
+ viky.031@gmail.com,Vicky031,,Darji031,,,,,General,
16
+ jai.031290@gmail.com,jai,,Darji,,,,,General,
17
+ viky.90@gmail.com,Vicky,,Darji,,,,,General,
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Webcreta_Exportcustomers</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Webcreta customer export extension seamlessly exports Registered and Guest customers to CSV comma separated file, directly from Admin Dashboard</summary>
10
+ <description>Webcreta customer export extension seamlessly exports Registered and Guest customers to CSV comma separated file, directly from Admin Dashboard Webcreta Export A perfect solution if you need to export your customer data out of your magento store to import the data back into your e-commerce store or marketing tool.</description>
11
+ <notes>Fixed minor bugs</notes>
12
+ <authors><author><name>WebCreta</name><user>WebCreta</user><email>webcreta@gmail.com</email></author></authors>
13
+ <date>2017-03-02</date>
14
+ <time>11:31:10</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Webcreta_Exportcustomers.xml" hash="31f2a0db4a9dd24df946ed777f0ffc6e"/></dir></target><target name="magelocal"><dir name="Webcreta"><dir name="Exportcustomers"><dir name="Block"><file name="Exportcustomers.php" hash="2740452811e8566d7806cc9da6b6bbeb"/></dir><dir name="Helper"><file name="Data.php" hash="612dd9366fc64426dee2954e5c38432f"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportcustomersController.php" hash="6c756a55a52724b34da954e5cda94f25"/></dir></dir><dir name="etc"><file name="config.xml" hash="98a8bcb8aaffa987dfb15042e165dcc2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="exportcustomers.xml" hash="0654d037492a0980498c04701e1e007b"/></dir><dir name="template"><dir name="exportcustomers"><file name="exportcustomers.phtml" hash="df3be56ce1c5dee9baf6e60268139f74"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="doc"><file name="Exportcustomers.PDF" hash="fb63c79b13a03c80dc57d09226b2553a"/></dir><dir name="media"><dir name="exportcustomers"><file name="exportcustomers.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="guest.csv" hash="025b8e05427158feb6cbc3ae546614bd"/><file name="registered.csv" hash="0b1b2a92be4e5c6db97fae1772ee8ce0"/><file name="testing.csv" hash="f7e853bfbdca7d6428f9c94f40404592"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>