EmailDirect_Integration - Version 2.0.15

Version Notes

Grouped product fixes.

Permissions updated to allow access to admin pages for specific roles.

Download this release

Release Info

Developer Magento Core Team
Extension EmailDirect_Integration
Version 2.0.15
Comparing to
See all releases


Code changes from version 2.0.14 to 2.0.15

app/code/community/EmailDirect/Integration/Helper/Data.php CHANGED
@@ -112,6 +112,10 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
112
 
113
  protected function getProduct($item)
114
  {
 
 
 
 
115
  $product_id = $item->getProductId();
116
 
117
  if (!$product_id)
112
 
113
  protected function getProduct($item)
114
  {
115
+ if (get_class($item) == "Varien_Object") {
116
+ return $item->getProduct();
117
+ }
118
+
119
  $product_id = $item->getProductId();
120
 
121
  if (!$product_id)
app/code/community/EmailDirect/Integration/Helper/Order.php CHANGED
@@ -2,699 +2,700 @@
2
 
3
  class EmailDirect_Integration_Helper_Order extends EmailDirect_Integration_Helper_Data
4
  {
5
- protected function getTrackingData($order)
6
- {
7
- $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
8
- ->setOrderFilter($order)
9
- ->load();
10
- foreach($shipmentCollection as $_shipment)
11
- {
12
- foreach($_shipment->getAllTracks() as $tracknum)
13
- {
14
- return $tracknum->getData();
15
- }
16
- }
17
 
18
- return null;
19
- }
20
 
21
- public function getTrackingMergeVars($track, $order)
22
- {
23
- $this->_logger->log('getTrackingMergeVars Start');
24
 
25
- $merge_vars = array();
26
- $maps = unserialize($this->config('shipping_fields', $order->getStoreId()));
27
 
28
- if (!$maps)
29
- return null;
30
 
31
- $this->_logger->log($maps, "Maps");
32
 
33
- $this->_logger->log($track->getData(), "Tracking Data");
34
 
35
- $this->processMap($merge_vars, $maps, $track);
36
 
37
- return $merge_vars;
38
- }
39
 
40
- protected function getShippingData($order)
41
- {
42
- $data = array();
43
 
44
- $data['shipping_code'] = $order->getData('shipping_method');
45
- $data['shipping_description'] = $order->getData('shipping_description');
46
 
47
- $track_data = $this->getTrackingData($order);
48
 
49
- if ($track_data != null)
50
- {
51
- $data['carrier_code'] = $track_data['carrier_code'];
52
- $data['title'] = $track_data['title'];
53
- $data['number'] = $track_data['number'];
54
- }
55
 
56
- $shipping_data = new Varien_Object();
57
 
58
- $shipping_data->setData($data);
59
 
60
- return $shipping_data;
61
- }
 
 
 
 
 
62
 
63
- protected function getOrderMergeVars(&$merge_vars, $order)
64
- {
65
- $this->_logger->logAndDebug('getOrderMergeVars (Tracking Data)');
66
- $maps = unserialize( $this->config('shipping_fields', $order->getStoreId()) );
67
-
68
- if ($maps)
69
- {
70
- $this->_logger->log($maps, "Maps");
71
- $shipping_data = $this->getShippingData($order);
72
-
73
- $this->_logger->log($shipping_data,'Shipping Data');
74
-
75
- $this->processMap($merge_vars, $maps, $shipping_data);
76
- }
77
- else
78
- $this->debug('No Mappings Found');
79
-
80
- return $merge_vars;
81
- }
82
-
83
- public function getOrderCustomer($order)
84
- {
85
- $customer = null;
86
-
87
- if ($order->getData('customer_is_guest'))
88
- {
89
- $this->_logger->log("Guest Customer");
90
-
91
- $customer = new Varien_Object;
92
-
93
- $customer->setData('email',$order->getCustomerEmail());
94
- $customer->setData('firstname',$order->getData('customer_firstname'));
95
- $customer->setData('lastname',$order->getData('customer_lastname'));
96
- $customer->setData('store_id',$order->getStoreId());
97
-
98
- $customer->setBillingAddress($order->getBillingAddress());
99
- }
100
- else
101
- {
102
- $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
103
- $address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
104
- $customer->setBillingAddress($address);
105
- }
106
-
107
- return $customer;
108
- }
109
-
110
- public function processOrderItems($order, &$merge_vars)
111
- {
112
- $this->debugHeader("processOrderItems Start",1);
113
-
114
- $merge_vars = $this->getOrderMergeVars($merge_vars,$order);
115
-
116
- $this->_logger->logAndDebug("Check Save Lastest");
117
- if ($this->config('save_latest_order'))
118
- {
119
- $this->_logger->logAndDebug("Adding Latest Order Information");
120
- $merge_vars['LastOrderNumber'] = $order->getIncrementId();
121
- $merge_vars['LastPurchaseDate'] = $order->getData('created_at');
122
- $merge_vars['LastPurchaseTotal'] = Mage::helper('core')->currency($order->getData('total_paid'), true, false);
123
-
124
- $merge_vars = $this->getMergeOrderItems($order, $merge_vars);
125
- $merge_vars = $this->getRelatedOrderItems($order, $merge_vars);
126
- $this->_logger->logAndDebug("Finish Save Latest");
127
- }
128
- else
129
- $this->_logger->logAndDebug("Not setup to send latest order info");
130
-
131
- return $merge_vars;
132
- }
133
-
134
- protected function getParentOptions($parent_product,$product_id)
135
- {
136
- $parent_options = $this->getConfigurableOptions($parent_product,$product_id);
137
-
138
- if (count($parent_options) == 0)
139
- return "";
140
-
141
- $options = "";
142
-
143
- foreach ($parent_options as $key => $value)
144
- {
145
- if ($options == "")
146
- $options .= "#";
147
- else
148
- $options .= "&";
149
-
150
- $options .= "{$key}={$value}";
151
- }
152
-
153
- return $options;
154
- }
155
-
156
- protected function getGroupedPrice($grouped_product)
157
- {
158
- $min = 0;
159
- $products = $grouped_product->getTypeInstance()->getAssociatedProducts();
160
- foreach ($products as $product)
161
- {
162
- if ($min == 0)
163
- $min = $product->getPrice();
164
-
165
- $min = min($min, $product->getPrice());
166
- }
167
-
168
- return $min;
169
- }
170
-
171
- protected function getProductImage($product, $parent_product = null)
172
- {
173
- try
174
- {
175
- $image = "";
176
- if ($product->getImage() == 'no_selection' || $product->getImage() == "")
177
- {
178
- if ($parent_product != null && $parent_product->getImage() != "no_selection" && $parent_product->getImage() != "")
179
- $image = Mage::getModel('catalog/product_media_config')->getMediaUrl($parent_product->getImage());
180
- }
181
- else
182
- $image = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
183
- }
184
- catch (Exception $e)
185
- {
186
- Mage::logException($e);
187
- $this->_logger->logException($e);
188
- }
189
-
190
- return $image;
191
- }
192
-
193
- private function addMergeItem($item_data, $pos, $merge_vars, $prefix = "")
194
- {
195
- $name = "";
196
- $parent_name = "";
197
- $sku = "";
198
- $url = "";
199
- $image = "";
200
- $cost = "";
201
- $description = "";
202
- $parent_item = null;
203
- $parent_product = null;
204
-
205
- $this->debug("--------------------------");
206
- $this->debug("ADDING MERGE ITEM");
207
-
208
- if ($item_data != null)
209
- {
210
- $product_id = 0;
211
-
212
- if (is_array($item_data))
213
- {
214
- $item = $item_data['item'];
215
-
216
- if (isset($item_data['parent']))
217
- {
218
- $parent_item = $item_data['parent'];
219
- $this->debug("Parent Item:");
220
- $this->debug($parent_item);
221
- }
222
- }
223
- else
224
- $item = $item_data;
225
-
226
- $this->debug("Item:");
227
- $this->debug($item);
228
-
229
- if (is_string($item))
230
- {
231
- $product_id = $item;
232
-
233
- $product = Mage::getModel('catalog/product')->load($product_id);
234
-
235
- if ($product == null || !$product->getId())
236
- return $merge_vars;
237
- }
238
- else
239
- {
240
- $product = $this->getProduct($item);
241
- if ($product == null)
242
- return $merge_vars; // Can't get product so abort
243
- }
244
-
245
- $this->debug("Product:");
246
- $this->debug($product);
247
-
248
- if ($parent_item != null)
249
- {
250
- $parent_product = $this->getProduct($parent_item);
251
- if ($parent_product == null)
252
- return $merge_vars; // Can't get product so abort
253
-
254
- $this->debug("Parent Product:");
255
- $this->debug($parent_product);
256
-
257
- $parent_name = $parent_product->getName();
258
- $url = $parent_product->getProductUrl();
259
-
260
- if ($parent_product->getTypeId() == 'configurable')
261
- $url .= $this->getParentOptions($parent_product,$product_id);
262
- }
263
- else
264
- $url = $product->getProductUrl();
265
-
266
- $name = $product->getName();
267
- $sku = $product->getSku();
268
-
269
- $image = $this->getProductImage($product, $parent_product);
270
-
271
- if (is_string($item))
272
- {
273
- $this->debug('String Item');
274
- if ($product->getTypeId() == 'grouped')
275
- $cost = $this->getGroupedPrice($product);
276
- else
277
- $cost = $product->getPrice();
278
- }
279
- else
280
- {
281
- if ($parent_item != null)
282
- $cost = $parent_item->getPrice();
283
- else
284
- $cost = $item->getPrice();
285
- }
286
-
287
- $cost = Mage::helper('core')->currency($cost,true,false);
288
- $description = $product->getShortDescription();
289
- }
290
-
291
- $merge_vars["{$prefix}ProductName{$pos}"] = $name;
292
- if ($prefix != 'Related')
293
- $merge_vars["{$prefix}ParentName{$pos}"] = $parent_name;
294
-
295
- $merge_vars["{$prefix}SKU{$pos}"] = $sku;
296
- $merge_vars["{$prefix}URL{$pos}"] = $url;
297
- $merge_vars["{$prefix}Image{$pos}"] = $image;
298
-
299
- $merge_vars["{$prefix}Cost{$pos}"] = $cost;
300
- $merge_vars["{$prefix}Description{$pos}"] = $description;
301
-
302
- return $merge_vars;
303
- }
304
-
305
- protected function getRelatedCollection($id_list, $max_count, $grouped_id_list = null)
306
- {
307
- $this->debug("getRelatedCollection Start");
308
- $collection = Mage::getModel('catalog/product_link')
309
- ->useRelatedLinks()
310
  ->getCollection()
311
  ->addFieldToFilter('product_id', array('in' => $id_list))
312
  ;
313
 
314
- $this->debug("Collection SQL");
315
- $this->debug($collection->getSelect()->__toString());
316
-
317
- // Filter out grouped products from the related list
318
- if ($grouped_id_list != null && count($grouped_id_list) > 0)
319
- {
320
- $this->debug("Merging Grouped ID's to filter");
321
- $id_list = array_merge($id_list,$grouped_id_list);
322
-
323
- }
324
-
325
- $this->debug("ID Filters");
326
- $this->debug($id_list);
327
-
328
- $product_ids = array();
329
-
330
- // If any of the related products are already in the order we filter them out
331
- foreach ($collection as $rp)
332
- {
333
- $this->debug("");
334
- $this->debug("-----------------------------");
335
- $this->debug("Related Product");
336
- $this->debug($rp->getData());
337
- $lp_id = $rp['linked_product_id'];
338
- if (!in_array($lp_id,$id_list))
339
- {
340
- $this->debug("Adding Related Product");
341
- $product_ids[] = $lp_id;
342
- }
343
- else
344
- $this->debug("Related product already in order");
345
- }
346
-
347
- $this->debug("Product IDs");
348
- $this->debug($product_ids);
349
-
350
- $related = Mage::getResourceModel('catalog/product_collection')
351
- ->addFieldToFilter('entity_id', array('in' => $product_ids))
352
- ->setPageSize($max_count);
353
-
354
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($related);
355
-
356
- $this->debug("Related SQL");
357
- $this->debug($related->getSelect()->__toString());
358
-
359
- $related_list = array();
360
-
361
- if (count($related) > 0)
362
- {
363
- foreach ($related as $rp)
364
- {
365
- $related_list[] = $rp;
366
- }
367
- }
368
-
369
- return $related_list;
370
- }
371
-
372
- protected function getRelatedProducts($quote)
373
- {
374
- $id_list = array();
375
- $grouped_id_list = array();
376
- $filter_id_list = array();
377
-
378
- foreach ($quote->getAllItems() as $item)
379
  {
380
- $this->debug("");
381
- $this->debug("----------------------------------------------------------");
382
- $type = $item->getProductType();
383
- $this->debug("Item ID: {$item->getId()}");
384
- $this->debug("Item Sku: {$item->getSku()}");
385
- $this->debug("Item Type: {$type}");
386
-
387
- // if it is a grouped product get the parent ID and add it to the list (if not already added)
388
- if ($type == 'grouped')
389
- {
390
- $grouped_product_id = $this->getGroupedProductId($item);
391
-
392
- $this->debug("Grouped Product ID: {$grouped_product_id}");
393
-
394
- if (!in_array($grouped_product_id, $grouped_id_list))
395
- $grouped_id_list[] = $grouped_product_id;
396
- }
397
-
398
- if ($product = $this->getProduct($item))
399
- {
400
- $product_id = $product->getId();
401
- if (!in_array($product_id, $id_list))
402
- $id_list[] = $product_id;
403
- }
404
  }
405
 
406
- $this->debug("ID List");
407
- $this->debug($id_list);
408
- $this->debug("Grouped ID List");
409
- $this->debug($grouped_id_list);
410
 
411
- $max_count = $this->config('related_fields');
412
-
413
- $this->debug("Max Related: {$max_count}");
414
-
415
- $this->debug("");
416
- $this->debug("--------------------------------------------------------------------------");
417
- $this->debug("Get Related Collection (Non Grouped)");
418
- $this->debug("");
419
-
420
- $related = $this->getRelatedCollection($id_list, $max_count, $grouped_id_list);
421
-
422
- $this->debug("");
423
- $this->debug("# of Related Products Found: " . count($related));
424
-
425
- if (count($related) < $max_count && count($grouped_id_list) > 0)
426
- {
427
- $this->debug("");
428
- $this->debug("--------------------------------------------------------------------------");
429
- $this->debug("Get Related Collection (Grouped)");
430
- $this->debug("");
431
-
432
- // get grouped related
433
- $grouped_related = $this->getRelatedCollection($grouped_id_list, $max_count - count($related), $id_list);
434
-
435
- // Merge the collections
436
- if (count($grouped_related) > 0)
437
- return array_merge($related, $grouped_related);
438
- }
439
 
440
- return $related;
441
- }
442
 
443
- public function getRelatedOrderItems($quote, $merge_vars)
444
- {
445
- $prefix = "Related";
446
- $max_count = $this->config('related_fields');
447
 
448
- $this->debug('');
449
- $this->debug('Getting Related Products');
450
 
451
- $related_products = $this->getRelatedProducts($quote);
452
 
453
- $count = 0;
454
 
455
- foreach ($related_products as $rp)
456
- {
457
- $count++;
458
 
459
- if ($count > $max_count)
460
- break;
461
-
462
- $merge_vars = $this->addMergeItem($rp->getId(), $count, $merge_vars, $prefix);
463
- }
464
-
465
- while ($count < $max_count)
466
- {
467
- $count++;
468
- $merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
469
- }
470
-
471
- return $merge_vars;
472
- }
473
-
474
- protected function getGroupedProductId($item)
475
- {
476
- $this->debug('Get Grouped Product Id');
477
- $options = $item->getProductOptions();
478
-
479
- $this->debug('Product Options');
480
- $this->debug($options);
481
-
482
- if (isset($options['super_product_config']))
483
- {
484
- $this->debug('Super config found');
485
- if (isset($options['super_product_config']['product_id']))
486
- {
487
- $this->debug('Product Id Found');
488
- $product_id = $options['super_product_config']['product_id'];
489
-
490
- return $product_id;
491
- }
492
- $this->debug('Product Id Not Found!');
493
- }
494
- else
495
- {
496
- $this->debug('Get Option By Code');
497
- $option = $item->getOptionByCode('product_type');
498
- if ($option)
499
- {
500
- $this->debug('Option Found');
501
- $this->debug($option);
502
- return $option->getProductId();
503
- }
504
- }
505
-
506
- $this->debug('Unable to get Grouped Product ID');
507
-
508
- return false;
509
- }
510
-
511
- protected function getGroupedProduct($item)
512
- {
513
- $this->debug('Get Grouped Product');
514
- $product_id = $this->getGroupedProductId($item);
515
-
516
- if ($product_id !== false)
517
- {
518
- $this->debug('Loading Product');
519
- $product = Mage::getModel('catalog/product')->load($product_id);
520
-
521
- if ($product->getId())
522
- {
523
- $this->debug('Grouped Product Found!');
524
- return $product;
525
- }
526
- }
527
-
528
- $this->debug('Unable to get Grouped Product');
529
-
530
- return false;
531
- }
532
-
533
- protected function isItemVisible($item)
534
- {
535
- $vis_flag = Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
536
-
537
- if ($item == null)
538
- return true;
539
-
540
- $product = $this->getProduct($item);
541
-
542
- if ($product == null)
543
- return true;
544
-
545
- if ($product->getVisibility() != $vis_flag)
546
- return true;
547
-
548
- return false;
549
- }
550
-
551
- protected function processParentItems($quote)
552
- {
553
- $this->debug("Processing Parent Items");
554
- $parent_items = array();
555
-
556
- foreach ($quote->getAllItems() as $item)
557
- {
558
- $this->debug("");
559
- $this->debug("----------------------------------------------------------");
560
- $type = $item->getProductType();
561
- //Zend_debug::dump($item->getData());
562
- $this->debug("Item ID: {$item->getId()}");
563
- $this->debug("Item Sku: {$item->getSku()}");
564
- $this->debug("Item Type: {$type}");
565
- if ($type == "configurable" || $type == "bundle")
566
- {
567
- $this->debug('*** Adding as Parent Item ***');
568
- $parent_items[$item->getId()] = $item;
569
- }
570
-
571
- if ($type == "grouped")
572
- {
573
- $grouped_product = $this->getGroupedProduct($item);
574
-
575
- if ($grouped_product)
576
- {
577
- $this->debug('*** Adding Grouped Product to Parent Items ***');
578
- $parent_item = new Varien_Object;
579
- $parent_item->setProduct($grouped_product);
580
- $parent_items[$item->getId()] = $parent_item;
581
- }
582
- }
583
- }
584
-
585
- $this->debug('Parent Items Found: ' . count($parent_items));
586
-
587
- if (count($parent_items) > 0)
588
- {
589
- $this->debug('Parent Items:');
590
-
591
- foreach($parent_items as $key => $item)
592
- {
593
- $this->debug('-------------------------');
594
- $this->debug("ID: {$key}");
595
- if ($item->getId())
596
- $this->debug("Parent ID: " . $item->getId());
597
- else
598
- {
599
- $parent_product = $this->getProduct($item);
600
- if ($parent_product)
601
- $this->debug("Parent ID: " . $parent_product->getId());
602
- else
603
- $this->debug("Parent ID: Failed to load product");
604
- }
605
- }
606
- }
607
-
608
- return $parent_items;
609
- }
610
-
611
- public function getMergeOrderItems($quote, $merge_vars, $prefix = "")
612
- {
613
- $max_count = $this->config('product_fields');
614
-
615
- $count = 0;
616
-
617
- $item_data = array();
618
-
619
- $parent_items = $this->processParentItems($quote);
620
-
621
- $this->debug('');
622
- $this->debug('Processing Order Items');
623
-
624
- foreach ($quote->getAllItems() as $item)
625
- {
626
- $type = $item->getProductType();
627
-
628
- $this->debug('');
629
- $this->debug("----------------------------------------------------------");
630
- $this->debug('Item Sku: ' . $item->getSku());
631
- $this->debug('Item Type: ' . $type);
632
-
633
- if ($type == "configurable" || $type == "bundle")
634
- {
635
- $this->debug('Skipping Configurable and Bundle Products (this is a parent product)');
636
- continue;
637
- }
638
-
639
- $item_id = $item->getId();
640
-
641
- if ($item->getProductType() == 'grouped')
642
- {
643
- $this->debug('Grouped Product');
644
-
645
- $parent_id = $item->getId();
646
- }
647
- else
648
- {
649
- $parent_id = $item->getParentItemId();
650
- }
651
-
652
- $this->debug("Parent Id: {$parent_id}");
653
-
654
- if ($parent_id != null && isset($parent_items[$parent_id]))
655
- {
656
- $this->debug('Item has a Parent');
657
- $parent_item = $parent_items[$parent_id];
658
-
659
- $this->debug('Checking Visibility of Item and Parent (only one needs to be visible)');
660
- if ($this->isItemVisible($item) || $this->isItemVisible($parent_item))
661
- {
662
- $this->debug('Adding Item to list');
663
- $item_data[$item_id] = array('item' => $item, 'parent' => $parent_item);
664
- }
665
- else
666
- $this->debug('Visibility check failed');
667
- }
668
- else
669
- {
670
- $this->debug('Checking Visibility of Item');
671
- if ($this->isItemVisible($item))
672
- {
673
- $this->debug('Adding Item to list');
674
- $item_data[$item_id] = array('item' => $item);
675
- }
676
- else
677
- $this->debug('Visibility check failed');
678
- }
679
- }
680
-
681
- foreach ($item_data as $item)
682
  {
683
- $count++;
684
 
685
- if ($count > $max_count)
686
- break;
687
 
688
  $merge_vars = $this->addMergeItem($item, $count, $merge_vars, $prefix);
689
  }
690
 
691
- // Blank out other items
692
- while ($count < $max_count)
693
- {
694
- $count++;
695
- $merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
696
- }
697
 
698
- return $merge_vars;
699
- }
700
  }
2
 
3
  class EmailDirect_Integration_Helper_Order extends EmailDirect_Integration_Helper_Data
4
  {
5
+ protected function getTrackingData($order)
6
+ {
7
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
8
+ ->setOrderFilter($order)
9
+ ->load();
10
+ foreach($shipmentCollection as $_shipment)
11
+ {
12
+ foreach($_shipment->getAllTracks() as $tracknum)
13
+ {
14
+ return $tracknum->getData();
15
+ }
16
+ }
17
 
18
+ return null;
19
+ }
20
 
21
+ public function getTrackingMergeVars($track, $order)
22
+ {
23
+ $this->_logger->log('getTrackingMergeVars Start');
24
 
25
+ $merge_vars = array();
26
+ $maps = unserialize($this->config('shipping_fields', $order->getStoreId()));
27
 
28
+ if (!$maps)
29
+ return null;
30
 
31
+ $this->_logger->log($maps, "Maps");
32
 
33
+ $this->_logger->log($track->getData(), "Tracking Data");
34
 
35
+ $this->processMap($merge_vars, $maps, $track);
36
 
37
+ return $merge_vars;
38
+ }
39
 
40
+ protected function getShippingData($order)
41
+ {
42
+ $data = array();
43
 
44
+ $data['shipping_code'] = $order->getData('shipping_method');
45
+ $data['shipping_description'] = $order->getData('shipping_description');
46
 
47
+ $track_data = $this->getTrackingData($order);
48
 
49
+ if ($track_data != null)
50
+ {
51
+ $data['carrier_code'] = $track_data['carrier_code'];
52
+ $data['title'] = $track_data['title'];
53
+ $data['number'] = $track_data['number'];
54
+ }
55
 
56
+ $shipping_data = new Varien_Object();
57
 
58
+ $shipping_data->setData($data);
59
 
60
+ return $shipping_data;
61
+ }
62
+
63
+ protected function getOrderMergeVars(&$merge_vars, $order)
64
+ {
65
+ $this->_logger->logAndDebug('getOrderMergeVars (Tracking Data)');
66
+ $maps = unserialize( $this->config('shipping_fields', $order->getStoreId()) );
67
 
68
+ if ($maps)
69
+ {
70
+ $this->_logger->log($maps, "Maps");
71
+ $shipping_data = $this->getShippingData($order);
72
+
73
+ $this->_logger->log($shipping_data,'Shipping Data');
74
+
75
+ $this->processMap($merge_vars, $maps, $shipping_data);
76
+ }
77
+ else
78
+ $this->debug('No Mappings Found');
79
+
80
+ return $merge_vars;
81
+ }
82
+
83
+ public function getOrderCustomer($order)
84
+ {
85
+ $customer = null;
86
+
87
+ if ($order->getData('customer_is_guest')) {
88
+ $this->_logger->log("Guest Customer");
89
+
90
+ $customer = new Varien_Object;
91
+
92
+ $customer->setData('email',$order->getCustomerEmail());
93
+ $customer->setData('firstname',$order->getData('customer_firstname'));
94
+ $customer->setData('lastname',$order->getData('customer_lastname'));
95
+ $customer->setData('store_id',$order->getStoreId());
96
+
97
+ $customer->setBillingAddress($order->getBillingAddress());
98
+ } else {
99
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
100
+ $address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
101
+ $customer->setBillingAddress($address);
102
+ }
103
+
104
+ return $customer;
105
+ }
106
+
107
+ public function processOrderItems($order, &$merge_vars)
108
+ {
109
+ $this->debugHeader("processOrderItems Start",1);
110
+
111
+ $merge_vars = $this->getOrderMergeVars($merge_vars,$order);
112
+
113
+ $this->_logger->logAndDebug("Check Save Lastest");
114
+ if ($this->config('save_latest_order'))
115
+ {
116
+ $this->_logger->logAndDebug("Adding Latest Order Information");
117
+ $merge_vars['LastOrderNumber'] = $order->getIncrementId();
118
+ $merge_vars['LastPurchaseDate'] = $order->getData('created_at');
119
+ $merge_vars['LastPurchaseTotal'] = Mage::helper('core')->currency($order->getData('total_paid'), true, false);
120
+
121
+ $merge_vars = $this->getMergeOrderItems($order, $merge_vars);
122
+ $merge_vars = $this->getRelatedOrderItems($order, $merge_vars);
123
+ $this->_logger->logAndDebug("Finish Save Latest");
124
+ }
125
+ else
126
+ $this->_logger->logAndDebug("Not setup to send latest order info");
127
+
128
+ return $merge_vars;
129
+ }
130
+
131
+ protected function getParentOptions($parent_product,$product_id)
132
+ {
133
+ $parent_options = $this->getConfigurableOptions($parent_product,$product_id);
134
+
135
+ if (count($parent_options) == 0)
136
+ return "";
137
+
138
+ $options = "";
139
+
140
+ foreach ($parent_options as $key => $value)
141
+ {
142
+ if ($options == "")
143
+ $options .= "#";
144
+ else
145
+ $options .= "&";
146
+
147
+ $options .= "{$key}={$value}";
148
+ }
149
+
150
+ return $options;
151
+ }
152
+
153
+ protected function getGroupedPrice($grouped_product)
154
+ {
155
+ // This is used when a grouped product is related. We get the minimum price of associated products
156
+ // otherwise we have no value to show
157
+ $min = 0;
158
+ $products = $grouped_product->getTypeInstance()->getAssociatedProducts();
159
+ foreach ($products as $product)
160
+ {
161
+ if ($min == 0)
162
+ $min = $product->getPrice();
163
+
164
+ $min = min($min, $product->getPrice());
165
+ }
166
+
167
+ return $min;
168
+ }
169
+
170
+ protected function getProductImage($product, $parent_product = null)
171
+ {
172
+ try
173
+ {
174
+ $image = "";
175
+ if ($product->getImage() == 'no_selection' || $product->getImage() == "")
176
+ {
177
+ if ($parent_product != null && $parent_product->getImage() != "no_selection" && $parent_product->getImage() != "")
178
+ $image = Mage::getModel('catalog/product_media_config')->getMediaUrl($parent_product->getImage());
179
+ }
180
+ else
181
+ $image = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
182
+ }
183
+ catch (Exception $e)
184
+ {
185
+ Mage::logException($e);
186
+ $this->_logger->logException($e);
187
+ }
188
+
189
+ return $image;
190
+ }
191
+
192
+ private function addMergeItem($item_data, $pos, $merge_vars, $prefix = "")
193
+ {
194
+ $name = "";
195
+ $parent_name = "";
196
+ $sku = "";
197
+ $url = "";
198
+ $image = "";
199
+ $cost = "";
200
+ $description = "";
201
+ $parent_item = null;
202
+ $parent_product = null;
203
+
204
+ $this->debug("--------------------------");
205
+ $this->debug("ADDING MERGE ITEM");
206
+
207
+ if ($item_data != null)
208
+ {
209
+ $product_id = 0;
210
+
211
+ if (is_array($item_data))
212
+ {
213
+ $item = $item_data['item'];
214
+
215
+ if (isset($item_data['parent']))
216
+ {
217
+ $parent_item = $item_data['parent'];
218
+ $this->debug("Parent Item:");
219
+ $this->debug($parent_item);
220
+ }
221
+ }
222
+ else
223
+ $item = $item_data;
224
+
225
+ $this->debug("Item:");
226
+ $this->debug($item);
227
+
228
+ if (is_string($item))
229
+ {
230
+ $product_id = $item;
231
+
232
+ $product = Mage::getModel('catalog/product')->load($product_id);
233
+
234
+ if ($product == null || !$product->getId())
235
+ return $merge_vars;
236
+ }
237
+ else
238
+ {
239
+ $product = $this->getProduct($item);
240
+ if ($product == null)
241
+ return $merge_vars; // Can't get product so abort
242
+ }
243
+
244
+ $this->debug("Product:");
245
+ $this->debug($product);
246
+
247
+ if ($parent_item != null)
248
+ {
249
+ $parent_product = $this->getProduct($parent_item);
250
+ if ($parent_product == null) {
251
+ return $merge_vars; // Can't get product so abort
252
+ }
253
+
254
+ $this->debug("Parent Product:");
255
+ $this->debug($parent_product);
256
+
257
+ $parent_name = $parent_product->getName();
258
+ $url = $parent_product->getProductUrl();
259
+
260
+ if ($parent_product->getTypeId() == 'configurable')
261
+ $url .= $this->getParentOptions($parent_product,$product_id);
262
+ } else {
263
+ $url = $product->getProductUrl();
264
+ }
265
+
266
+ $name = $product->getName();
267
+ $sku = $product->getSku();
268
+
269
+ $image = $this->getProductImage($product, $parent_product);
270
+
271
+ if (is_string($item))
272
+ {
273
+ $this->debug('String Item (Related)');
274
+ if ($product->getTypeId() == 'grouped')
275
+ $cost = $this->getGroupedPrice($product);
276
+ else
277
+ $cost = $product->getPrice();
278
+ }
279
+ else
280
+ {
281
+ if ($parent_item != null && get_class($parent_item) != 'Varien_Object' ) {
282
+ $cost = $parent_item->getPrice();
283
+ } else {
284
+ $cost = $item->getPrice();
285
+ }
286
+ }
287
+
288
+ $cost = Mage::helper('core')->currency($cost,true,false);
289
+ $description = $product->getShortDescription();
290
+ }
291
+
292
+ $merge_vars["{$prefix}ProductName{$pos}"] = $name;
293
+ if ($prefix != 'Related')
294
+ $merge_vars["{$prefix}ParentName{$pos}"] = $parent_name;
295
+
296
+ $merge_vars["{$prefix}SKU{$pos}"] = $sku;
297
+ $merge_vars["{$prefix}URL{$pos}"] = $url;
298
+ $merge_vars["{$prefix}Image{$pos}"] = $image;
299
+
300
+ $merge_vars["{$prefix}Cost{$pos}"] = $cost;
301
+ $merge_vars["{$prefix}Description{$pos}"] = $description;
302
+
303
+ return $merge_vars;
304
+ }
305
+
306
+ protected function getRelatedCollection($id_list, $max_count, $grouped_id_list = null)
307
+ {
308
+ $this->debug("getRelatedCollection Start");
309
+ $collection = Mage::getModel('catalog/product_link')
310
+ ->useRelatedLinks()
 
 
 
 
311
  ->getCollection()
312
  ->addFieldToFilter('product_id', array('in' => $id_list))
313
  ;
314
 
315
+ $this->debug("Collection SQL");
316
+ $this->debug($collection->getSelect()->__toString());
317
+
318
+ // Filter out grouped products from the related list
319
+ if ($grouped_id_list != null && count($grouped_id_list) > 0)
320
+ {
321
+ $this->debug("Merging Grouped ID's to filter");
322
+ $id_list = array_merge($id_list,$grouped_id_list);
323
+
324
+ }
325
+
326
+ $this->debug("ID Filters");
327
+ $this->debug($id_list);
328
+
329
+ $product_ids = array();
330
+
331
+ // If any of the related products are already in the order we filter them out
332
+ foreach ($collection as $rp)
333
+ {
334
+ $this->debug("");
335
+ $this->debug("-----------------------------");
336
+ $this->debug("Related Product");
337
+ $this->debug($rp->getData());
338
+ $lp_id = $rp['linked_product_id'];
339
+ if (!in_array($lp_id,$id_list))
340
+ {
341
+ $this->debug("Adding Related Product");
342
+ $product_ids[] = $lp_id;
343
+ }
344
+ else
345
+ $this->debug("Related product already in order");
346
+ }
347
+
348
+ $this->debug("Product IDs");
349
+ $this->debug($product_ids);
350
+
351
+ $related = Mage::getResourceModel('catalog/product_collection')
352
+ ->addFieldToFilter('entity_id', array('in' => $product_ids))
353
+ ->setPageSize($max_count);
354
+
355
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($related);
356
+
357
+ $this->debug("Related SQL");
358
+ $this->debug($related->getSelect()->__toString());
359
+
360
+ $related_list = array();
361
+
362
+ if (count($related) > 0)
363
+ {
364
+ foreach ($related as $rp)
365
+ {
366
+ $related_list[] = $rp;
367
+ }
368
+ }
369
+
370
+ return $related_list;
371
+ }
372
+
373
+ protected function getRelatedProducts($quote)
374
+ {
375
+ $id_list = array();
376
+ $grouped_id_list = array();
377
+ $filter_id_list = array();
378
+
379
+ foreach ($quote->getAllItems() as $item)
380
  {
381
+ $this->debug("");
382
+ $this->debug("----------------------------------------------------------");
383
+ $type = $item->getProductType();
384
+ $this->debug("Item ID: {$item->getId()}");
385
+ $this->debug("Item Sku: {$item->getSku()}");
386
+ $this->debug("Item Type: {$type}");
387
+
388
+ // if it is a grouped product get the parent ID and add it to the list (if not already added)
389
+ if ($type == 'grouped')
390
+ {
391
+ $grouped_product_id = $this->getGroupedProductId($item);
392
+
393
+ $this->debug("Grouped Product ID: {$grouped_product_id}");
394
+
395
+ if (!in_array($grouped_product_id, $grouped_id_list))
396
+ $grouped_id_list[] = $grouped_product_id;
397
+ }
398
+
399
+ if ($product = $this->getProduct($item))
400
+ {
401
+ $product_id = $product->getId();
402
+ if (!in_array($product_id, $id_list))
403
+ $id_list[] = $product_id;
404
+ }
405
  }
406
 
407
+ $this->debug("ID List");
408
+ $this->debug($id_list);
409
+ $this->debug("Grouped ID List");
410
+ $this->debug($grouped_id_list);
411
 
412
+ $max_count = $this->config('related_fields');
413
+
414
+ $this->debug("Max Related: {$max_count}");
415
+
416
+ $this->debug("");
417
+ $this->debug("--------------------------------------------------------------------------");
418
+ $this->debug("Get Related Collection (Non Grouped)");
419
+ $this->debug("");
420
+
421
+ $related = $this->getRelatedCollection($id_list, $max_count, $grouped_id_list);
422
+
423
+ $this->debug("");
424
+ $this->debug("# of Related Products Found: " . count($related));
425
+
426
+ if (count($related) < $max_count && count($grouped_id_list) > 0)
427
+ {
428
+ $this->debug("");
429
+ $this->debug("--------------------------------------------------------------------------");
430
+ $this->debug("Get Related Collection (Grouped)");
431
+ $this->debug("");
432
+
433
+ // get grouped related
434
+ $grouped_related = $this->getRelatedCollection($grouped_id_list, $max_count - count($related), $id_list);
435
+
436
+ // Merge the collections
437
+ if (count($grouped_related) > 0)
438
+ return array_merge($related, $grouped_related);
439
+ }
440
 
441
+ return $related;
442
+ }
443
 
444
+ public function getRelatedOrderItems($quote, $merge_vars)
445
+ {
446
+ $prefix = "Related";
447
+ $max_count = $this->config('related_fields');
448
 
449
+ $this->debug('');
450
+ $this->debug('Getting Related Products');
451
 
452
+ $related_products = $this->getRelatedProducts($quote);
453
 
454
+ $count = 0;
455
 
456
+ foreach ($related_products as $rp)
457
+ {
458
+ $count++;
459
 
460
+ if ($count > $max_count)
461
+ break;
462
+
463
+ $merge_vars = $this->addMergeItem($rp->getId(), $count, $merge_vars, $prefix);
464
+ }
465
+
466
+ while ($count < $max_count)
467
+ {
468
+ $count++;
469
+ $merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
470
+ }
471
+
472
+ return $merge_vars;
473
+ }
474
+
475
+ protected function getGroupedProductId($item)
476
+ {
477
+ $this->debug('Get Grouped Product Id');
478
+ $options = $item->getProductOptions();
479
+
480
+ $this->debug('Product Options');
481
+ $this->debug($options);
482
+
483
+ if (isset($options['super_product_config']))
484
+ {
485
+ $this->debug('Super config found');
486
+ if (isset($options['super_product_config']['product_id']))
487
+ {
488
+ $this->debug('Product Id Found');
489
+ $product_id = $options['super_product_config']['product_id'];
490
+
491
+ return $product_id;
492
+ }
493
+ $this->debug('Product Id Not Found!');
494
+ }
495
+ else
496
+ {
497
+ $this->debug('Get Option By Code');
498
+ $option = $item->getOptionByCode('product_type');
499
+ if ($option)
500
+ {
501
+ $this->debug('Option Found');
502
+ $this->debug($option);
503
+ return $option->getProductId();
504
+ }
505
+ }
506
+
507
+ $this->debug('Unable to get Grouped Product ID');
508
+
509
+ return false;
510
+ }
511
+
512
+ protected function getGroupedProduct($item)
513
+ {
514
+ $this->debug('Get Grouped Product');
515
+ $product_id = $this->getGroupedProductId($item);
516
+
517
+ if ($product_id !== false)
518
+ {
519
+ $this->debug('Loading Product');
520
+ $product = Mage::getModel('catalog/product')->load($product_id);
521
+
522
+ if ($product->getId())
523
+ {
524
+ $this->debug('Grouped Product Found!');
525
+ return $product;
526
+ }
527
+ }
528
+
529
+ $this->debug('Unable to get Grouped Product');
530
+
531
+ return false;
532
+ }
533
+
534
+ protected function isItemVisible($item)
535
+ {
536
+ $vis_flag = Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
537
+
538
+ if ($item == null)
539
+ return true;
540
+
541
+ $product = $this->getProduct($item);
542
+
543
+ if ($product == null)
544
+ return true;
545
+
546
+ if ($product->getVisibility() != $vis_flag)
547
+ return true;
548
+
549
+ return false;
550
+ }
551
+
552
+ protected function processParentItems($quote)
553
+ {
554
+ $this->debug("Processing Parent Items");
555
+ $parent_items = array();
556
+
557
+ foreach ($quote->getAllItems() as $item)
558
+ {
559
+ $this->debug("");
560
+ $this->debug("----------------------------------------------------------");
561
+ $type = $item->getProductType();
562
+ //Zend_debug::dump($item->getData());
563
+ $this->debug("Item ID: {$item->getId()}");
564
+ $this->debug("Item Sku: {$item->getSku()}");
565
+ $this->debug("Item Type: {$type}");
566
+ if ($type == "configurable" || $type == "bundle")
567
+ {
568
+ $this->debug('*** Adding as Parent Item ***');
569
+ $parent_items[$item->getId()] = $item;
570
+ }
571
+
572
+ if ($type == "grouped")
573
+ {
574
+ $grouped_product = $this->getGroupedProduct($item);
575
+
576
+ if ($grouped_product)
577
+ {
578
+ $this->debug('*** Adding Grouped Product to Parent Items ***');
579
+ $parent_item = new Varien_Object;
580
+ $parent_item->setProduct($grouped_product);
581
+ $parent_items[$item->getId()] = $parent_item;
582
+ }
583
+ }
584
+ }
585
+
586
+ $this->debug('Parent Items Found: ' . count($parent_items));
587
+
588
+ if (count($parent_items) > 0)
589
+ {
590
+ $this->debug('Parent Items:');
591
+
592
+ foreach($parent_items as $key => $item)
593
+ {
594
+ $this->debug('-------------------------');
595
+ $this->debug("ID: {$key}");
596
+ if ($item->getId())
597
+ $this->debug("Parent ID: " . $item->getId());
598
+ else
599
+ {
600
+ $parent_product = $this->getProduct($item);
601
+ if ($parent_product)
602
+ $this->debug("Parent ID: " . $parent_product->getId());
603
+ else
604
+ $this->debug("Parent ID: Failed to load product");
605
+ }
606
+ }
607
+ }
608
+
609
+ return $parent_items;
610
+ }
611
+
612
+ public function getMergeOrderItems($quote, $merge_vars, $prefix = "")
613
+ {
614
+ $max_count = $this->config('product_fields');
615
+
616
+ $count = 0;
617
+
618
+ $item_data = array();
619
+
620
+ $parent_items = $this->processParentItems($quote);
621
+
622
+ $this->debug('');
623
+ $this->debug('Processing Order Items');
624
+
625
+ foreach ($quote->getAllItems() as $item)
626
+ {
627
+ $type = $item->getProductType();
628
+
629
+ $this->debug('');
630
+ $this->debug("----------------------------------------------------------");
631
+ $this->debug('Item Sku: ' . $item->getSku());
632
+ $this->debug('Item Type: ' . $type);
633
+
634
+ if ($type == "configurable" || $type == "bundle")
635
+ {
636
+ $this->debug('Skipping Configurable and Bundle Products (this is a parent product)');
637
+ continue;
638
+ }
639
+
640
+ $item_id = $item->getId();
641
+
642
+ if ($item->getProductType() == 'grouped')
643
+ {
644
+ $this->debug('Grouped Product');
645
+
646
+ $parent_id = $item->getId();
647
+ }
648
+ else
649
+ {
650
+ $parent_id = $item->getParentItemId();
651
+ }
652
+
653
+ $this->debug("Parent Id: {$parent_id}");
654
+
655
+ if ($parent_id != null && isset($parent_items[$parent_id]))
656
+ {
657
+ $this->debug('Item has a Parent');
658
+ $parent_item = $parent_items[$parent_id];
659
+
660
+ $this->debug('Checking Visibility of Item and Parent (only one needs to be visible)');
661
+ if ($this->isItemVisible($item) || $this->isItemVisible($parent_item))
662
+ {
663
+ $this->debug('Adding Item to list');
664
+ $item_data[$item_id] = array('item' => $item, 'parent' => $parent_item);
665
+ }
666
+ else
667
+ $this->debug('Visibility check failed');
668
+ }
669
+ else
670
+ {
671
+ $this->debug('Checking Visibility of Item');
672
+ if ($this->isItemVisible($item))
673
+ {
674
+ $this->debug('Adding Item to list');
675
+ $item_data[$item_id] = array('item' => $item);
676
+ }
677
+ else
678
+ $this->debug('Visibility check failed');
679
+ }
680
+ }
681
+
682
+ foreach ($item_data as $item)
683
  {
684
+ $count++;
685
 
686
+ if ($count > $max_count)
687
+ break;
688
 
689
  $merge_vars = $this->addMergeItem($item, $count, $merge_vars, $prefix);
690
  }
691
 
692
+ // Blank out other items
693
+ while ($count < $max_count)
694
+ {
695
+ $count++;
696
+ $merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
697
+ }
698
 
699
+ return $merge_vars;
700
+ }
701
  }
app/code/community/EmailDirect/Integration/Model/Resource/Setup.php CHANGED
@@ -65,7 +65,7 @@ class EmailDirect_Integration_Model_Resource_Setup extends Mage_Core_Model_Resou
65
  if (is_array($description))
66
  $description = '<ul><li>' . implode('</li><li>', $description) . '</li></ul>';
67
 
68
- $date = date(EmailDirect_Integration_Helper_Troubleshooting::DATE_FORMAT);
69
  Mage::getSingleton('adminnotification/inbox')->parse(array(array(
70
  'severity' => $severity,
71
  'date_added' => $date,
65
  if (is_array($description))
66
  $description = '<ul><li>' . implode('</li><li>', $description) . '</li></ul>';
67
 
68
+ $date = date(EmailDirect_Integration_Helper_Data::DATE_FORMAT);
69
  Mage::getSingleton('adminnotification/inbox')->parse(array(array(
70
  'severity' => $severity,
71
  'date_added' => $date,
app/code/community/EmailDirect/Integration/controllers/Admin/AbandonedController.php CHANGED
@@ -2,89 +2,94 @@
2
 
3
  class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_Controller_Action
4
  {
5
- public function indexAction()
6
- {
7
- $this->loadLayout();
8
-
9
- $this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Abandoned Carts'));
10
- $this->_setActiveMenu('emaildirect');
11
- $this->renderLayout();
12
- }
13
-
14
- public function detailsAction()
15
- {
16
- $this->loadLayout();
17
-
18
- $this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Abandoned Carts'));
19
- $this->_setActiveMenu('emaildirect');
20
- $this->renderLayout();
21
- }
22
-
23
- public function gridAction()
24
- {
25
- $this->showGrid();
26
- }
27
-
28
- private function showGrid()
29
- {
30
- $this->loadLayout();
31
- $this->getResponse()->setBody($this->getLayout()->createBlock('emaildirect/adminhtml_abandoned_grid')->toHtml());
32
  }
33
 
34
- public function runAction()
35
- {
36
- $store_id = $this->getRequest()->getParam('store_id');
37
-
38
- Mage::getSingleton('emaildirect/abandoned_observer')->manualCartsProcessor($store_id);
39
-
40
- $msg = "The Abandoned Cart process has been run";
41
-
42
- if ($store_id)
43
- $msg .= " on store: " . Mage::helper('emaildirect')->getFullStoreNameById($store_id);
44
-
45
- $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__($msg));
46
- $this->_redirect('*/*/index');
47
- }
48
-
49
- public function sendAction()
50
- {
51
- $id = $this->getRequest()->getParam('id');
52
-
53
- if ($id == null)
54
- $this->_getSession()->addError(Mage::helper('adminhtml')->__("No Carts were specified."));
55
- else
56
- {
57
- $id_list = array($id);
58
- Mage::getSingleton('emaildirect/abandoned_observer')->SendAbandonedCarts($id_list);
59
- $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("Abandoned Cart has been sent."));
60
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  $this->_redirect('*/*/index');
62
- }
63
-
64
- public function massSendAction()
65
- {
66
- $params = array();
67
  if( $this->getRequest()->isPost() )
68
  $params = $this->getRequest()->getPost();
69
 
70
  $id_list = $params['id'];
71
-
72
- if (!is_array($id_list))
73
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select at least one cart to send or resend.'));
74
- else
75
  {
76
- try
77
  {
78
- $count = Mage::getSingleton('emaildirect/abandoned_observer')->SendAbandonedCarts($id_list);
79
-
80
  Mage::getSingleton('adminhtml/session')->addSuccess(
81
  Mage::helper('adminhtml')->__('Total of %d carts(s) were sent.', $count));
82
- }
83
- catch (Exception $e)
84
  {
85
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
86
  }
87
  }
88
  $this->_redirect('*/*/index', Mage::helper('emaildirect')->getUrlParams());
89
- }
90
  }
2
 
3
  class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_Controller_Action
4
  {
5
+ protected function _isAllowed()
6
+ {
7
+ return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_abandoned');
8
+ }
9
+
10
+ public function indexAction()
11
+ {
12
+ $this->loadLayout();
13
+
14
+ $this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Abandoned Carts'));
15
+ $this->_setActiveMenu('emaildirect');
16
+ $this->renderLayout();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
+ public function detailsAction()
20
+ {
21
+ $this->loadLayout();
22
+
23
+ $this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Abandoned Carts'));
24
+ $this->_setActiveMenu('emaildirect');
25
+ $this->renderLayout();
26
+ }
27
+
28
+ public function gridAction()
29
+ {
30
+ $this->showGrid();
31
+ }
32
+
33
+ private function showGrid()
34
+ {
35
+ $this->loadLayout();
36
+ $this->getResponse()->setBody($this->getLayout()->createBlock('emaildirect/adminhtml_abandoned_grid')->toHtml());
37
+ }
38
+
39
+ public function runAction()
40
+ {
41
+ $store_id = $this->getRequest()->getParam('store_id');
42
+
43
+ Mage::getSingleton('emaildirect/abandoned_observer')->manualCartsProcessor($store_id);
44
+
45
+ $msg = "The Abandoned Cart process has been run";
46
+
47
+ if ($store_id) {
48
+ $msg .= " on store: " . Mage::helper('emaildirect')->getFullStoreNameById($store_id);
49
+ }
50
+
51
+ $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__($msg));
52
+ $this->_redirect('*/*/index');
53
+ }
54
+
55
+ public function sendAction()
56
+ {
57
+ $id = $this->getRequest()->getParam('id');
58
+
59
+ if ($id == null) {
60
+ $this->_getSession()->addError(Mage::helper('adminhtml')->__("No Carts were specified."));
61
+ } else {
62
+ $id_list = array($id);
63
+ Mage::getSingleton('emaildirect/abandoned_observer')->SendAbandonedCarts($id_list);
64
+ $this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("Abandoned Cart has been sent."));
65
+ }
66
  $this->_redirect('*/*/index');
67
+ }
68
+
69
+ public function massSendAction()
70
+ {
71
+ $params = array();
72
  if( $this->getRequest()->isPost() )
73
  $params = $this->getRequest()->getPost();
74
 
75
  $id_list = $params['id'];
76
+
77
+ if (!is_array($id_list))
78
  Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select at least one cart to send or resend.'));
79
+ else
80
  {
81
+ try
82
  {
83
+ $count = Mage::getSingleton('emaildirect/abandoned_observer')->SendAbandonedCarts($id_list);
84
+
85
  Mage::getSingleton('adminhtml/session')->addSuccess(
86
  Mage::helper('adminhtml')->__('Total of %d carts(s) were sent.', $count));
87
+ }
88
+ catch (Exception $e)
89
  {
90
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
91
  }
92
  }
93
  $this->_redirect('*/*/index', Mage::helper('emaildirect')->getUrlParams());
94
+ }
95
  }
app/code/community/EmailDirect/Integration/controllers/Admin/DiagnosticController.php CHANGED
@@ -6,24 +6,29 @@ class EmailDirect_Integration_Admin_DiagnosticController extends Mage_Adminhtml_
6
  private $_order = null;
7
  private $_quote = null;
8
  private $_result = array();
9
-
 
 
 
 
 
10
  public function downloadAction()
11
  {
12
  $filename = $this->getRequest()->getParam('filename');
13
-
14
  $output = $this->getRequest()->getParam('output');
15
-
16
  $this->_prepareDownloadResponse($filename, $output);
17
  }
18
-
19
  public function ajaxAction()
20
  {
21
  $this->_logger = Mage::helper('emaildirect/troubleshooting');
22
  $this->_logger->turnOnDebug();
23
-
24
  $method = $this->getRequest()->getParam('method');
25
  $success = false;
26
-
27
  switch ($method)
28
  {
29
  // Orders
@@ -33,22 +38,22 @@ class EmailDirect_Integration_Admin_DiagnosticController extends Mage_Adminhtml_
33
  case "order_full_request": $success = $this->fullOrder(); break;
34
  case "order_custom_fields": $success = $this->customFields(); break;
35
  case "tracking_info": $success = $this->trackingInfo(); break;
36
-
37
  // Abandoned
38
  case "abandoned_url": $success = $this->AbandonedUrl(); break;
39
  case "abandoned_custom_fields": $success = $this->AbandonedCustomFields(); break;
40
  case "abandoned_request": $success = $this->abandonedFull(); break;
41
  case "abandoned_request_full": $success = $this->abandonedFull(false); break;
42
  }
43
-
44
  $this->_logger->turnOffDebug();
45
-
46
  if ($success)
47
  $this->setSuccess($this->_output, $this->_logger->getDebugData());
48
-
49
  $this->getResponse()->setBody(json_encode($this->_result));
50
  }
51
-
52
  private function getCss()
53
  {
54
  $css = "<style>
@@ -58,31 +63,31 @@ class EmailDirect_Integration_Admin_DiagnosticController extends Mage_Adminhtml_
58
  .diagnostic_table tr td:first-child { font-weight: bold; }
59
 
60
  </style>";
61
-
62
  return $css;
63
  }
64
-
65
  private function setSuccess($output, $details)
66
  {
67
  $this->_result['success'] = true;
68
-
69
  if (is_array($details))
70
  $this->_result['details'] = implode("<br />",$details) . "<br /><br />";
71
  else
72
  $this->_result['details'] = $details;
73
-
74
  $this->_result['output'] = $this->getCss() . $output;
75
-
76
  return true;
77
  }
78
-
79
  private function setFailure($message)
80
  {
81
  $this->_result['success'] = false;
82
  $this->_result['error'] = true;
83
-
84
  $this->_result['message'] = $message;
85
-
86
  return false;
87
  }
88
 
@@ -90,397 +95,397 @@ class EmailDirect_Integration_Admin_DiagnosticController extends Mage_Adminhtml_
90
  {
91
  $this->_logger->debug($data);
92
  }
93
-
94
  private function debugHeader($data, $level = 2)
95
  {
96
  $this->_logger->debugHeader($data, $level);
97
  }
98
-
99
  private function getOrder()
100
  {
101
  if ($this->_order != null)
102
  return $this->_order;
103
-
104
  $order_id = $this->getRequest()->getParam('item_id');
105
-
106
  $this->_order = Mage::getModel('sales/order')->load($order_id);
107
-
108
  if ($this->_order != null && !$this->_order->getId())
109
  $this->_order = null;
110
- else
111
  Mage::app()->setCurrentStore($this->_order->getStoreId());
112
-
113
  return $this->_order;
114
  }
115
-
116
  private function getQuote()
117
  {
118
  if ($this->_quote != null)
119
  return $this->_quote;
120
-
121
  $quote_id = $this->getRequest()->getParam('item_id');
122
  $store_id = $this->getRequest()->getParam('store_id');
123
-
124
  $store = Mage::getModel('core/store')->load($store_id);
125
-
126
  $this->_quote = Mage::getModel('sales/quote')->setStore($store)->load($quote_id);
127
-
128
  if ($this->_quote != null && !$this->_quote->getId())
129
  $this->_quote = null;
130
- else
131
  Mage::app()->setCurrentStore($store);
132
-
133
  return $this->_quote;
134
  }
135
-
136
  private function decorateArray($array)
137
  {
138
  //Zend_debug::dump($array);
139
  $output = "<table class='diagnostic_table'>";
140
  $output .= "<tr>";
141
  $keys = array_keys($array);
142
-
143
  foreach ($keys as $key)
144
  {
145
  $output .= "<th>{$key}</th>";
146
  }
147
-
148
  $output .= "</tr>";
149
-
150
  foreach ($array as $row)
151
  {
152
  $output .= "<tr>";
153
-
154
  foreach ($row as $data)
155
  {
156
  $output .= "<td>{$data}</td>";
157
  }
158
-
159
  $output .= "</tr>";
160
  }
161
-
162
  $output .= "</table>";
163
-
164
  return $output;
165
  }
166
-
167
  private function arrayToTable($array)
168
  {
169
  $output = "<table class='diagnostic_table' cellspacing='0'>";
170
-
171
  foreach ($array as $key => $value)
172
  {
173
  $output .= "<tr><td>{$key}</td><td>{$value}</td></tr>";
174
  }
175
-
176
  return $output . "</table>";
177
  }
178
-
179
  private function getNumberedKeys($array)
180
  {
181
  $keys = array();
182
-
183
  foreach ($array as $key => $value)
184
  {
185
  if (strpos($key,"1") === false)
186
  return $keys;
187
-
188
  $keys[] = substr($key,0,strlen($key) - 1);
189
  }
190
-
191
  return $keys;
192
  }
193
-
194
  private function numberedItemsDisplay($array)
195
  {
196
  $output = "";
197
-
198
  $keys = $this->getNumberedKeys($array);
199
-
200
  $first_key = $keys[0];
201
-
202
  $count = 1;
203
-
204
  while (isset($array["{$first_key}{$count}"]))
205
  {
206
  $output .= "<h3>Item # {$count}</h3>";
207
-
208
  $output .= "<table class='diagnostic_table' cellspacing='0'>";
209
-
210
  foreach ($keys as $key)
211
  {
212
  $output .= "<tr><td>{$key}</td><td>" . $array["{$key}{$count}"] . "</td></tr>";
213
  }
214
-
215
  $output .= "</table><br />";
216
-
217
  $count++;
218
  }
219
-
220
-
221
  return $output;
222
  }
223
-
224
  private function lastOrderItems()
225
- {
226
  $order = $this->getOrder();
227
-
228
  if ($order == null)
229
  return $this->setFailure("Order not found");
230
-
231
  $this->debugHeader('Last Order Items');
232
-
233
  $this->debug('Order #' . $order->getIncrementId());
234
-
235
  $merge_vars = array();
236
-
237
  $order_helper = Mage::helper('emaildirect/order');
238
-
239
  $merge_vars = $order_helper->getMergeOrderItems($order, $merge_vars);
240
-
241
  $this->debug('');
242
  $this->debugHeader('Latest Order Items',1);
243
  $this->debug($merge_vars);
244
-
245
  $this->debugHeader('Last Order Items Complete!');
246
-
247
  $this->_output = "<h2>Order Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
248
-
249
  return true;
250
  }
251
 
252
  private function relatedOrderItems()
253
- {
254
  $order = $this->getOrder();
255
-
256
  if ($order == null)
257
  return $this->setFailure("Order not found");
258
-
259
  $this->debugHeader('Related Order Items');
260
-
261
  $this->debug('Order #' . $order->getIncrementId());
262
  $this->debug('');
263
-
264
  $merge_vars = array();
265
-
266
  $order_helper = Mage::helper('emaildirect/order');
267
-
268
  $merge_vars = $order_helper->getRelatedOrderItems($order, $merge_vars);
269
-
270
  $this->debugHeader('Related Order Items',1);
271
  $this->debug($merge_vars);
272
-
273
  $this->debugHeader('Related Order Items Complete!');
274
-
275
  $this->_output = "<h2>Related Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
276
-
277
  return true;
278
  }
279
 
280
  private function fullOrder($request_only = true)
281
  {
282
  $order = $this->getOrder();
283
-
284
  if ($order == null)
285
  return $this->setFailure("Order not found");
286
-
287
  $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
288
-
289
  $merge_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
290
-
291
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
292
-
293
  //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
294
-
295
  //$this->_logger->debugXml($order_xml);
296
-
297
  if ($request_only)
298
  $this->_logger->setDebugExecuteMode('request_only');
299
  else
300
  $this->_logger->setDebugExecuteMode('full');
301
-
302
  Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
303
-
304
  $this->_output = "<h2>Full Order Diagnostic Results</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
305
-
306
  if (!$request_only)
307
  {
308
  $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
309
  }
310
-
311
  return true;
312
  }
313
-
314
  private function customFields()
315
  {
316
  $order = $this->getOrder();
317
-
318
  if ($order == null)
319
  return $this->setFailure("Order not found");
320
-
321
  $this->debugHeader('Custom Fields Diagnostic Starting');
322
-
323
  $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
324
-
325
  $this->debugHeader('Customer Related Merge Vars',1);
326
-
327
  $customer_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
328
-
329
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
330
-
331
  //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
332
-
333
  //$this->_logger->debugXml($order_xml);
334
-
335
  $this->_output = "<h2>Custom Fields Diagnostic Results</h2><h3>Customer Fields</h3>" . $this->arrayToTable($customer_vars);
336
  $this->_output .= "<br /><h3>Order Fields</h3>" . $this->arrayToTable($merge_vars);
337
-
338
  return true;
339
  }
340
-
341
  private function abandonedUrl()
342
  {
343
  $quote = $this->getQuote();
344
-
345
  if ($quote == null)
346
  return $this->setFailure("Quote not found");
347
-
348
  $this->debugHeader('Abandoned URL');
349
-
350
  //$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
351
-
352
  //$this->debugHeader('Customer Related Merge Vars',1);
353
-
354
  $url = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
355
-
356
  $this->_output = "<h2>Abandoned Cart Url (Restore Cart)</h2><p>Click on the link to test it (opens in a new window and won't replace customer cart data)</p>URL: <a target='_blank' href='{$url}&test_mode=true'>{$url}</a>";
357
-
358
  return true;
359
  }
360
-
361
  private function abandonedCustomFields()
362
  {
363
  $quote = $this->getQuote();
364
-
365
  if ($quote == null)
366
  return $this->setFailure("Quote not found");
367
-
368
  $this->debugHeader('Custom Fields Diagnostic Starting');
369
-
370
  $abandonedDate = $quote->getUpdatedAt();
371
-
372
  $merge_vars = array();
373
-
374
  $merge_vars['FirstName'] = $quote->getData('customer_firstname');
375
  $merge_vars['LastName'] = $quote->getData('customer_lastname');
376
-
377
  $merge_vars['AbandonedDate'] = $abandonedDate;
378
  $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
379
-
380
  // Setup sequence for this store
381
  Mage::helper('emaildirect/abandoned')->setupSequence();
382
-
383
  Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
384
-
385
  $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
386
-
387
-
388
-
389
  if (Mage::helper('emaildirect')->config('save_latest_order'))
390
  {
391
  $this->debug("Processing Last Order");
392
  $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
393
-
394
  if ($order != null)
395
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
396
  else
397
  $this->debug("Order not found");
398
  //$this->_log("Order not found");
399
  }
400
-
401
-
402
  //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
403
-
404
  //$this->_logger->debugXml($order_xml);
405
-
406
  $this->_output = "<h2>Custom Fields Diagnostic Results</h2>";
407
  $this->_output .= "<br /><h3>Fields</h3>" . $this->arrayToTable($merge_vars);
408
-
409
  return true;
410
  }
411
 
412
  private function getQuoteEmail($quote)
413
  {
414
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart($quote->getId());
415
-
416
  return $abandoned_cart->getEmail();
417
  }
418
 
419
  private function abandonedFull($request_only = true)
420
  {
421
  $quote = $this->getQuote();
422
-
423
  if ($quote == null)
424
  return $this->setFailure("Quote not found");
425
-
426
  $abandonedDate = $quote->getUpdatedAt();
427
-
428
  $email = $quote->getCustomerEmail();
429
-
430
  if ($email == null)
431
  $email = $this->getQuoteEmail($quote);
432
-
433
  $merge_vars = array();
434
-
435
  $merge_vars['FirstName'] = $quote->getData('customer_firstname');
436
  $merge_vars['LastName'] = $quote->getData('customer_lastname');
437
-
438
  $merge_vars['AbandonedDate'] = $abandonedDate;
439
  $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
440
-
441
  // Setup sequence for this store
442
  Mage::helper('emaildirect/abandoned')->setupSequence();
443
-
444
  Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
445
-
446
  $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
447
-
448
  if (Mage::helper('emaildirect')->config('save_latest_order'))
449
  {
450
  $this->debug("Processing Last Order");
451
  $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
452
-
453
  if ($order != null)
454
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
455
  else
456
  $this->debug("Order not found");
457
  //$this->_log("Order not found");
458
  }
459
-
460
  $xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
461
-
462
  if ($request_only)
463
  $this->_logger->setDebugExecuteMode('request_only');
464
  else
465
  $this->_logger->setDebugExecuteMode('full');
466
-
467
  $xml = "<Subscribers>{$xml}</Subscribers>";
468
-
469
  //Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
470
  $rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
471
-
472
  $this->_output = "<h2>Abandoned Cart Xml</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
473
-
474
  if (!$request_only)
475
  {
476
  $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
477
  }
478
  return true;
479
  }
480
-
481
  private function trackingInfo()
482
  {
483
-
484
  return true;
485
  }
486
  }
6
  private $_order = null;
7
  private $_quote = null;
8
  private $_result = array();
9
+
10
+ protected function _isAllowed()
11
+ {
12
+ return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_diagnostics');
13
+ }
14
+
15
  public function downloadAction()
16
  {
17
  $filename = $this->getRequest()->getParam('filename');
18
+
19
  $output = $this->getRequest()->getParam('output');
20
+
21
  $this->_prepareDownloadResponse($filename, $output);
22
  }
23
+
24
  public function ajaxAction()
25
  {
26
  $this->_logger = Mage::helper('emaildirect/troubleshooting');
27
  $this->_logger->turnOnDebug();
28
+
29
  $method = $this->getRequest()->getParam('method');
30
  $success = false;
31
+
32
  switch ($method)
33
  {
34
  // Orders
38
  case "order_full_request": $success = $this->fullOrder(); break;
39
  case "order_custom_fields": $success = $this->customFields(); break;
40
  case "tracking_info": $success = $this->trackingInfo(); break;
41
+
42
  // Abandoned
43
  case "abandoned_url": $success = $this->AbandonedUrl(); break;
44
  case "abandoned_custom_fields": $success = $this->AbandonedCustomFields(); break;
45
  case "abandoned_request": $success = $this->abandonedFull(); break;
46
  case "abandoned_request_full": $success = $this->abandonedFull(false); break;
47
  }
48
+
49
  $this->_logger->turnOffDebug();
50
+
51
  if ($success)
52
  $this->setSuccess($this->_output, $this->_logger->getDebugData());
53
+
54
  $this->getResponse()->setBody(json_encode($this->_result));
55
  }
56
+
57
  private function getCss()
58
  {
59
  $css = "<style>
63
  .diagnostic_table tr td:first-child { font-weight: bold; }
64
 
65
  </style>";
66
+
67
  return $css;
68
  }
69
+
70
  private function setSuccess($output, $details)
71
  {
72
  $this->_result['success'] = true;
73
+
74
  if (is_array($details))
75
  $this->_result['details'] = implode("<br />",$details) . "<br /><br />";
76
  else
77
  $this->_result['details'] = $details;
78
+
79
  $this->_result['output'] = $this->getCss() . $output;
80
+
81
  return true;
82
  }
83
+
84
  private function setFailure($message)
85
  {
86
  $this->_result['success'] = false;
87
  $this->_result['error'] = true;
88
+
89
  $this->_result['message'] = $message;
90
+
91
  return false;
92
  }
93
 
95
  {
96
  $this->_logger->debug($data);
97
  }
98
+
99
  private function debugHeader($data, $level = 2)
100
  {
101
  $this->_logger->debugHeader($data, $level);
102
  }
103
+
104
  private function getOrder()
105
  {
106
  if ($this->_order != null)
107
  return $this->_order;
108
+
109
  $order_id = $this->getRequest()->getParam('item_id');
110
+
111
  $this->_order = Mage::getModel('sales/order')->load($order_id);
112
+
113
  if ($this->_order != null && !$this->_order->getId())
114
  $this->_order = null;
115
+ else
116
  Mage::app()->setCurrentStore($this->_order->getStoreId());
117
+
118
  return $this->_order;
119
  }
120
+
121
  private function getQuote()
122
  {
123
  if ($this->_quote != null)
124
  return $this->_quote;
125
+
126
  $quote_id = $this->getRequest()->getParam('item_id');
127
  $store_id = $this->getRequest()->getParam('store_id');
128
+
129
  $store = Mage::getModel('core/store')->load($store_id);
130
+
131
  $this->_quote = Mage::getModel('sales/quote')->setStore($store)->load($quote_id);
132
+
133
  if ($this->_quote != null && !$this->_quote->getId())
134
  $this->_quote = null;
135
+ else
136
  Mage::app()->setCurrentStore($store);
137
+
138
  return $this->_quote;
139
  }
140
+
141
  private function decorateArray($array)
142
  {
143
  //Zend_debug::dump($array);
144
  $output = "<table class='diagnostic_table'>";
145
  $output .= "<tr>";
146
  $keys = array_keys($array);
147
+
148
  foreach ($keys as $key)
149
  {
150
  $output .= "<th>{$key}</th>";
151
  }
152
+
153
  $output .= "</tr>";
154
+
155
  foreach ($array as $row)
156
  {
157
  $output .= "<tr>";
158
+
159
  foreach ($row as $data)
160
  {
161
  $output .= "<td>{$data}</td>";
162
  }
163
+
164
  $output .= "</tr>";
165
  }
166
+
167
  $output .= "</table>";
168
+
169
  return $output;
170
  }
171
+
172
  private function arrayToTable($array)
173
  {
174
  $output = "<table class='diagnostic_table' cellspacing='0'>";
175
+
176
  foreach ($array as $key => $value)
177
  {
178
  $output .= "<tr><td>{$key}</td><td>{$value}</td></tr>";
179
  }
180
+
181
  return $output . "</table>";
182
  }
183
+
184
  private function getNumberedKeys($array)
185
  {
186
  $keys = array();
187
+
188
  foreach ($array as $key => $value)
189
  {
190
  if (strpos($key,"1") === false)
191
  return $keys;
192
+
193
  $keys[] = substr($key,0,strlen($key) - 1);
194
  }
195
+
196
  return $keys;
197
  }
198
+
199
  private function numberedItemsDisplay($array)
200
  {
201
  $output = "";
202
+
203
  $keys = $this->getNumberedKeys($array);
204
+
205
  $first_key = $keys[0];
206
+
207
  $count = 1;
208
+
209
  while (isset($array["{$first_key}{$count}"]))
210
  {
211
  $output .= "<h3>Item # {$count}</h3>";
212
+
213
  $output .= "<table class='diagnostic_table' cellspacing='0'>";
214
+
215
  foreach ($keys as $key)
216
  {
217
  $output .= "<tr><td>{$key}</td><td>" . $array["{$key}{$count}"] . "</td></tr>";
218
  }
219
+
220
  $output .= "</table><br />";
221
+
222
  $count++;
223
  }
224
+
225
+
226
  return $output;
227
  }
228
+
229
  private function lastOrderItems()
230
+ {
231
  $order = $this->getOrder();
232
+
233
  if ($order == null)
234
  return $this->setFailure("Order not found");
235
+
236
  $this->debugHeader('Last Order Items');
237
+
238
  $this->debug('Order #' . $order->getIncrementId());
239
+
240
  $merge_vars = array();
241
+
242
  $order_helper = Mage::helper('emaildirect/order');
243
+
244
  $merge_vars = $order_helper->getMergeOrderItems($order, $merge_vars);
245
+
246
  $this->debug('');
247
  $this->debugHeader('Latest Order Items',1);
248
  $this->debug($merge_vars);
249
+
250
  $this->debugHeader('Last Order Items Complete!');
251
+
252
  $this->_output = "<h2>Order Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
253
+
254
  return true;
255
  }
256
 
257
  private function relatedOrderItems()
258
+ {
259
  $order = $this->getOrder();
260
+
261
  if ($order == null)
262
  return $this->setFailure("Order not found");
263
+
264
  $this->debugHeader('Related Order Items');
265
+
266
  $this->debug('Order #' . $order->getIncrementId());
267
  $this->debug('');
268
+
269
  $merge_vars = array();
270
+
271
  $order_helper = Mage::helper('emaildirect/order');
272
+
273
  $merge_vars = $order_helper->getRelatedOrderItems($order, $merge_vars);
274
+
275
  $this->debugHeader('Related Order Items',1);
276
  $this->debug($merge_vars);
277
+
278
  $this->debugHeader('Related Order Items Complete!');
279
+
280
  $this->_output = "<h2>Related Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
281
+
282
  return true;
283
  }
284
 
285
  private function fullOrder($request_only = true)
286
  {
287
  $order = $this->getOrder();
288
+
289
  if ($order == null)
290
  return $this->setFailure("Order not found");
291
+
292
  $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
293
+
294
  $merge_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
295
+
296
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
297
+
298
  //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
299
+
300
  //$this->_logger->debugXml($order_xml);
301
+
302
  if ($request_only)
303
  $this->_logger->setDebugExecuteMode('request_only');
304
  else
305
  $this->_logger->setDebugExecuteMode('full');
306
+
307
  Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
308
+
309
  $this->_output = "<h2>Full Order Diagnostic Results</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
310
+
311
  if (!$request_only)
312
  {
313
  $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
314
  }
315
+
316
  return true;
317
  }
318
+
319
  private function customFields()
320
  {
321
  $order = $this->getOrder();
322
+
323
  if ($order == null)
324
  return $this->setFailure("Order not found");
325
+
326
  $this->debugHeader('Custom Fields Diagnostic Starting');
327
+
328
  $customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
329
+
330
  $this->debugHeader('Customer Related Merge Vars',1);
331
+
332
  $customer_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
333
+
334
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
335
+
336
  //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
337
+
338
  //$this->_logger->debugXml($order_xml);
339
+
340
  $this->_output = "<h2>Custom Fields Diagnostic Results</h2><h3>Customer Fields</h3>" . $this->arrayToTable($customer_vars);
341
  $this->_output .= "<br /><h3>Order Fields</h3>" . $this->arrayToTable($merge_vars);
342
+
343
  return true;
344
  }
345
+
346
  private function abandonedUrl()
347
  {
348
  $quote = $this->getQuote();
349
+
350
  if ($quote == null)
351
  return $this->setFailure("Quote not found");
352
+
353
  $this->debugHeader('Abandoned URL');
354
+
355
  //$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
356
+
357
  //$this->debugHeader('Customer Related Merge Vars',1);
358
+
359
  $url = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
360
+
361
  $this->_output = "<h2>Abandoned Cart Url (Restore Cart)</h2><p>Click on the link to test it (opens in a new window and won't replace customer cart data)</p>URL: <a target='_blank' href='{$url}&test_mode=true'>{$url}</a>";
362
+
363
  return true;
364
  }
365
+
366
  private function abandonedCustomFields()
367
  {
368
  $quote = $this->getQuote();
369
+
370
  if ($quote == null)
371
  return $this->setFailure("Quote not found");
372
+
373
  $this->debugHeader('Custom Fields Diagnostic Starting');
374
+
375
  $abandonedDate = $quote->getUpdatedAt();
376
+
377
  $merge_vars = array();
378
+
379
  $merge_vars['FirstName'] = $quote->getData('customer_firstname');
380
  $merge_vars['LastName'] = $quote->getData('customer_lastname');
381
+
382
  $merge_vars['AbandonedDate'] = $abandonedDate;
383
  $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
384
+
385
  // Setup sequence for this store
386
  Mage::helper('emaildirect/abandoned')->setupSequence();
387
+
388
  Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
389
+
390
  $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
391
+
392
+
393
+
394
  if (Mage::helper('emaildirect')->config('save_latest_order'))
395
  {
396
  $this->debug("Processing Last Order");
397
  $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
398
+
399
  if ($order != null)
400
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
401
  else
402
  $this->debug("Order not found");
403
  //$this->_log("Order not found");
404
  }
405
+
406
+
407
  //$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
408
+
409
  //$this->_logger->debugXml($order_xml);
410
+
411
  $this->_output = "<h2>Custom Fields Diagnostic Results</h2>";
412
  $this->_output .= "<br /><h3>Fields</h3>" . $this->arrayToTable($merge_vars);
413
+
414
  return true;
415
  }
416
 
417
  private function getQuoteEmail($quote)
418
  {
419
  $abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart($quote->getId());
420
+
421
  return $abandoned_cart->getEmail();
422
  }
423
 
424
  private function abandonedFull($request_only = true)
425
  {
426
  $quote = $this->getQuote();
427
+
428
  if ($quote == null)
429
  return $this->setFailure("Quote not found");
430
+
431
  $abandonedDate = $quote->getUpdatedAt();
432
+
433
  $email = $quote->getCustomerEmail();
434
+
435
  if ($email == null)
436
  $email = $this->getQuoteEmail($quote);
437
+
438
  $merge_vars = array();
439
+
440
  $merge_vars['FirstName'] = $quote->getData('customer_firstname');
441
  $merge_vars['LastName'] = $quote->getData('customer_lastname');
442
+
443
  $merge_vars['AbandonedDate'] = $abandonedDate;
444
  $merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
445
+
446
  // Setup sequence for this store
447
  Mage::helper('emaildirect/abandoned')->setupSequence();
448
+
449
  Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
450
+
451
  $merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
452
+
453
  if (Mage::helper('emaildirect')->config('save_latest_order'))
454
  {
455
  $this->debug("Processing Last Order");
456
  $order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
457
+
458
  if ($order != null)
459
  $merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
460
  else
461
  $this->debug("Order not found");
462
  //$this->_log("Order not found");
463
  }
464
+
465
  $xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
466
+
467
  if ($request_only)
468
  $this->_logger->setDebugExecuteMode('request_only');
469
  else
470
  $this->_logger->setDebugExecuteMode('full');
471
+
472
  $xml = "<Subscribers>{$xml}</Subscribers>";
473
+
474
  //Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
475
  $rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
476
+
477
  $this->_output = "<h2>Abandoned Cart Xml</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
478
+
479
  if (!$request_only)
480
  {
481
  $this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
482
  }
483
  return true;
484
  }
485
+
486
  private function trackingInfo()
487
  {
488
+
489
  return true;
490
  }
491
  }
app/code/community/EmailDirect/Integration/controllers/Admin/ExportController.php CHANGED
@@ -3,9 +3,14 @@
3
  class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected $_min_category_level = 2;
6
-
7
  protected $_export_type = null;
8
 
 
 
 
 
 
9
  public function countAction()
10
  {
11
  $count = "Unknown";
@@ -15,46 +20,46 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
15
  $to = $this->getRequest()->getParam('to');
16
  $include = $this->getRequest()->getParam('include');
17
  $store = Mage::app()->getRequest()->getParam('store');
18
-
19
  $orders = Mage::helper('emaildirect')->getOrderExportCollection($from, $to, $include, $store);
20
-
21
  $count = $orders->getSize();
22
  }
23
  catch (Exception $e)
24
  {
25
  Mage::logException($e);
26
  }
27
-
28
  $this->getResponse()->setBody($count);
29
  }
30
 
31
  private function setConfigValue($name)
32
  {
33
  $old_value = Mage::helper('emaildirect')->exportConfig($name);
34
-
35
  $new_value = $this->getRequest()->getParam($name);
36
-
37
  if ($new_value != '' && $new_value != $old_value)
38
  {
39
  Mage::getConfig()->saveConfig("emaildirect/export/{$name}", $new_value,"default","default");
40
  return true;
41
  }
42
-
43
  return false;
44
  }
45
 
46
  private function setConfiguration()
47
  {
48
  $config_options = array('include_disabled','include_already_sent');
49
-
50
  $changed = false;
51
-
52
  foreach ($config_options as $option)
53
  {
54
  if ($this->setConfigValue($option))
55
  $changed = true;
56
  }
57
-
58
  if ($changed)
59
  {
60
  Mage::getConfig()->cleanCache();
@@ -67,51 +72,51 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
67
  {
68
  // Update export configuration options if changed before button click
69
  $this->setConfiguration();
70
-
71
  $this->loadLayout();
72
  $this->renderLayout();
73
  }
74
-
75
  public function ordersAction()
76
  {
77
  // Update export configuration options if changed before button click
78
  $this->setConfiguration();
79
-
80
  $this->loadLayout();
81
  $this->renderLayout();
82
  }
83
-
84
  private function getCategoryPath($category)
85
  {
86
  $name = "";
87
-
88
  while ($category->parent_id != 0 && $category->level >= $this->_min_category_level)
89
  {
90
  if ($name != "")
91
  $name = $category->getName() . "/{$name}";
92
  else
93
  $name = $category->getName();
94
-
95
  $category = $category->getParentCategory();
96
  }
97
-
98
  return $name;
99
  }
100
-
101
  private function getProductData($id)
102
  {
103
  $product = Mage::getModel('catalog/product')->load($id);
104
 
105
  $product_data = array($product->getName(), $product->getSku());
106
-
107
  $product_categories = $product->getCategoryCollection()->exportToArray();
108
-
109
  $category_data = array();
110
-
111
  foreach($product_categories as $cat)
112
  {
113
  $category = Mage::getModel('catalog/category')->load($cat['entity_id']);
114
-
115
  $category_data[] = $this->getCategoryPath($category);
116
  }
117
 
@@ -119,56 +124,56 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
119
  $product_data[] = implode(",",$category_data);
120
  else
121
  $product_data[] = "";
122
-
123
  return $product_data;
124
  }
125
-
126
  private function getOrderData($id)
127
  {
128
  $order = Mage::getModel('sales/order')->load($id);
129
-
130
  //EmailAddress, OrderNumber, ProductName, SKU, Quantity, PurchaseDate, UnitPrice
131
-
132
  $date = $order->getCreatedAt();
133
  $orderNum = $order->getIncrementId();
134
  $email = $order->getCustomerEmail();
135
-
136
  $items = $order->getAllItems();
137
-
138
  $order_data = array();
139
-
140
  if (is_array($items))
141
  {
142
  foreach($items as $item)
143
  {
144
-
145
  if ($item->getParentItemId() != null)
146
  continue;
147
-
148
  $row = array($email,$orderNum);
149
-
150
  $qty = (int)$item->getQtyOrdered();
151
  $name = $item->getName();
152
  $sku = $item->getSku();
153
  $price = $item->getPrice();
154
-
155
  $row[] = $name;
156
  $row[] = $sku;
157
  $row[] = $qty;
158
  $row[] = $date;
159
  $row[] = $price;
160
-
161
  $order_data[] = $row;
162
  }
163
-
164
  }
165
  return $order_data;
166
  }
167
-
168
  private function saveRow($fields,$name)
169
  {
170
  $file = Mage::helper('emaildirect')->getExportFileName($name);
171
-
172
  if (file_exists($file))
173
  {
174
  $fp = fopen($file, 'a');
@@ -179,30 +184,30 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
179
  $header_fields = array('Product Name','SKU','Root Category');
180
  else
181
  $header_fields = array('EmailAddress', 'OrderNumber', 'ProductName', 'SKU', 'Quantity', 'PurchaseDate', 'UnitPrice');
182
-
183
  $fp = fopen($file, 'w');
184
  fputcsv($fp, $header_fields, ',','"');
185
  }
186
 
187
  fputcsv($fp, $fields, ',','"');
188
-
189
  fclose($fp);
190
  }
191
-
192
  private function getMinCategoryLevel()
193
  {
194
  $roots = Mage::getModel('catalog/category')->load(1)->getChildren();
195
-
196
  if (strpos($roots,',') === FALSE)
197
  return 2;
198
  return 1;
199
  }
200
-
201
  private function getExportType()
202
  {
203
  if ($this->_export_type == null)
204
  $this->_export_type = $this->getRequest()->getParam('export_type', 'product');
205
-
206
  return $this->_export_type;
207
  }
208
 
@@ -210,17 +215,17 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
210
  {
211
  if ($this->getExportType() == 'product')
212
  return $this->batchRunProducts();
213
-
214
  return $this->batchRunOrders();
215
  }
216
-
217
  private function batchRunOrders()
218
  {
219
- if ($this->getRequest()->isPost())
220
  {
221
  $order_id = $this->getRequest()->getPost('id', 0);
222
  $file_name = $this->getRequest()->getPost('filename', 0);
223
-
224
  if (is_array($order_id))
225
  {
226
  foreach ($order_id as $id)
@@ -232,7 +237,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
232
  $this->saveRow($data_row,"emaildirect_orders_{$file_name}");
233
  }
234
  }
235
-
236
  $result = array(
237
  'savedRows' => count($order_id),
238
  'errors' => array()
@@ -246,7 +251,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
246
  {
247
  $this->saveRow($data_row,"emaildirect_orders_{$file_name}");
248
  }
249
-
250
  $result = array(
251
  'savedRows' => 1,
252
  'errors' => array()
@@ -255,16 +260,16 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
255
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
256
  }
257
  }
258
-
259
  private function batchRunProducts()
260
  {
261
  $this->_min_category_level = $this->getMinCategoryLevel();
262
-
263
- if ($this->getRequest()->isPost())
264
  {
265
  $product_id = $this->getRequest()->getPost('id', 0);
266
  $file_name = $this->getRequest()->getPost('filename', 0);
267
-
268
  if (is_array($product_id))
269
  {
270
  foreach ($product_id as $id)
@@ -273,7 +278,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
273
 
274
  $this->saveRow($csv_data,"emaildirect_products_{$file_name}");
275
  }
276
-
277
  $result = array(
278
  'savedRows' => count($product_id),
279
  'errors' => array()
@@ -284,7 +289,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
284
  $csv_data = $this->getProductData($product_id);
285
 
286
  $this->saveRow($csv_data,"emaildirect_products_{$file_name}");
287
-
288
  $result = array(
289
  'savedRows' => 1,
290
  'errors' => array()
@@ -293,11 +298,11 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
293
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
294
  }
295
  }
296
-
297
  public function downloadAction()
298
  {
299
  $file_name = "emaildirect_" . $this->getExportType() . "s_" . $this->getRequest()->getParam('filename');
300
-
301
  $file = Mage::helper('emaildirect')->getExportFileName($file_name);
302
 
303
  $this->_prepareDownloadResponse(Mage::helper('emaildirect')->getExportFileName($file_name,false), file_get_contents($file));
@@ -305,7 +310,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
305
 
306
  public function batchFinishAction()
307
  {
308
- if ($this->getRequest()->isPost())
309
  {
310
  $file_name = $this->getRequest()->getPost('filename', 0);
311
  $store = $this->getRequest()->getPost('store', 0);
@@ -316,22 +321,22 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
316
  }
317
 
318
  $url = $this->getUrl('*/*/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
319
-
320
  $result = array(
321
  'download_link' => $url,
322
  );
323
-
324
  $ed_url = $this->getUrl('ed_integration/export/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
325
  $api = Mage::getSingleton('emaildirect/wrapper_ftp');
326
  $rc = $api->upload($ed_url,"magento_" . $this->getExportType() . "s_{$file_name}.csv");
327
-
328
  if (isset($rc->ErrorCode))
329
  $result['error'] = "EmailDirect Error: (" . (string) $rc->ErrorCode . "): " . (string)$rc->Message;
330
-
331
  if ($store != 0)
332
  Mage::app()->setCurrentStore($starting_store);
333
-
334
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
335
- }
336
  }
337
  }
3
  class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Controller_Action
4
  {
5
  protected $_min_category_level = 2;
6
+
7
  protected $_export_type = null;
8
 
9
+ protected function _isAllowed()
10
+ {
11
+ return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_export');
12
+ }
13
+
14
  public function countAction()
15
  {
16
  $count = "Unknown";
20
  $to = $this->getRequest()->getParam('to');
21
  $include = $this->getRequest()->getParam('include');
22
  $store = Mage::app()->getRequest()->getParam('store');
23
+
24
  $orders = Mage::helper('emaildirect')->getOrderExportCollection($from, $to, $include, $store);
25
+
26
  $count = $orders->getSize();
27
  }
28
  catch (Exception $e)
29
  {
30
  Mage::logException($e);
31
  }
32
+
33
  $this->getResponse()->setBody($count);
34
  }
35
 
36
  private function setConfigValue($name)
37
  {
38
  $old_value = Mage::helper('emaildirect')->exportConfig($name);
39
+
40
  $new_value = $this->getRequest()->getParam($name);
41
+
42
  if ($new_value != '' && $new_value != $old_value)
43
  {
44
  Mage::getConfig()->saveConfig("emaildirect/export/{$name}", $new_value,"default","default");
45
  return true;
46
  }
47
+
48
  return false;
49
  }
50
 
51
  private function setConfiguration()
52
  {
53
  $config_options = array('include_disabled','include_already_sent');
54
+
55
  $changed = false;
56
+
57
  foreach ($config_options as $option)
58
  {
59
  if ($this->setConfigValue($option))
60
  $changed = true;
61
  }
62
+
63
  if ($changed)
64
  {
65
  Mage::getConfig()->cleanCache();
72
  {
73
  // Update export configuration options if changed before button click
74
  $this->setConfiguration();
75
+
76
  $this->loadLayout();
77
  $this->renderLayout();
78
  }
79
+
80
  public function ordersAction()
81
  {
82
  // Update export configuration options if changed before button click
83
  $this->setConfiguration();
84
+
85
  $this->loadLayout();
86
  $this->renderLayout();
87
  }
88
+
89
  private function getCategoryPath($category)
90
  {
91
  $name = "";
92
+
93
  while ($category->parent_id != 0 && $category->level >= $this->_min_category_level)
94
  {
95
  if ($name != "")
96
  $name = $category->getName() . "/{$name}";
97
  else
98
  $name = $category->getName();
99
+
100
  $category = $category->getParentCategory();
101
  }
102
+
103
  return $name;
104
  }
105
+
106
  private function getProductData($id)
107
  {
108
  $product = Mage::getModel('catalog/product')->load($id);
109
 
110
  $product_data = array($product->getName(), $product->getSku());
111
+
112
  $product_categories = $product->getCategoryCollection()->exportToArray();
113
+
114
  $category_data = array();
115
+
116
  foreach($product_categories as $cat)
117
  {
118
  $category = Mage::getModel('catalog/category')->load($cat['entity_id']);
119
+
120
  $category_data[] = $this->getCategoryPath($category);
121
  }
122
 
124
  $product_data[] = implode(",",$category_data);
125
  else
126
  $product_data[] = "";
127
+
128
  return $product_data;
129
  }
130
+
131
  private function getOrderData($id)
132
  {
133
  $order = Mage::getModel('sales/order')->load($id);
134
+
135
  //EmailAddress, OrderNumber, ProductName, SKU, Quantity, PurchaseDate, UnitPrice
136
+
137
  $date = $order->getCreatedAt();
138
  $orderNum = $order->getIncrementId();
139
  $email = $order->getCustomerEmail();
140
+
141
  $items = $order->getAllItems();
142
+
143
  $order_data = array();
144
+
145
  if (is_array($items))
146
  {
147
  foreach($items as $item)
148
  {
149
+
150
  if ($item->getParentItemId() != null)
151
  continue;
152
+
153
  $row = array($email,$orderNum);
154
+
155
  $qty = (int)$item->getQtyOrdered();
156
  $name = $item->getName();
157
  $sku = $item->getSku();
158
  $price = $item->getPrice();
159
+
160
  $row[] = $name;
161
  $row[] = $sku;
162
  $row[] = $qty;
163
  $row[] = $date;
164
  $row[] = $price;
165
+
166
  $order_data[] = $row;
167
  }
168
+
169
  }
170
  return $order_data;
171
  }
172
+
173
  private function saveRow($fields,$name)
174
  {
175
  $file = Mage::helper('emaildirect')->getExportFileName($name);
176
+
177
  if (file_exists($file))
178
  {
179
  $fp = fopen($file, 'a');
184
  $header_fields = array('Product Name','SKU','Root Category');
185
  else
186
  $header_fields = array('EmailAddress', 'OrderNumber', 'ProductName', 'SKU', 'Quantity', 'PurchaseDate', 'UnitPrice');
187
+
188
  $fp = fopen($file, 'w');
189
  fputcsv($fp, $header_fields, ',','"');
190
  }
191
 
192
  fputcsv($fp, $fields, ',','"');
193
+
194
  fclose($fp);
195
  }
196
+
197
  private function getMinCategoryLevel()
198
  {
199
  $roots = Mage::getModel('catalog/category')->load(1)->getChildren();
200
+
201
  if (strpos($roots,',') === FALSE)
202
  return 2;
203
  return 1;
204
  }
205
+
206
  private function getExportType()
207
  {
208
  if ($this->_export_type == null)
209
  $this->_export_type = $this->getRequest()->getParam('export_type', 'product');
210
+
211
  return $this->_export_type;
212
  }
213
 
215
  {
216
  if ($this->getExportType() == 'product')
217
  return $this->batchRunProducts();
218
+
219
  return $this->batchRunOrders();
220
  }
221
+
222
  private function batchRunOrders()
223
  {
224
+ if ($this->getRequest()->isPost())
225
  {
226
  $order_id = $this->getRequest()->getPost('id', 0);
227
  $file_name = $this->getRequest()->getPost('filename', 0);
228
+
229
  if (is_array($order_id))
230
  {
231
  foreach ($order_id as $id)
237
  $this->saveRow($data_row,"emaildirect_orders_{$file_name}");
238
  }
239
  }
240
+
241
  $result = array(
242
  'savedRows' => count($order_id),
243
  'errors' => array()
251
  {
252
  $this->saveRow($data_row,"emaildirect_orders_{$file_name}");
253
  }
254
+
255
  $result = array(
256
  'savedRows' => 1,
257
  'errors' => array()
260
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
261
  }
262
  }
263
+
264
  private function batchRunProducts()
265
  {
266
  $this->_min_category_level = $this->getMinCategoryLevel();
267
+
268
+ if ($this->getRequest()->isPost())
269
  {
270
  $product_id = $this->getRequest()->getPost('id', 0);
271
  $file_name = $this->getRequest()->getPost('filename', 0);
272
+
273
  if (is_array($product_id))
274
  {
275
  foreach ($product_id as $id)
278
 
279
  $this->saveRow($csv_data,"emaildirect_products_{$file_name}");
280
  }
281
+
282
  $result = array(
283
  'savedRows' => count($product_id),
284
  'errors' => array()
289
  $csv_data = $this->getProductData($product_id);
290
 
291
  $this->saveRow($csv_data,"emaildirect_products_{$file_name}");
292
+
293
  $result = array(
294
  'savedRows' => 1,
295
  'errors' => array()
298
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
299
  }
300
  }
301
+
302
  public function downloadAction()
303
  {
304
  $file_name = "emaildirect_" . $this->getExportType() . "s_" . $this->getRequest()->getParam('filename');
305
+
306
  $file = Mage::helper('emaildirect')->getExportFileName($file_name);
307
 
308
  $this->_prepareDownloadResponse(Mage::helper('emaildirect')->getExportFileName($file_name,false), file_get_contents($file));
310
 
311
  public function batchFinishAction()
312
  {
313
+ if ($this->getRequest()->isPost())
314
  {
315
  $file_name = $this->getRequest()->getPost('filename', 0);
316
  $store = $this->getRequest()->getPost('store', 0);
321
  }
322
 
323
  $url = $this->getUrl('*/*/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
324
+
325
  $result = array(
326
  'download_link' => $url,
327
  );
328
+
329
  $ed_url = $this->getUrl('ed_integration/export/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
330
  $api = Mage::getSingleton('emaildirect/wrapper_ftp');
331
  $rc = $api->upload($ed_url,"magento_" . $this->getExportType() . "s_{$file_name}.csv");
332
+
333
  if (isset($rc->ErrorCode))
334
  $result['error'] = "EmailDirect Error: (" . (string) $rc->ErrorCode . "): " . (string)$rc->Message;
335
+
336
  if ($store != 0)
337
  Mage::app()->setCurrentStore($starting_store);
338
+
339
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
340
+ }
341
  }
342
  }
app/code/community/EmailDirect/Integration/controllers/Admin/TroubleshootingController.php CHANGED
@@ -5,6 +5,11 @@ class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Admin
5
  private $_output = array();
6
  private $_config = null;
7
 
 
 
 
 
 
8
  public function indexAction()
9
  {
10
  $this->loadLayout();
5
  private $_output = array();
6
  private $_config = null;
7
 
8
+ protected function _isAllowed()
9
+ {
10
+ return Mage::getSingleton('admin/session')->isAllowed('emaildirect/emaildirect_troubleshooting');
11
+ }
12
+
13
  public function indexAction()
14
  {
15
  $this->loadLayout();
app/code/community/EmailDirect/Integration/etc/adminhtml.xml CHANGED
@@ -27,6 +27,26 @@
27
  <resources>
28
  <admin>
29
  <children>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  <system>
31
  <children>
32
  <config>
27
  <resources>
28
  <admin>
29
  <children>
30
+ <emaildirect>
31
+ <title>EmailDirect</title>
32
+ <children>
33
+ <emaildirect_abandoned module='emaildirect'>
34
+ <title>Abandoned Carts</title>
35
+ </emaildirect_abandoned>
36
+ <emaildirect_troubleshooting module='emaildirect'>
37
+ <title>Troubleshooting</title>
38
+ </emaildirect_troubleshooting>
39
+ <emaildirect_diagnostics>
40
+ <title>Diagnostics</title>
41
+ </emaildirect_diagnostics>
42
+ <emaildirect_export>
43
+ <title>Export</title>
44
+ </emaildirect_export>
45
+ <emaildirect_config>
46
+ <title>Configuration Link</title>
47
+ </emaildirect_config>
48
+ </children>
49
+ </emaildirect>
50
  <system>
51
  <children>
52
  <config>
app/code/community/EmailDirect/Integration/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <EmailDirect_Integration>
5
- <version>2.0.14</version>
6
  </EmailDirect_Integration>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <EmailDirect_Integration>
5
+ <version>2.0.15</version>
6
  </EmailDirect_Integration>
7
  </modules>
8
  <global>
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>EmailDirect_Integration</name>
4
- <version>2.0.14</version>
5
  <stability>stable</stability>
6
  <license/>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>EmailDirect integration for magento</summary>
10
  <description>EmailDirect integration for magento</description>
11
- <notes>Cron warning fix</notes>
 
 
12
  <authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
13
- <date>2015-07-30</date>
14
- <time>04:47:36</time>
15
- <contents><target name="magecommunity"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Abandoned"><dir name="Details"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="8706487c8f465a5ce762cd923258bb35"/></dir><file name="Cart.php" hash="09e9331f6c72157f581ad7135b7f147c"/><file name="Diagnostics.php" hash="eba18ce04ccb125ce4aa6ed5e473734a"/></dir><file name="Form.php" hash="dffc6e49eb95db2f83050706eee1fd55"/></dir><file name="Details.php" hash="9f98f4dd9ea741f9f7dd2eb018af0d7d"/><file name="Grid.php" hash="e0a15673636acb7e113fdf6e3bcd8879"/><file name="Status.php" hash="9a740fd8c63148532bbcf07d19f462df"/><file name="Tabs.php" hash="19e184e72777dfc5b0c35b7027a3e1cf"/></dir><dir name="Diagnostics"><dir name="Status"><file name="Abstract.php" hash="4a54d82d748f880fc5bb8263935ddc98"/></dir></dir><dir name="Order"><dir name="View"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="b4dd8410aa9ce649e603762d5d14f314"/></dir><file name="Diagnostics.php" hash="91bb6af0c9a0e6f41d2575651e8a59ef"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="25796ead15053f86d7adcd551b8b49e7"/></dir><dir name="Form"><dir name="Field"><dir name="Export"><file name="Orders.php" hash="5b101fadb6a64044b276eb07b21cf0a5"/><file name="Products.php" hash="32e13d4b7250890bf84aba87f25de03c"/><file name="Range.php" hash="4adac96fa53fa8e1449bae943a8cca80"/></dir><dir name="Signup"><file name="Test.php" hash="3b773dda25c62bc8cb28031931d67f9f"/></dir><file name="Addressmapfields.php" hash="97b75c8340d561e863a3985ad73ce228"/><file name="Api.php" hash="77dabda85973dc72227937397392c411"/><file name="Common.php" hash="6a86cce53f6df6857ea79241fa281939"/><file name="Diagnostics.php" hash="7efe5c8b90db90e9c512842388d3263d"/><file name="Info.php" hash="246de52ea5d2349ecd7f103cbba8cb8f"/><file name="Logging.php" hash="53b0b7d28d2680e479bfa89b6884802d"/><file name="Mapfields.php" hash="16894c5d76df1293e63128e349700e05"/><file name="Note.php" hash="ef99a474bbc3a828c7a618132a80fe66"/><file name="Shippingmapfields.php" hash="589a74260f394a5eae1b57ca89a74a8b"/></dir></dir></dir><dir name="Convert"><dir name="Profile"><dir name="Export"><file name="Orders.php" hash="947af2b0d8e3f7bc47c47b32cd434f18"/><file name="Products.php" hash="3f93e4789dbeb6710cd2742587d61726"/></dir><file name="Export.php" hash="ba879607ac0693e9db6251bbbc1676a1"/></dir></dir></dir><dir name="Troubleshooting"><dir name="View"><dir name="Tab"><file name="Download.php" hash="619916677df7c833e559aae74dae2aa0"/><file name="Help.php" hash="ad4007af59687653f4d6692f2b42b31d"/><file name="Info.php" hash="be5c15da32ef0e042c53d8ac007f8bd6"/><file name="Log.php" hash="a61e66923a287beee5910511b7282a0a"/><file name="Settings.php" hash="f15e57cdc6539c4da84042c98f0ab25c"/><file name="Submit.php" hash="81ae0e0636b66a329cf8f39939788d1d"/></dir><file name="Form.php" hash="e527a3a2335b109c48a69f06c1b0d01f"/></dir><file name="Status.php" hash="d140afcad424ff531bebb412539d6f1c"/><file name="Tabs.php" hash="5d4168cec60212beb87997e6391282e9"/><file name="View.php" hash="47efa0685db07fb73544ad477a0e2c85"/></dir><file name="Abandoned.php" hash="6e51c09f3c9d491f14ee6ecfb7f33f08"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="a49c1e7f612d379e6509658a56f53d7d"/></dir><dir name="Customer"><dir name="Account"><file name="Lists.php" hash="e1b911c77a78995d3b3390363926ae5a"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><dir name="Abandoned"><file name="Minutes.php" hash="e311f6de480fd4b63aee7f46ea412372"/></dir><file name="Action.php" hash="bf2243f50c9c6dafca26a5bcb889f372"/></dir></dir></dir></dir><file name="Capture.php" hash="e44034ad875957a566d3ac89abb408ed"/><file name="Signup.php" hash="c51c2e5cb93978170a65dc4b69d197bf"/></dir><dir name="Controller"><dir name="Front"><file name="Abstract.php" hash="48d93179d5f8a6b416fd82dd8763daf9"/></dir></dir><dir name="Helper"><file name="Abandoned.php" hash="7910bd8db8a030ae22adae9469d91fe7"/><file name="Data.php" hash="9d3e0377de044475d7f6e251c56bd715"/><file name="Diagnostic.php" hash="68867fd906405a6be98e14c1568437b6"/><file name="Fields.php" hash="5fa737c45be172f55fe965975aa6db52"/><file name="Order.php" hash="e4683daf9827a5cb47f17b0104509102"/><file name="Troubleshooting.php" hash="cf422b72b445a86326e73cbc6f506e18"/></dir><dir name="Model"><dir name="Abandoned"><file name="Observer.php" hash="00f8e4f8186a6c800df932b74b147844"/></dir><dir name="Configuration"><file name="Observer.php" hash="9a188656d5f7d73c91bf4221cc6e4aac"/></dir><dir name="Customer"><file name="Observer.php" hash="cef8d32ba304c51b448343555ea6a066"/></dir><dir name="Mysql4"><dir name="Abandoned"><file name="Collection.php" hash="1a9129267942a98ac3830ceaf714c2ab"/></dir><dir name="Order"><file name="Collection.php" hash="43d343562cf7e54f1b36315aa5d1d4a7"/></dir><dir name="Session"><file name="Collection.php" hash="7d6a8283fdbc1207d709e2bbbc78906d"/></dir><file name="Abandoned.php" hash="485b3771906783d383de75ae9761e55c"/><file name="Order.php" hash="8d538a5737095a1ba0ad448c027b3afb"/><file name="Session.php" hash="516eeeb28038416dc885ed7af6a8a8b0"/></dir><dir name="Newsletter"><file name="Observer.php" hash="d3181ac610e920dead78fff5656f65de"/></dir><dir name="Observer"><file name="Abstract.php" hash="1db39dc86bed51af1d2a3b4df50099bd"/></dir><dir name="Order"><file name="Observer.php" hash="17cd32f5111f0e423ac3a5d8dd62b256"/></dir><dir name="Resource"><file name="Setup.php" hash="83ba3645f702694355f14181546db330"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="96c51fc5c0b947750be4e612e32c83ab"/></dir><dir name="Send"><file name="Field.php" hash="8ecffa8ccce40f3b2db6513b24eb9200"/></dir><dir name="Signup"><file name="Opacity.php" hash="8eabed4c72e7347f0376c3d4cc1023a7"/><file name="Recurrence.php" hash="e11200bbc204b00486c373d8a4e6675e"/></dir><file name="Abandoned.php" hash="9881811b94f38be90bd20a99951a1903"/><file name="Abandonedlist.php" hash="b81d7f2cb03b8482debea5cd6a2bd1c5"/><file name="Additionallist.php" hash="9f109ab04c7ae7832887572b26868e3a"/><file name="Checkoutsubscribe.php" hash="fd90252a1f19649a420dae136ad2a2ba"/><file name="List.php" hash="84c1c8e27f579d5d33992fcb15202748"/><file name="Publication.php" hash="a5bc0192605fc558fe59b37cc0462825"/><file name="Sequence.php" hash="a599f218882d2cfc68dfcf4d58a98a41"/><file name="Source.php" hash="44815cbf4ac6443032df1e7d9c4cadef"/><file name="States.php" hash="a746affc786d8165a98801e68cbf80ab"/><file name="Statuses.php" hash="9844a7a9c3b5c68df45c8f6c518acf16"/><file name="Time.php" hash="8acbb5cb33e66de1e408cf55d17a9398"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="ef81d36a7276737f2d0aa1a5d783a83b"/><file name="Abstract.php" hash="9e97ce6a12e0d074921bb3a1391f3648"/><file name="Database.php" hash="3cceb467358d13584baff58c043762ec"/><file name="Execute.php" hash="e38737d197b2ccd6700ec87ec1836456"/><file name="Ftp.php" hash="d5335cfb68f99761d6902dd390a3d7a8"/><file name="Lists.php" hash="425d64b9256bbdbafa899c4138e78368"/><file name="Orders.php" hash="fa1c481787b0f994c1c1f704f73d6741"/><file name="Publications.php" hash="1bebd172a8bba669d075f09589785652"/><file name="Sources.php" hash="c6caf0274f7d0c50114324bc47a490c4"/><file name="Subscribers.php" hash="53a2c24db3936b7768ae6a8a8f98f394"/><file name="Wishlist.php" hash="2ceb111bbeaa06c4f13f61281aaa5b5e"/></dir><file name="Abandoned.php" hash="b5e001d0bc059c66ef38130b7d6dcec0"/><file name="Observer.php" hash="37a2d4c63e4ef75d535426a8670764f1"/><file name="Order.php" hash="b21426543cd46f799cd0743525120fb8"/><file name="Session.php" hash="c56ecf779dbfb2dae0030935af31911a"/></dir><dir name="controllers"><dir name="Admin"><file name="AbandonedController.php" hash="7366ad52662d5494e1b0e65988ee1dc7"/><file name="DiagnosticController.php" hash="aa0f4e9bf3c22124c61c3f46729372a9"/><file name="ExportController.php" hash="3ff11560de77d99bccb2cc257d14b8ab"/><file name="TroubleshootingController.php" hash="52847165f3c24c955832455e2c27a7a6"/></dir><dir name="Customer"><file name="AccountController.php" hash="91942750c1c3d20dc31159c1ffbe8200"/></dir><file name="AbandonedController.php" hash="39c9d1a72bca9369a3121ac15f68558e"/><file name="CaptureController.php" hash="89e043bb3864617a062e915d2209dcf4"/><file name="ExportController.php" hash="7ca147debc5c1436b3bf2d9501592f33"/><file name="SignupController.php" hash="fe975d44cc11f1270d34d9d82c7d4be9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5501d4faf3da5ba1e380017b9608e1e8"/><file name="cache.xml" hash="9f7ad708d6507ec880473689e70ef314"/><file name="config.xml" hash="d7b3fcc04cf6597d1e7258655974b970"/><file name="system.xml" hash="38f8dfb41b5fcc55490daf4d7c6e147c"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-2.0.0.php" hash="bdc5e09fe949b36534c50c85fd198e66"/><file name="mysql4-upgrade-1.5.8-2.0.0.php" hash="8f33c7f6dca96cfa8210ec1fe016d95b"/><file name="mysql4-upgrade-2.0.0-2.0.14.php" hash="ead09ac13bb7798b08776dda5948f91d"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="61d3d7b29b97f75023f2232cae6eb0c1"/><file name="logo.png" hash="2e7e39ced387c798ef27b77dd69f073e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="emaildirect.css" hash="c9caf9ea168efa3b0d6f4b881bcf093c"/><file name="integration.js" hash="7980204c0f594b180b9fa336954c9229"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="7767cd483e20d1930c0f1d79fee03b2a"/></dir><dir name="template"><dir name="emaildirect"><dir name="abandoned"><dir name="details"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="24829356b9dba966e53fb1cfe0f192b6"/></dir><file name="cart.phtml" hash="be7ca2b147fc836c2ca547b290ffe841"/></dir><file name="form.phtml" hash="60633d212382770e99d11d24ae919e47"/></dir><file name="details.phtml" hash="9d467b97a2d773aec950bea7061c6730"/><file name="status.phtml" hash="9e7723dc1fe5f8693345db9cc7cda808"/></dir><dir name="order"><dir name="view"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="a3bdecb1ec08903dd1b61dce6992e190"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="176f3ddb8ea667a64a06967351526f3c"/></dir><dir name="form"><dir name="field"><dir name="export"><file name="date_range.phtml" hash="6a37b1e58456e1dcec734c48deb8c0c1"/><file name="orders.phtml" hash="1dfa19a712b18d2c95c2f4b938f6acef"/><file name="products.phtml" hash="098b7b21b6424c2a4eea26194883a623"/></dir><dir name="signup"><file name="test.phtml" hash="636501cd90c6ab4231bea54efb16b2ff"/></dir><file name="api.phtml" hash="468f33b2a23dbe2828489c1620000c74"/><file name="array.phtml" hash="5415eeff311735624354468c886d39b5"/><file name="diagnostics.phtml" hash="3327dba9e03362077f7562e3045180b7"/><file name="info.phtml" hash="44ab79fdfc5fb5b0cd7e15e79bfd9502"/><file name="logging.phtml" hash="3c7bd2a6f48a84efca1d0f1e75097a8a"/><file name="note.phtml" hash="6625a3771ba10daba5ded5570574716f"/></dir></dir><file name="setup_check.phtml" hash="1814302f58a15fb1629446e074a7e1e0"/></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="c829eeccb120ffe4c0b9f0ddf9c7ff9a"/></dir></dir></dir><dir name="troubleshooting"><dir name="view"><dir name="tab"><file name="download.phtml" hash="d5701a0af7a8f308467fa5552d0de6b2"/><file name="help.phtml" hash="ce11f0fb8f19a00d950266840b4ec3ce"/><file name="info.phtml" hash="bd19bb1072ce1d60a4fb7bda660a0ce7"/><file name="log.phtml" hash="724a65165770bc92ed08ea32d20c1fe7"/><file name="settings.phtml" hash="56cea7faf49b815ac8bd66896130c58c"/><file name="submit.phtml" hash="0d7df80ddbd24e499275315d91fbfd58"/></dir><file name="form.phtml" hash="d2338bfe3598e9315ca8f5ac8d9b5516"/></dir><file name="status.phtml" hash="fac61e17efe7bd4cf67a47eb67786496"/><file name="view.phtml" hash="6ddfc8c6efe25d30e63f792b19a95c84"/></dir><file name="diagnostics.phtml" hash="f1f43a89824cad9f39e599df21ac44b4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="8cb8652ad2505bb6f0c5e80d7be60109"/></dir><dir name="template"><dir name="emaildirect"><dir name="capture"><file name="email.phtml" hash="fa273ff1a48a12eb386f58f3e3e78f66"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="d57eb93aab4e0f1d58f1ec8b9ed24c50"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="50ebf53c50e5e0419dd86a6d5faa2bf9"/></dir><file name="lists.phtml" hash="101ea6709a4355786917a6845b8d52aa"/></dir></dir><dir name="signup"><file name="form.phtml" hash="3d483079d29b79ad4daf306228120c0f"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="newsletter_subscr_success_emaildirect.html" hash="f6afb69d207bbc3f8920e7a72ac9dd07"/><file name="newsletter_unsub_success_emaildirect.html" hash="bd9f97e8f5485180d4420097b5200ef4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EmailDirect_Integration.xml" hash="90a441f2d0dff6c247f810274e8a76ab"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>EmailDirect_Integration</name>
4
+ <version>2.0.15</version>
5
  <stability>stable</stability>
6
  <license/>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>EmailDirect integration for magento</summary>
10
  <description>EmailDirect integration for magento</description>
11
+ <notes>Grouped product fixes.&#xD;
12
+ &#xD;
13
+ Permissions updated to allow access to admin pages for specific roles.</notes>
14
  <authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
15
+ <date>2015-08-03</date>
16
+ <time>21:17:56</time>
17
+ <contents><target name="magecommunity"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Abandoned"><dir name="Details"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="8706487c8f465a5ce762cd923258bb35"/></dir><file name="Cart.php" hash="09e9331f6c72157f581ad7135b7f147c"/><file name="Diagnostics.php" hash="eba18ce04ccb125ce4aa6ed5e473734a"/></dir><file name="Form.php" hash="dffc6e49eb95db2f83050706eee1fd55"/></dir><file name="Details.php" hash="9f98f4dd9ea741f9f7dd2eb018af0d7d"/><file name="Grid.php" hash="e0a15673636acb7e113fdf6e3bcd8879"/><file name="Status.php" hash="9a740fd8c63148532bbcf07d19f462df"/><file name="Tabs.php" hash="19e184e72777dfc5b0c35b7027a3e1cf"/></dir><dir name="Diagnostics"><dir name="Status"><file name="Abstract.php" hash="4a54d82d748f880fc5bb8263935ddc98"/></dir></dir><dir name="Order"><dir name="View"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="b4dd8410aa9ce649e603762d5d14f314"/></dir><file name="Diagnostics.php" hash="91bb6af0c9a0e6f41d2575651e8a59ef"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="25796ead15053f86d7adcd551b8b49e7"/></dir><dir name="Form"><dir name="Field"><dir name="Export"><file name="Orders.php" hash="5b101fadb6a64044b276eb07b21cf0a5"/><file name="Products.php" hash="32e13d4b7250890bf84aba87f25de03c"/><file name="Range.php" hash="4adac96fa53fa8e1449bae943a8cca80"/></dir><dir name="Signup"><file name="Test.php" hash="3b773dda25c62bc8cb28031931d67f9f"/></dir><file name="Addressmapfields.php" hash="97b75c8340d561e863a3985ad73ce228"/><file name="Api.php" hash="77dabda85973dc72227937397392c411"/><file name="Common.php" hash="6a86cce53f6df6857ea79241fa281939"/><file name="Diagnostics.php" hash="7efe5c8b90db90e9c512842388d3263d"/><file name="Info.php" hash="246de52ea5d2349ecd7f103cbba8cb8f"/><file name="Logging.php" hash="53b0b7d28d2680e479bfa89b6884802d"/><file name="Mapfields.php" hash="16894c5d76df1293e63128e349700e05"/><file name="Note.php" hash="ef99a474bbc3a828c7a618132a80fe66"/><file name="Shippingmapfields.php" hash="589a74260f394a5eae1b57ca89a74a8b"/></dir></dir></dir><dir name="Convert"><dir name="Profile"><dir name="Export"><file name="Orders.php" hash="947af2b0d8e3f7bc47c47b32cd434f18"/><file name="Products.php" hash="3f93e4789dbeb6710cd2742587d61726"/></dir><file name="Export.php" hash="ba879607ac0693e9db6251bbbc1676a1"/></dir></dir></dir><dir name="Troubleshooting"><dir name="View"><dir name="Tab"><file name="Download.php" hash="619916677df7c833e559aae74dae2aa0"/><file name="Help.php" hash="ad4007af59687653f4d6692f2b42b31d"/><file name="Info.php" hash="be5c15da32ef0e042c53d8ac007f8bd6"/><file name="Log.php" hash="a61e66923a287beee5910511b7282a0a"/><file name="Settings.php" hash="f15e57cdc6539c4da84042c98f0ab25c"/><file name="Submit.php" hash="81ae0e0636b66a329cf8f39939788d1d"/></dir><file name="Form.php" hash="e527a3a2335b109c48a69f06c1b0d01f"/></dir><file name="Status.php" hash="d140afcad424ff531bebb412539d6f1c"/><file name="Tabs.php" hash="5d4168cec60212beb87997e6391282e9"/><file name="View.php" hash="47efa0685db07fb73544ad477a0e2c85"/></dir><file name="Abandoned.php" hash="6e51c09f3c9d491f14ee6ecfb7f33f08"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="a49c1e7f612d379e6509658a56f53d7d"/></dir><dir name="Customer"><dir name="Account"><file name="Lists.php" hash="e1b911c77a78995d3b3390363926ae5a"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><dir name="Abandoned"><file name="Minutes.php" hash="e311f6de480fd4b63aee7f46ea412372"/></dir><file name="Action.php" hash="bf2243f50c9c6dafca26a5bcb889f372"/></dir></dir></dir></dir><file name="Capture.php" hash="e44034ad875957a566d3ac89abb408ed"/><file name="Signup.php" hash="c51c2e5cb93978170a65dc4b69d197bf"/></dir><dir name="Controller"><dir name="Front"><file name="Abstract.php" hash="48d93179d5f8a6b416fd82dd8763daf9"/></dir></dir><dir name="Helper"><file name="Abandoned.php" hash="7910bd8db8a030ae22adae9469d91fe7"/><file name="Data.php" hash="d85791021c4d296445e545dcc7c3eb85"/><file name="Diagnostic.php" hash="68867fd906405a6be98e14c1568437b6"/><file name="Fields.php" hash="5fa737c45be172f55fe965975aa6db52"/><file name="Order.php" hash="b87142e32a71a73d9d93a4c4f4a7c202"/><file name="Troubleshooting.php" hash="cf422b72b445a86326e73cbc6f506e18"/></dir><dir name="Model"><dir name="Abandoned"><file name="Observer.php" hash="00f8e4f8186a6c800df932b74b147844"/></dir><dir name="Configuration"><file name="Observer.php" hash="9a188656d5f7d73c91bf4221cc6e4aac"/></dir><dir name="Customer"><file name="Observer.php" hash="cef8d32ba304c51b448343555ea6a066"/></dir><dir name="Mysql4"><dir name="Abandoned"><file name="Collection.php" hash="1a9129267942a98ac3830ceaf714c2ab"/></dir><dir name="Order"><file name="Collection.php" hash="43d343562cf7e54f1b36315aa5d1d4a7"/></dir><dir name="Session"><file name="Collection.php" hash="7d6a8283fdbc1207d709e2bbbc78906d"/></dir><file name="Abandoned.php" hash="485b3771906783d383de75ae9761e55c"/><file name="Order.php" hash="8d538a5737095a1ba0ad448c027b3afb"/><file name="Session.php" hash="516eeeb28038416dc885ed7af6a8a8b0"/></dir><dir name="Newsletter"><file name="Observer.php" hash="d3181ac610e920dead78fff5656f65de"/></dir><dir name="Observer"><file name="Abstract.php" hash="1db39dc86bed51af1d2a3b4df50099bd"/></dir><dir name="Order"><file name="Observer.php" hash="17cd32f5111f0e423ac3a5d8dd62b256"/></dir><dir name="Resource"><file name="Setup.php" hash="2b4fc64eaafbd5f41f95f219871275df"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="96c51fc5c0b947750be4e612e32c83ab"/></dir><dir name="Send"><file name="Field.php" hash="8ecffa8ccce40f3b2db6513b24eb9200"/></dir><dir name="Signup"><file name="Opacity.php" hash="8eabed4c72e7347f0376c3d4cc1023a7"/><file name="Recurrence.php" hash="e11200bbc204b00486c373d8a4e6675e"/></dir><file name="Abandoned.php" hash="9881811b94f38be90bd20a99951a1903"/><file name="Abandonedlist.php" hash="b81d7f2cb03b8482debea5cd6a2bd1c5"/><file name="Additionallist.php" hash="9f109ab04c7ae7832887572b26868e3a"/><file name="Checkoutsubscribe.php" hash="fd90252a1f19649a420dae136ad2a2ba"/><file name="List.php" hash="84c1c8e27f579d5d33992fcb15202748"/><file name="Publication.php" hash="a5bc0192605fc558fe59b37cc0462825"/><file name="Sequence.php" hash="a599f218882d2cfc68dfcf4d58a98a41"/><file name="Source.php" hash="44815cbf4ac6443032df1e7d9c4cadef"/><file name="States.php" hash="a746affc786d8165a98801e68cbf80ab"/><file name="Statuses.php" hash="9844a7a9c3b5c68df45c8f6c518acf16"/><file name="Time.php" hash="8acbb5cb33e66de1e408cf55d17a9398"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="ef81d36a7276737f2d0aa1a5d783a83b"/><file name="Abstract.php" hash="9e97ce6a12e0d074921bb3a1391f3648"/><file name="Database.php" hash="3cceb467358d13584baff58c043762ec"/><file name="Execute.php" hash="e38737d197b2ccd6700ec87ec1836456"/><file name="Ftp.php" hash="d5335cfb68f99761d6902dd390a3d7a8"/><file name="Lists.php" hash="425d64b9256bbdbafa899c4138e78368"/><file name="Orders.php" hash="fa1c481787b0f994c1c1f704f73d6741"/><file name="Publications.php" hash="1bebd172a8bba669d075f09589785652"/><file name="Sources.php" hash="c6caf0274f7d0c50114324bc47a490c4"/><file name="Subscribers.php" hash="53a2c24db3936b7768ae6a8a8f98f394"/><file name="Wishlist.php" hash="2ceb111bbeaa06c4f13f61281aaa5b5e"/></dir><file name="Abandoned.php" hash="b5e001d0bc059c66ef38130b7d6dcec0"/><file name="Observer.php" hash="37a2d4c63e4ef75d535426a8670764f1"/><file name="Order.php" hash="b21426543cd46f799cd0743525120fb8"/><file name="Session.php" hash="c56ecf779dbfb2dae0030935af31911a"/></dir><dir name="controllers"><dir name="Admin"><file name="AbandonedController.php" hash="a5df99cae9322d66954111aaa8be5661"/><file name="DiagnosticController.php" hash="9dd175698b69c2bf59eee728d72726dd"/><file name="ExportController.php" hash="5bb090e4997e9c45367837c66fb9fd01"/><file name="TroubleshootingController.php" hash="02dffffc761bf1ac82ac18f51c75c976"/></dir><dir name="Customer"><file name="AccountController.php" hash="91942750c1c3d20dc31159c1ffbe8200"/></dir><file name="AbandonedController.php" hash="39c9d1a72bca9369a3121ac15f68558e"/><file name="CaptureController.php" hash="89e043bb3864617a062e915d2209dcf4"/><file name="ExportController.php" hash="7ca147debc5c1436b3bf2d9501592f33"/><file name="SignupController.php" hash="fe975d44cc11f1270d34d9d82c7d4be9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="61d894b12944956c74b41f5f96956c2c"/><file name="cache.xml" hash="9f7ad708d6507ec880473689e70ef314"/><file name="config.xml" hash="c9e957ffead8e022282474d2fb835243"/><file name="system.xml" hash="38f8dfb41b5fcc55490daf4d7c6e147c"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-2.0.0.php" hash="bdc5e09fe949b36534c50c85fd198e66"/><file name="mysql4-upgrade-1.5.8-2.0.0.php" hash="8f33c7f6dca96cfa8210ec1fe016d95b"/><file name="mysql4-upgrade-2.0.0-2.0.14.php" hash="ead09ac13bb7798b08776dda5948f91d"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="61d3d7b29b97f75023f2232cae6eb0c1"/><file name="logo.png" hash="2e7e39ced387c798ef27b77dd69f073e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="emaildirect.css" hash="c9caf9ea168efa3b0d6f4b881bcf093c"/><file name="integration.js" hash="7980204c0f594b180b9fa336954c9229"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="7767cd483e20d1930c0f1d79fee03b2a"/></dir><dir name="template"><dir name="emaildirect"><dir name="abandoned"><dir name="details"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="24829356b9dba966e53fb1cfe0f192b6"/></dir><file name="cart.phtml" hash="be7ca2b147fc836c2ca547b290ffe841"/></dir><file name="form.phtml" hash="60633d212382770e99d11d24ae919e47"/></dir><file name="details.phtml" hash="9d467b97a2d773aec950bea7061c6730"/><file name="status.phtml" hash="9e7723dc1fe5f8693345db9cc7cda808"/></dir><dir name="order"><dir name="view"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="a3bdecb1ec08903dd1b61dce6992e190"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="176f3ddb8ea667a64a06967351526f3c"/></dir><dir name="form"><dir name="field"><dir name="export"><file name="date_range.phtml" hash="6a37b1e58456e1dcec734c48deb8c0c1"/><file name="orders.phtml" hash="1dfa19a712b18d2c95c2f4b938f6acef"/><file name="products.phtml" hash="098b7b21b6424c2a4eea26194883a623"/></dir><dir name="signup"><file name="test.phtml" hash="636501cd90c6ab4231bea54efb16b2ff"/></dir><file name="api.phtml" hash="468f33b2a23dbe2828489c1620000c74"/><file name="array.phtml" hash="5415eeff311735624354468c886d39b5"/><file name="diagnostics.phtml" hash="3327dba9e03362077f7562e3045180b7"/><file name="info.phtml" hash="44ab79fdfc5fb5b0cd7e15e79bfd9502"/><file name="logging.phtml" hash="3c7bd2a6f48a84efca1d0f1e75097a8a"/><file name="note.phtml" hash="6625a3771ba10daba5ded5570574716f"/></dir></dir><file name="setup_check.phtml" hash="1814302f58a15fb1629446e074a7e1e0"/></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="c829eeccb120ffe4c0b9f0ddf9c7ff9a"/></dir></dir></dir><dir name="troubleshooting"><dir name="view"><dir name="tab"><file name="download.phtml" hash="d5701a0af7a8f308467fa5552d0de6b2"/><file name="help.phtml" hash="ce11f0fb8f19a00d950266840b4ec3ce"/><file name="info.phtml" hash="bd19bb1072ce1d60a4fb7bda660a0ce7"/><file name="log.phtml" hash="724a65165770bc92ed08ea32d20c1fe7"/><file name="settings.phtml" hash="56cea7faf49b815ac8bd66896130c58c"/><file name="submit.phtml" hash="0d7df80ddbd24e499275315d91fbfd58"/></dir><file name="form.phtml" hash="d2338bfe3598e9315ca8f5ac8d9b5516"/></dir><file name="status.phtml" hash="fac61e17efe7bd4cf67a47eb67786496"/><file name="view.phtml" hash="6ddfc8c6efe25d30e63f792b19a95c84"/></dir><file name="diagnostics.phtml" hash="f1f43a89824cad9f39e599df21ac44b4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="8cb8652ad2505bb6f0c5e80d7be60109"/></dir><dir name="template"><dir name="emaildirect"><dir name="capture"><file name="email.phtml" hash="fa273ff1a48a12eb386f58f3e3e78f66"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="d57eb93aab4e0f1d58f1ec8b9ed24c50"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="50ebf53c50e5e0419dd86a6d5faa2bf9"/></dir><file name="lists.phtml" hash="101ea6709a4355786917a6845b8d52aa"/></dir></dir><dir name="signup"><file name="form.phtml" hash="3d483079d29b79ad4daf306228120c0f"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="newsletter_subscr_success_emaildirect.html" hash="f6afb69d207bbc3f8920e7a72ac9dd07"/><file name="newsletter_unsub_success_emaildirect.html" hash="bd9f97e8f5485180d4420097b5200ef4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EmailDirect_Integration.xml" hash="90a441f2d0dff6c247f810274e8a76ab"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies/>
20
  </package>