Dotsquares_Exportprofiles - Version 0.1.0

Version Notes

First Release

Download this release

Release Info

Developer Dotsquares
Extension Dotsquares_Exportprofiles
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Dotsquares/Exportprofiles/Model/Convert/Adapter/Subscribers.php ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotsquares_Exportprofiles_Model_Convert_Adapter_Subscribers extends Mage_Dataflow_Model_Convert_Adapter_Abstract
3
+ {
4
+ const SET_NAME_KEY = 0;
5
+ const GROUP_NAME_KEY = 1;
6
+
7
+ /**
8
+ * Current store model
9
+ *
10
+ * @var Mage_Core_Model_Store
11
+ */
12
+ protected $_store = null;
13
+
14
+ /**
15
+ * @var int
16
+ */
17
+ protected $_entityTypeId = null;
18
+ protected $_orderBy = 'subscriber_id';
19
+ protected $_orderDir = 'ASC';
20
+ protected $_limit = 0;
21
+ protected $_subscriberModel;
22
+
23
+ /**
24
+ * @var int
25
+ * @todo add multi-store functionality
26
+ */
27
+ protected $_admin = 0;
28
+
29
+ /**
30
+ * @return int
31
+ */
32
+
33
+ /**
34
+ * @return int
35
+ * @throws Exception
36
+ */
37
+ public function getStoreId()
38
+ {
39
+ if (is_null($this->_store)) {
40
+ try {
41
+ $this->_store = Mage::app()->getStore($this->getVar('store'));
42
+ }
43
+ catch (Exception $e) {
44
+ $message = Mage::helper('dataflow')->__('Invalid store specified');
45
+ $this->addException($message, Varien_Convert_Exception::FATAL);
46
+ throw $e;
47
+ }
48
+ }
49
+
50
+ return $this->_store->getId();
51
+ }
52
+
53
+ /**
54
+ * Retrieve website model by code
55
+ *
56
+ * @param int $websiteId
57
+ * @return Mage_Core_Model_Website
58
+ */
59
+ public function getWebsiteId($storeId=null)
60
+ {
61
+ try {
62
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
63
+ }
64
+ catch (Exception $e) {
65
+ $message = Mage::helper('dataflow')->__('Invalid website specified');
66
+ $this->addException($message, Varien_Convert_Exception::FATAL);
67
+ throw $e;
68
+ }
69
+ return $websiteId;
70
+
71
+ //$iDefaultStoreId = Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
72
+ }
73
+
74
+ /**
75
+ * Retrieve store object by code
76
+ *
77
+ * @param string $store
78
+ * @return Mage_Core_Model_Store
79
+ */
80
+ public function getStoreById($id=NULL)
81
+ {
82
+ if (empty($id)) {
83
+ //$this->_store = Mage::app()->getStore(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
84
+ return Mage::app()->getWebsite(true)->getDefaultGroup()->getDefaultStoreId();
85
+ } else {
86
+ try {
87
+ $this->_store = Mage::app()->getStore($id);
88
+ }
89
+ catch (Exception $e) {
90
+ $message = Mage::helper('dataflow')->__('Invalid store specified, Invalid store id "%s".', $id);
91
+ Mage::throwException($message);
92
+ }
93
+ }
94
+ return $this->_store->getId();
95
+
96
+ /**
97
+ * In single store mode all data should be saved as default
98
+ */
99
+ }
100
+
101
+ /**
102
+ * @return $this
103
+ * @throws Exception
104
+ * @throws Varien_Convert_Exception
105
+ */
106
+ public function load()
107
+ {
108
+ $websiteId = $this->getWebsiteId($this->getStoreId());
109
+ $attrFilterArray = array();
110
+
111
+ /*
112
+ * Fixing date filter from and to
113
+ */
114
+ if ($var = $this->getVar('filter/created_at/from')) {
115
+ $this->setVar('filter/created_at/from', $var . ' 00:00:00');
116
+ }
117
+
118
+ if ($var = $this->getVar('filter/created_at/to')) {
119
+ $this->setVar('filter/created_at/to', $var . ' 23:59:59');
120
+ }
121
+
122
+ $filterQuery = $this->getFilter();
123
+ $orderVars = $this->_parseVars('order',5);
124
+ $_limit = $this->getVar('limit');
125
+
126
+ $collection = Mage::getModel('newsletter/subscriber')->getCollection()->addFieldToSelect('subscriber_id');
127
+
128
+
129
+ if (is_array($filterQuery)) {
130
+ foreach ($filterQuery as $k => $val) {
131
+ $collection->addFieldToFilter($k,$val);
132
+ }
133
+ }
134
+
135
+ $this->_store = Mage::app()->getStore();
136
+ if (!empty($store = $this->getVar('store'))) {
137
+ $collection->addFieldToFilter('store_id',$store);
138
+ }
139
+
140
+ if(isset($orderVars['by']) && !empty($orderVars['by'])){
141
+ $this->_orderBy = $orderVars['by'];
142
+ }
143
+ if(isset($orderVars['direction']) && !empty($orderVars['direction'])){
144
+ $this->_orderDir = $orderVars['direction'];
145
+ }
146
+ $collection->getSelect()->order($this->_orderBy.' '.$this->_orderDir);
147
+
148
+ if($_limit) {
149
+ $collection->getSelect()->limit($_limit);
150
+ //$collection->setPageSize(2);
151
+ //$collection->clear()->setPageSize(2)->setCurPage(1);
152
+ //$collection->setPageSize(2);
153
+ }
154
+
155
+ //echo $collection->getSelect(); die;
156
+ //$entityIds = $collection->getAllIds(2,2);
157
+ $entityDatas = $collection->getData();
158
+ $entityIds = $this->getOnlyIds($entityDatas);
159
+
160
+ /* echo '<pre>';
161
+ print_r($entityIds);
162
+ die; */
163
+
164
+ try {
165
+ $message = Mage::helper('dataflow')->__("Loaded %d records", count($entityIds));
166
+ $this->addException($message);
167
+ }
168
+ catch (Varien_Convert_Exception $e) {
169
+ throw $e;
170
+ }
171
+ catch (Exception $e) {
172
+ $message = Mage::helper('dataflow')->__('Problem loading the collection, aborting. Error: %s', $e->getMessage());
173
+ $this->addException($message, Varien_Convert_Exception::FATAL);
174
+ }
175
+
176
+ $this->setData($entityIds);
177
+ return $this;
178
+ }
179
+
180
+ public function getFilter()
181
+ {
182
+ $filters = array();
183
+ $filterVars = $this->_parseVars('filter');
184
+ //$now = Mage::getModel('core/date')->timestamp(time());
185
+ //$dateStart = date('m/d/Y' . ' 00:00:00', $now);
186
+ //$dateEnd = date('m/d/Y' . ' 23:59:59', $now);
187
+
188
+ $dateStart = date('Y-m-d H:i:s', strtotime('-1 year'));
189
+ $dateEnd = date('Y-m-d H:i:s', strtotime(now()));
190
+
191
+
192
+ if (is_array($filterVars)) {
193
+ foreach ($filterVars as $filterVarK => $filterVarV) {
194
+
195
+ if($filterVarK == "created_at/from"){
196
+ //$filters['change_status_at']['gteq'] = $filterVarV;
197
+ $filters['change_status_at']['from'] = $filterVarV;
198
+ }
199
+ if($filterVarK == "created_at/to"){
200
+ //$filters['change_status_at']['lteq'] = $filterVarV;
201
+ $filters['change_status_at']['to'] = $filterVarV;
202
+ }
203
+ if($filterVarK == "customer_id/from"){
204
+ $filters['customer_id']['from'] = $filterVarV;
205
+ }
206
+ if($filterVarK == "customer_id/to"){
207
+ $filters['customer_id']['to'] = $filterVarV;
208
+ }
209
+ if($filterVarK == "subscriber_id/from"){
210
+ $filters['subscriber_id']['from'] = $filterVarV;
211
+ }
212
+ if($filterVarK == "subscriber_id/to"){
213
+ $filters['subscriber_id']['to'] = $filterVarV;
214
+ }
215
+
216
+ if($filterVarK == "subscriber_status"){
217
+ $filters['subscriber_status']['eq'] = $filterVarV;
218
+ }
219
+ if($filterVarK == "subscriber_email"){
220
+ $filters['subscriber_email']['eq'] = $filterVarV;
221
+ }
222
+ }
223
+ }
224
+ return $filters;
225
+ }
226
+
227
+ protected function _parseVars($type = 'filter', $typeChars =6)
228
+ {
229
+ $varFilters = $this->getVars();
230
+ $filters = array();
231
+ foreach ($varFilters as $key => $val) {
232
+ if (substr($key,0,$typeChars) === $type) {
233
+ $keys = explode('/', $key, 2);
234
+ $filters[$keys[1]] = $val;
235
+ }
236
+ }
237
+
238
+ $filters = array_filter($filters);
239
+
240
+ return $filters;
241
+ }
242
+
243
+ /**
244
+ * @return $this
245
+ */
246
+ public function save()
247
+ {
248
+ return $this;
249
+ }
250
+
251
+
252
+ public function parse()
253
+ {
254
+ $batchModel = Mage::getSingleton('dataflow/batch');
255
+
256
+ $batchImportModel = $batchModel->getBatchImportModel();
257
+ $importIds = $batchImportModel->getIdCollection();
258
+
259
+ foreach ($importIds as $importId) {
260
+ //print '<pre>'.memory_get_usage().'</pre>';
261
+ $batchImportModel->load($importId);
262
+ $importData = $batchImportModel->getBatchData();
263
+ $this->saveRow($importData);
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Save newsletter subscriber (import)
269
+ *
270
+ * @param array $importData
271
+ * @throws Mage_Core_Exception
272
+ * @return bool
273
+ */
274
+ public function saveRow(array $importData)
275
+ {
276
+ //$subscriber = $this->getSubscriberModel()->reset();
277
+ $subscriber = $this->getSubscriberModel();
278
+ $dd = $this->getBatchParams();
279
+ Mage::log($dd, null,'Dotsquares_Exportprofiles.log');
280
+
281
+ $store = $this->getStoreById($this->getBatchParams('store'));
282
+
283
+ if (empty($importData['subscriber_email'])) {
284
+ $message = Mage::helper('newsletter')->__('Skipping import row, required field "%s" is not defined.', 'subscriber_email');
285
+ Mage::throwException($message);
286
+ Mage::log(sprintf('Skip import row, required field "subscriber_email" not defined', $message), null,'Dotsquares_Exportprofiles.log');
287
+ } else {
288
+
289
+ $subscriberUser = $subscriber->loadByEmail($importData['subscriber_email']);
290
+ if ($subscriberUser->getId()) {
291
+ // put your logic here...
292
+ if ($subscriberUser->getSubscriberStatus() == $importData['subscriber_status']) {
293
+ $message = Mage::helper('newsletter')->__('Skipping import row, "%s" already subscribed.', $importData['subscriber_email']);
294
+ Mage::throwException($message);
295
+ Mage::log(sprintf('Skip import row, subscriber_email already subscribed', $message), null,'Dotsquares_Exportprofiles.log');
296
+ }
297
+ } else {
298
+ /* Import */
299
+
300
+ /* create new subscriber without send an confirmation email */
301
+ $subscriber->setImportMode(true)->subscribe($importData['subscriber_email']);
302
+
303
+ /* get just generated subscriber */
304
+ $subscriber = $subscriber->loadByEmail($importData['subscriber_email']);
305
+
306
+ /* get Newsletter Subscriber whose status is equal to value */
307
+
308
+ $status = strtolower($importData['subscriber_status']);
309
+
310
+ if ($status == "subscribed"){
311
+ // Subscribed
312
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
313
+ }else if($status == "not activated" || $status == "notactivated"){
314
+ // Not Activated
315
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
316
+ }else if($status == "unsubscribed"){
317
+ // Unsubscribed
318
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
319
+ }else if($status == "unconfirmed"){
320
+ // Unconfirmed
321
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED);
322
+ }
323
+
324
+ $subscriber->setStoreId($store);
325
+ $subscriber->save();
326
+ }
327
+ }
328
+
329
+ return true;
330
+
331
+ }
332
+
333
+ /**
334
+ * Retrieve product model cache
335
+ *
336
+ * @return Mage_Catalog_Model_Product
337
+ */
338
+ public function getSubscriberModel()
339
+ {
340
+ if (is_null($this->_subscriberModel)) {
341
+ $subscriberModel = Mage::getModel('newsletter/subscriber');
342
+ $this->_subscriberModel = Mage::objects()->save($subscriberModel);
343
+ }
344
+ return Mage::objects()->load($this->_subscriberModel);
345
+ }
346
+
347
+ /* public function reset() {
348
+ return new self();
349
+ } */
350
+ public function getOnlyIds($entityDatas){
351
+ $ids = array();
352
+ foreach ($entityDatas as $entityDatasItem) {
353
+ $ids[] = $entityDatasItem['subscriber_id'];
354
+ }
355
+ return $ids;
356
+ }
357
+
358
+ }
app/code/community/Dotsquares/Exportprofiles/Model/Convert/Parser/Subscribers.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotsquares_Exportprofiles_Model_Convert_Parser_Subscribers extends Mage_Dataflow_Model_Convert_Parser_Abstract
3
+ {
4
+
5
+ /**
6
+ * @var Mage_Core_Model_Store
7
+ */
8
+ protected $_store;
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ protected $_storeId;
14
+
15
+ /**
16
+ * @var array
17
+ */
18
+ protected $_columns = array(
19
+ 'subscriber_id',
20
+ 'customer_id',
21
+ 'firstname',
22
+ 'lastname',
23
+ 'subscriber_email',
24
+ 'subscriber_status',
25
+ 'has_account',
26
+ 'subscription_date'
27
+ );
28
+
29
+ protected $_subscriberStatus = array(
30
+ '1' => 'Subscribed',
31
+ '2' => 'Not Activated',
32
+ '3' => 'Unsubscribed',
33
+ '4' => 'Unconfirmed'
34
+ );
35
+
36
+
37
+ /**
38
+ * @param array $row
39
+ */
40
+ protected function _addDataRow($row)
41
+ {
42
+ $this->getBatchExportModel()->setId(null)->setBatchId($this->getBatchModel()->getId())->setBatchData($row)->setStatus(1)->save();
43
+ }
44
+
45
+ /**
46
+ *
47
+ */
48
+ protected function _prepareColumnNames()
49
+ {
50
+ $names = array();
51
+ foreach ($this->_columns as $name) {
52
+ $names[$name] = $name;
53
+ }
54
+ $this->_addDataRow($names);
55
+ }
56
+
57
+ /**
58
+ * @return Mage_Core_Model_Store
59
+ * @throws Exception
60
+ */
61
+ public function getStore()
62
+ {
63
+ if (is_null($this->_store)) {
64
+ try {
65
+ $store = Mage::app()->getStore($this->getVar('store'));
66
+ }
67
+ catch (Exception $e) {
68
+ $this->addException(Mage::helper('dataflow')->__('Invalid store specified'), Varien_Convert_Exception::FATAL);
69
+ throw $e;
70
+ }
71
+ $this->_store = $store;
72
+ }
73
+ return $this->_store;
74
+ }
75
+
76
+ /**
77
+ * @return int
78
+ */
79
+ public function getStoreId()
80
+ {
81
+ if (is_null($this->_storeId)) {
82
+ $this->_storeId = $this->getStore()->getId();
83
+ }
84
+ return $this->_storeId;
85
+ }
86
+
87
+ /**
88
+ * @return $this
89
+ */
90
+ public function parse()
91
+ {
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * Unparse (prepare data) loaded products
97
+ *
98
+ * @return Mage_Catalog_Model_Convert_Parser_Product
99
+ */
100
+ public function unparse()
101
+ {
102
+ $entityIds = $this->getData();
103
+ $columnNames = true;
104
+ $export_customer_name = $this->getVar('export_customer_name');
105
+ $export_customer_name = strtolower($export_customer_name);
106
+
107
+ foreach ($entityIds as $i => $entityId) {
108
+ $model = Mage::getModel('newsletter/subscriber');
109
+
110
+ $model->load($entityId);
111
+ $data = $model->getData();
112
+ //$row = $data;
113
+ $row = array();
114
+
115
+ //print_r($customerExist->getData());
116
+
117
+ /* if ($columnNames) {
118
+ $columnNames = false;
119
+ $this->_prepareColumnNames();
120
+ } */
121
+
122
+ foreach ($data as $key => $val) {
123
+ if (in_array($key, $this->_columns)) {
124
+ $row[$key] = $val;
125
+ }
126
+ }
127
+ if($export_customer_name == 'true' && !empty($data['subscriber_email'])) {
128
+
129
+ $customerExist = Mage::getModel('customer/customer')
130
+ ->getCollection()
131
+ ->addAttributeToSelect('firstname')
132
+ ->addAttributeToSelect('lastname')
133
+ ->addAttributeToFilter('email', $data['subscriber_email'] )
134
+ ->getFirstItem();
135
+ if($customerExist) {
136
+ $row['firstname'] = $customerExist->getFirstname();
137
+ $row['lastname'] = $customerExist->getLastname();
138
+ }
139
+
140
+ }
141
+ $row['has_account'] = ($data['customer_id'])?'Yes':'No';
142
+ $row['subscriber_status'] = $this->_subscriberStatus[$data['subscriber_status']];
143
+ if(!empty($data['change_status_at'])) {
144
+ $row['subscription_date'] = date("d/m/Y", strtotime($data['change_status_at']));
145
+ } else {
146
+ $row['subscription_date'] = '';
147
+ }
148
+
149
+
150
+ $this->_addDataRow($row);
151
+ }
152
+ return $this;
153
+ }
154
+ }
app/code/community/Dotsquares/Exportprofiles/Model/Observer.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotsquares_Exportprofiles_Model_Observer
3
+ {
4
+ /**
5
+ * Observer function to update the subscription action date
6
+ * @param Varien_Event_Observer $observer
7
+ */
8
+ public function setUpdateDate(Varien_Event_Observer $observer)
9
+ {
10
+ $subscriber = $observer->getSubscriber();
11
+ $subscriber['change_status_at'] = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
12
+ //$subscriber['change_status_at'] = date("Y-m-d H:i:s", time());
13
+ //date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
14
+
15
+ }
16
+ }
app/code/community/Dotsquares/Exportprofiles/data/DataFlowProfiles.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ =============== Dotsquares - Export Newsletter Subscribers =================
2
+ <action type="dotsquares_exportprofiles/convert_adapter_subscribers" method="load">
3
+ <var name="store"><![CDATA[0]]></var>
4
+ <var name="filter/subscriber_status"><![CDATA[1]]></var>
5
+ <var name="filter/subscriber_email"><![CDATA[developer7@yopmail.com]]></var>
6
+ <var name="filter/created_at/from"><![CDATA[09/22/09]]></var>
7
+ <var name="filter/created_at/to"><![CDATA[09/24/09]]></var>
8
+ <var name="filter/customer_id/from"><![CDATA[5]]></var>
9
+ <var name="filter/customer_id/to"><![CDATA[12]]></var>
10
+ <var name="filter/subscriber_id/from"><![CDATA[5]]></var>
11
+ <var name="filter/subscriber_id/to"><![CDATA[12]]></var>
12
+ <var name="order/by"><![CDATA[subscriber_id]]></var>
13
+ <var name="order/direction"><![CDATA[DESC]]></var>
14
+ <var name="limit"><![CDATA[5]]></var>
15
+ </action>
16
+
17
+ <action type="dotsquares_exportprofiles/convert_parser_subscribers" method="unparse">
18
+ <var name="store"><![CDATA[0]]></var>
19
+ <var name="export_customer_name"><![CDATA[true]]></var>
20
+ </action>
21
+
22
+ <action type="dataflow/convert_mapper_column" method="map">
23
+ <var name="map">
24
+ <map name="subscriber_id"><![CDATA[CSV field name]]></map>
25
+ </var>
26
+ <var name="_only_specified">true</var>
27
+ </action>
28
+
29
+ <action type="dataflow/convert_parser_csv" method="unparse">
30
+ <var name="delimiter"><![CDATA[,]]></var>
31
+ <var name="enclose"><![CDATA["]]></var>
32
+ <var name="fieldnames">true</var>
33
+ </action>
34
+
35
+ <action type="dataflow/convert_adapter_io" method="save">
36
+ <var name="type">file</var>
37
+ <var name="path">var/export</var>
38
+ <var name="filename"><![CDATA[export_newsletter_subscribers.csv]]></var>
39
+ </action>
40
+
41
+ =============== Dotsquares - Import Newsletter Subscribers =================
42
+
43
+ <action type="dataflow/convert_adapter_io" method="load">
44
+ <var name="type">file</var>
45
+ <var name="path">var/import</var>
46
+ <var name="filename"><![CDATA[import_newsletter_subscribers.csv]]></var>
47
+ <var name="format"><![CDATA[csv]]></var>
48
+ </action>
49
+
50
+ <action type="dataflow/convert_parser_csv" method="parse">
51
+ <var name="delimiter"><![CDATA[,]]></var>
52
+ <var name="enclose"><![CDATA["]]></var>
53
+ <var name="fieldnames">false</var>
54
+ <var name="store"><![CDATA[0]]></var>
55
+ <var name="adapter">dotsquares_exportprofiles/convert_adapter_subscribers</var>
56
+ <var name="method">saveRow</var>
57
+ </action>
app/code/community/Dotsquares/Exportprofiles/data/exportprofiles_setup/data-install-0.1.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $dataflowData = array(
5
+ array(
6
+ 'name' => 'Dotsquares - Export Newsletter Subscribers',
7
+ 'actions_xml' => '<action type="dotsquares_exportprofiles/convert_adapter_subscribers" method="load">'."\r\n".'<var name="store"><![CDATA[0]]></var>'."\r\n".'</action>'."\r\n".''."\r\n".'<action type="dotsquares_exportprofiles/convert_parser_subscribers" method="unparse">'."\r\n".'<var name="store"><![CDATA[0]]></var>'."\r\n".'</action>'."\r\n".''."\r\n".'<action type="dataflow/convert_mapper_column" method="map">'."\r\n".'</action>'."\r\n".''."\r\n".'<action type="dataflow/convert_parser_csv" method="unparse">'."\r\n".'<var name="delimiter"><![CDATA[,]]></var>'."\r\n".'<var name="enclose"><![CDATA["]]></var>'."\r\n".'<var name="fieldnames">true</var>'."\r\n".'</action>'."\r\n".''."\r\n".'<action type="dataflow/convert_adapter_io" method="save">'."\r\n".'<var name="type">file</var>'."\r\n".'<var name="path">var/export</var>'."\r\n".'<var name="filename"><![CDATA[export_newsletter_subscribers.csv]]></var>'."\r\n".'</action>',
8
+ 'store_id' => 0
9
+ ),
10
+ array(
11
+ 'name' => 'Dotsquares - Import Newsletter Subscribers',
12
+ 'actions_xml' => '<action type="dataflow/convert_adapter_io" method="load">'."\r\n".'<var name="type">file</var>'."\r\n".'<var name="path">var/import</var>'."\r\n".'<var name="filename"><![CDATA[import_newsletter_subscribers.csv]]></var>'."\r\n".'<var name="format"><![CDATA[csv]]></var>'."\r\n".'</action>'."\r\n".'<action type="dataflow/convert_parser_csv" method="parse">'."\r\n".'<var name="delimiter"><![CDATA[,]]></var>'."\r\n".'<var name="enclose"><![CDATA["]]></var>'."\r\n".'<var name="fieldnames">false</var>'."\r\n".'<var name="store"><![CDATA[0]]></var>'."\r\n".'<var name="adapter">dotsquares_exportprofiles/convert_adapter_subscribers</var>'."\r\n".'<var name="method">saveRow</var>'."\r\n".'</action>',
13
+ 'store_id' => 0
14
+ ),
15
+ );
16
+
17
+ foreach ($dataflowData as $bind) {
18
+ Mage::getModel('dataflow/profile')->setData($bind)->save();
19
+ }
20
+
21
+ $installer->endSetup();
app/code/community/Dotsquares/Exportprofiles/etc/config.xml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Dotsquares_Pickupfromstore extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the MIT License
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/mit-license.php
12
+ *
13
+ * @category Dotsquares
14
+ * @package Dotsquares_Pickupfromstore
15
+ * @copyright Copyright (c) 2013
16
+ * @license http://opensource.org/licenses/mit-license.php MIT License
17
+ * @author Suman Singh <suman.singh@dotsquares.com>
18
+ */
19
+ -->
20
+ <config>
21
+ <modules>
22
+ <Dotsquares_Exportprofiles>
23
+ <version>0.1.0</version>
24
+ </Dotsquares_Exportprofiles>
25
+ </modules>
26
+ <global>
27
+ <models>
28
+ <dotsquares_exportprofiles>
29
+ <class>Dotsquares_Exportprofiles_Model</class>
30
+ </dotsquares_exportprofiles>
31
+ </models>
32
+ <events>
33
+ <newsletter_subscriber_save_before>
34
+ <observers>
35
+ <subscribefix_observer_subscriber>
36
+ <type>singleton</type>
37
+ <class>Dotsquares_Exportprofiles_Model_Observer</class>
38
+ <method>setUpdateDate</method>
39
+ </subscribefix_observer_subscriber>
40
+ </observers>
41
+ </newsletter_subscriber_save_before>
42
+ </events>
43
+ <resources>
44
+ <exportprofiles_setup>
45
+ <setup>
46
+ <module>Dotsquares_Exportprofiles</module>
47
+ </setup>
48
+ </exportprofiles_setup>
49
+ </resources>
50
+ </global>
51
+ </config>
app/etc/modules/Dotsquares_Exportprofiles.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * This file is part of ImportExportAttributes extension.
5
+ *
6
+ * ImportExportAttributes is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Lesser General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * ImportExportAttributes is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public License
17
+ * along with ImportExportAttributes. If not, see <http://www.gnu.org/licenses/>.
18
+ *
19
+ * @category IteraResearch
20
+ * @package IteraResearch_ImportExportAttributes
21
+ * @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
22
+ * @license http://www.gnu.org/licenses Lesser General Public License
23
+ */
24
+ -->
25
+ <config>
26
+ <modules>
27
+ <Dotsquares_Exportprofiles>
28
+ <active>true</active>
29
+ <codePool>community</codePool>
30
+ </Dotsquares_Exportprofiles>
31
+ </modules>
32
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Dotsquares_Exportprofiles</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module helps you out exporting/importing newsletter subscribers using the Dataflow Advanced Profiles.</summary>
10
+ <description>This module helps you out exporting/importing newsletter subscribers using the Dataflow Advanced Profiles.</description>
11
+ <notes>First Release</notes>
12
+ <authors><author><name>Dotsquares</name><user>dotsquaresltd</user><email>support.extensions@dotsquares.com</email></author></authors>
13
+ <date>2017-03-03</date>
14
+ <time>12:27:08</time>
15
+ <contents><target name="magecommunity"><dir name="Dotsquares"><dir name="Exportprofiles"><dir name="data"><file name="DataFlowProfiles.txt" hash="7d37d22eca5cd2f555211a4b0f0d93a7"/><dir name="exportprofiles_setup"><file name="data-install-0.1.0.php" hash="41a060091fbf23d79915fff6815075ac"/></dir></dir><dir name="etc"><file name="config.xml" hash="246193ee6817c722946ea6ec135c0392"/></dir><dir name="Model"><dir name="Convert"><dir name="Adapter"><file name="Subscribers.php" hash="2bf9976e4c469cfad9ce62bc40abeabf"/></dir><dir name="Parser"><file name="Subscribers.php" hash="10b34bc68fa19d10dc6e946410ef88bd"/></dir></dir><file name="Observer.php" hash="93cb47eff4e0ab5865aa039e402cf7d5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dotsquares_Exportprofiles.xml" hash="170d334799c5773890d870413a03db38"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
18
+ </package>