Version Notes
v2
Download this release
Release Info
Developer | Dolist |
Extension | Dolist_Net |
Version | 2.0.0.7 |
Comparing to | |
See all releases |
Code changes from version 2.0.0.6 to 2.0.0.7
- app/code/community/Dolist/Net/Helper/Data.php +139 -0
- app/code/community/Dolist/Net/Model/Adminhtml/Observer.php +43 -30
- app/code/community/Dolist/Net/Model/Dolistv8/Calculatedfields.php +168 -271
- app/code/community/Dolist/Net/Model/Exporter/Csv.php +151 -147
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Calculatedfields.php +51 -2
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Firstorder.php +6 -60
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastorder.php +5 -60
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastquotenotordered.php +11 -164
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorder.php +8 -4
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorderline.php +8 -4
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbproductsperorder.php +7 -1
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountexcltax.php +7 -1
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountincltax.php +6 -83
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountexcltax.php +4 -4
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountincltax.php +5 -1
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountexcltax.php +9 -6
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountincltax.php +11 -149
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountexcltax.php +6 -1
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountincltax.php +4 -2
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Nbpromotionrulesused.php +7 -2
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountexcltax.php +7 -1
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountincltax.php +9 -4
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderedproducts.php +10 -1
- app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorders.php +10 -1
- app/code/community/Dolist/Net/Model/Observer.php +110 -1
- app/code/community/Dolist/Net/Model/Reports.php +5 -1
- app/code/community/Dolist/Net/Model/Service.php +99 -251
- app/code/community/Dolist/Net/Model/System/Config/Source/Dolistv8/Customerattributelist.php +14 -11
- app/code/community/Dolist/Net/controllers/Adminhtml/CustomerdolistController.php +75 -9
- app/code/community/Dolist/Net/controllers/Adminhtml/System/Config/TestconnectionController.php +5 -0
- app/code/community/Dolist/Net/etc/config.xml +12 -22
- app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-2.0.0.6-2.0.0.7.php +14 -0
- app/design/adminhtml/default/default/template/dolist/customerexport.phtml +1 -1
- app/locale/fr_FR/Dolist_Net.csv +2 -0
- package.xml +1 -1
- shell/dolist_export_segments.php +95 -0
app/code/community/Dolist/Net/Helper/Data.php
CHANGED
@@ -81,6 +81,42 @@ class Dolist_Net_Helper_Data extends Mage_Core_Helper_Abstract
|
|
81 |
'CustomInt10'
|
82 |
);
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/**
|
85 |
* Check if Dolist-V8 is enabled
|
86 |
*
|
@@ -360,6 +396,109 @@ class Dolist_Net_Helper_Data extends Mage_Core_Helper_Abstract
|
|
360 |
->save();
|
361 |
}
|
362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
/**
|
364 |
* Return Dolist-V8 export contact file header fields
|
365 |
*
|
81 |
'CustomInt10'
|
82 |
);
|
83 |
|
84 |
+
public function loadSubscriberByEmail($email, $storeId)
|
85 |
+
{
|
86 |
+
/** @var Mage_Newsletter_Model_Resource_Subscriber_Collection $subscriberCollection */
|
87 |
+
$subscriberCollection = Mage::getModel('newsletter/subscriber')->getCollection()
|
88 |
+
->addFilter('store_id', $storeId)
|
89 |
+
->addFilter('subscriber_email', $email);
|
90 |
+
|
91 |
+
if ($subscriberCollection->count() >= 1) {
|
92 |
+
return $subscriberCollection->getFirstItem();
|
93 |
+
}
|
94 |
+
|
95 |
+
return null;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function loadSubscriberByCustomer(Mage_Customer_Model_Customer $customer, $storeId)
|
99 |
+
{
|
100 |
+
/** @var Mage_Newsletter_Model_Resource_Subscriber_Collection $subscriberCollection */
|
101 |
+
$subscriberCollection = Mage::getModel('newsletter/subscriber')->getCollection()
|
102 |
+
->addFilter('store_id', $storeId)
|
103 |
+
->addFilter('customer_id', $customer->getId());
|
104 |
+
|
105 |
+
if ($subscriberCollection->count() >= 1) {
|
106 |
+
return $subscriberCollection->getFirstItem();
|
107 |
+
}
|
108 |
+
|
109 |
+
$subscriberCollection = Mage::getModel('newsletter/subscriber')->getCollection()
|
110 |
+
->addFilter('store_id', $storeId)
|
111 |
+
->addFilter('subscriber_email', $customer->getEmail());
|
112 |
+
|
113 |
+
if ($subscriberCollection->count() >= 1) {
|
114 |
+
return $subscriberCollection->getFirstItem();
|
115 |
+
}
|
116 |
+
|
117 |
+
return null;
|
118 |
+
}
|
119 |
+
|
120 |
/**
|
121 |
* Check if Dolist-V8 is enabled
|
122 |
*
|
396 |
->save();
|
397 |
}
|
398 |
|
399 |
+
/**
|
400 |
+
* Retrieve from core_flag table Dolist Segment Export Cronned Status flag
|
401 |
+
* If null, instantiate new object
|
402 |
+
*
|
403 |
+
* @param int $segmentId Segment ID
|
404 |
+
*
|
405 |
+
* @return Mage_Core_Model_Flag
|
406 |
+
*/
|
407 |
+
public function getCronExportSegmentFlag($segmentId)
|
408 |
+
{
|
409 |
+
$flagCode = 'dolist_cron_export_segment_' . $segmentId;
|
410 |
+
|
411 |
+
// First, try to retrieve object
|
412 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode))->load($flagCode, 'flag_code');
|
413 |
+
if ($flag->getId() == null) {
|
414 |
+
// Instanciate new object
|
415 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
416 |
+
$flag->setFlagData(FALSE);
|
417 |
+
$flag->save();
|
418 |
+
}
|
419 |
+
return $flag;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Add Segment Export to Cronned segment export list
|
424 |
+
*
|
425 |
+
* @param $segmentId
|
426 |
+
*
|
427 |
+
* @return void
|
428 |
+
*/
|
429 |
+
public function addSegmentExportToCron($segmentId)
|
430 |
+
{
|
431 |
+
|
432 |
+
$flag = $this->getCronExportSegmentFlag($segmentId);
|
433 |
+
$flag->setFlagData(TRUE)
|
434 |
+
->save();
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Remove Segment Export to Cronned segment export list
|
439 |
+
*
|
440 |
+
* @param $segmentId
|
441 |
+
*
|
442 |
+
* @return void
|
443 |
+
*/
|
444 |
+
public function removeSegmentExportFromCron($segmentId)
|
445 |
+
{
|
446 |
+
$flag = $this->getCronExportSegmentFlag($segmentId);
|
447 |
+
$flag->setFlagData(FALSE)
|
448 |
+
->save();
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Return TRUE is the segment export is added to the cron, FALSE otherwise
|
453 |
+
*
|
454 |
+
* @param $segmentId
|
455 |
+
*
|
456 |
+
* @return bool
|
457 |
+
*/
|
458 |
+
public function isSegmentExportCronEnabled($segmentId)
|
459 |
+
{
|
460 |
+
$flag = $this->getCronExportSegmentFlag($segmentId);
|
461 |
+
return (bool) $flag->getFlagData();
|
462 |
+
}
|
463 |
+
|
464 |
+
public function exportSegment($segmentId) {
|
465 |
+
$return = FALSE;
|
466 |
+
|
467 |
+
$segment = Mage::getModel('enterprise_customersegment/segment')->load($segmentId);
|
468 |
+
|
469 |
+
if($segment && $segment->getId()) {
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Preparation des paramètres
|
473 |
+
*/
|
474 |
+
$segmentWebsiteIds = $segment->getWebsiteIds();
|
475 |
+
// Replace segment website ids with segment website default store view ids
|
476 |
+
$segmentStoreIds = array();
|
477 |
+
foreach ($segmentWebsiteIds as $segmentWebsiteId) {
|
478 |
+
$website = Mage::app()->getWebsite($segmentWebsiteId);
|
479 |
+
$segmentStoreIds[$segmentWebsiteId] = $website->getDefaultStore()->getId();
|
480 |
+
}
|
481 |
+
|
482 |
+
$enabledStoreIds = array();
|
483 |
+
foreach ($segmentStoreIds as $segmentWebsiteId => $segmentStoreId) {
|
484 |
+
if ($this->isDolistV8Enabled($segmentStoreId)) {
|
485 |
+
$enabledStoreIds[$segmentWebsiteId] = $segmentStoreId;
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
$websiteIds = array_keys($enabledStoreIds); // Dolist-V8 enabled websites
|
490 |
+
$storeIds = $enabledStoreIds;
|
491 |
+
$filteredWebsiteIds = $this->filterDistinctEnabledWebsites($websiteIds);
|
492 |
+
|
493 |
+
/** Export */
|
494 |
+
/** @var Dolist_Net_Model_Service $service */
|
495 |
+
$service = Mage::getSingleton('dolist/service');
|
496 |
+
$return = $service->exportSegment($segment->getId(), $filteredWebsiteIds, $storeIds);
|
497 |
+
}
|
498 |
+
return $return;
|
499 |
+
|
500 |
+
}
|
501 |
+
|
502 |
/**
|
503 |
* Return Dolist-V8 export contact file header fields
|
504 |
*
|
app/code/community/Dolist/Net/Model/Adminhtml/Observer.php
CHANGED
@@ -41,28 +41,52 @@ class Dolist_Net_Model_Adminhtml_Observer
|
|
41 |
if (!empty($enabledStoreIds)) {
|
42 |
$block = $observer->getEvent()->getBlock();
|
43 |
|
44 |
-
$url
|
45 |
-
$removeUrl
|
|
|
|
|
|
|
|
|
46 |
$urlParams = array(
|
47 |
'segment_id' => $segment->getId(),
|
48 |
'website_ids' => serialize(array_keys($enabledStoreIds)), // Dolist-V8 enabled websites
|
49 |
'store_ids' => serialize($enabledStoreIds),
|
50 |
);
|
51 |
-
|
52 |
-
// If this segment is not already exported
|
53 |
-
if (!$this->_getHelper()->isExportedSegment($segment->getId(), $enabledStoreIds)) {
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
65 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
$block->addButton(
|
68 |
'dolistv8_export',
|
@@ -71,22 +95,10 @@ class Dolist_Net_Model_Adminhtml_Observer
|
|
71 |
'label' => Mage::helper('dolist')->__('Export this segment to Dolist-V8'),
|
72 |
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($url, $urlParams) . '\')',
|
73 |
),
|
74 |
-
|
75 |
);
|
76 |
} else {
|
77 |
|
78 |
-
// Newline
|
79 |
-
$block->addButton(
|
80 |
-
'dolistv8_newline',
|
81 |
-
array(
|
82 |
-
'class' => '',
|
83 |
-
'label' => '',
|
84 |
-
'onclick' => '',
|
85 |
-
'style' => 'display:block; visibility: hidden;',
|
86 |
-
),
|
87 |
-
3
|
88 |
-
);
|
89 |
-
|
90 |
// Else, propose to export it again (just one segment export)
|
91 |
$block->addButton(
|
92 |
'dolistv8_export',
|
@@ -95,7 +107,7 @@ class Dolist_Net_Model_Adminhtml_Observer
|
|
95 |
'label' => Mage::helper('dolist')->__('Export again this segment to Dolist-V8'),
|
96 |
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($url, $urlParams) . '\')',
|
97 |
),
|
98 |
-
|
99 |
);
|
100 |
|
101 |
// Add new button to remove this segment from export list dolist_exported_segment_list
|
@@ -106,8 +118,9 @@ class Dolist_Net_Model_Adminhtml_Observer
|
|
106 |
'label' => Mage::helper('dolist')->__('Remove this segment from exported list'),
|
107 |
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($removeUrl, $urlParams) . '\')',
|
108 |
),
|
109 |
-
|
110 |
);
|
|
|
111 |
}
|
112 |
}
|
113 |
}
|
41 |
if (!empty($enabledStoreIds)) {
|
42 |
$block = $observer->getEvent()->getBlock();
|
43 |
|
44 |
+
$url = '*/customerdolist/exportSegment';
|
45 |
+
$removeUrl = '*/customerdolist/removeSegment';
|
46 |
+
$urlAddToCron = '*/customerdolist/addSegmentExportToCron';
|
47 |
+
$urlRemoveFromCron = '*/customerdolist/removeSegmentExportFromCron';
|
48 |
+
|
49 |
+
|
50 |
$urlParams = array(
|
51 |
'segment_id' => $segment->getId(),
|
52 |
'website_ids' => serialize(array_keys($enabledStoreIds)), // Dolist-V8 enabled websites
|
53 |
'store_ids' => serialize($enabledStoreIds),
|
54 |
);
|
|
|
|
|
|
|
55 |
|
56 |
+
//Get Segment Export Cron Status to build the correct action button
|
57 |
+
if(!$this->_getHelper()->isSegmentExportCronEnabled($segment->getId())) {
|
58 |
+
$button_export_cron = array(
|
59 |
+
'class' => 'add',
|
60 |
+
'label' => Mage::helper('dolist')->__('Enable export from Cron'),
|
61 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($urlAddToCron, $urlParams) . '\')'
|
62 |
+
);
|
63 |
+
} else {
|
64 |
+
$button_export_cron = array(
|
65 |
+
'class' => 'delete',
|
66 |
+
'label' => Mage::helper('dolist')->__('Disable export from Cron'),
|
67 |
+
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($urlRemoveFromCron, $urlParams) . '\')'
|
68 |
);
|
69 |
+
}
|
70 |
+
|
71 |
+
// Newline
|
72 |
+
$block->addButton(
|
73 |
+
'dolistv8_newline',
|
74 |
+
array(
|
75 |
+
'class' => '',
|
76 |
+
'label' => '',
|
77 |
+
'onclick' => '',
|
78 |
+
'style' => 'display:block; visibility: hidden;',
|
79 |
+
),
|
80 |
+
3
|
81 |
+
);
|
82 |
+
|
83 |
+
$block->addButton('toggle_export_cron',
|
84 |
+
$button_export_cron,
|
85 |
+
4);
|
86 |
+
|
87 |
+
|
88 |
+
// If this segment is not already exported
|
89 |
+
if (!$this->_getHelper()->isExportedSegment($segment->getId(), $enabledStoreIds)) {
|
90 |
|
91 |
$block->addButton(
|
92 |
'dolistv8_export',
|
95 |
'label' => Mage::helper('dolist')->__('Export this segment to Dolist-V8'),
|
96 |
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($url, $urlParams) . '\')',
|
97 |
),
|
98 |
+
5
|
99 |
);
|
100 |
} else {
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
// Else, propose to export it again (just one segment export)
|
103 |
$block->addButton(
|
104 |
'dolistv8_export',
|
107 |
'label' => Mage::helper('dolist')->__('Export again this segment to Dolist-V8'),
|
108 |
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($url, $urlParams) . '\')',
|
109 |
),
|
110 |
+
5
|
111 |
);
|
112 |
|
113 |
// Add new button to remove this segment from export list dolist_exported_segment_list
|
118 |
'label' => Mage::helper('dolist')->__('Remove this segment from exported list'),
|
119 |
'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl($removeUrl, $urlParams) . '\')',
|
120 |
),
|
121 |
+
6
|
122 |
);
|
123 |
+
|
124 |
}
|
125 |
}
|
126 |
}
|
app/code/community/Dolist/Net/Model/Dolistv8/Calculatedfields.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstract
|
5 |
{
|
6 |
|
@@ -21,20 +25,6 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
21 |
$this->debug = true;
|
22 |
}
|
23 |
|
24 |
-
/**
|
25 |
-
* @param array $attribute
|
26 |
-
* @return mixed
|
27 |
-
*/
|
28 |
-
public function getColumnValue($attribute)
|
29 |
-
{
|
30 |
-
$config = $this->getConfig();
|
31 |
-
|
32 |
-
$adapter = Mage::getModel($attribute['adapter']);
|
33 |
-
|
34 |
-
return $adapter->getExportedValue($this->getData($config[$attribute['field']]));
|
35 |
-
}
|
36 |
-
|
37 |
-
|
38 |
public function getConfig()
|
39 |
{
|
40 |
return array(
|
@@ -72,19 +62,48 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
72 |
return false;
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
* @param $customerId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
* @return array
|
78 |
*/
|
79 |
-
|
80 |
{
|
81 |
/**
|
82 |
* FULL : ttl date is null
|
83 |
* BEGIN : ttl is from beginDate to currentDate
|
84 |
* RANGE_X : ttl is from currentDate - delay to currentDate
|
85 |
*/
|
86 |
-
$option = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode');
|
87 |
-
|
88 |
|
89 |
if (!$option) {
|
90 |
$option = 1;
|
@@ -97,7 +116,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
97 |
case self::FULL:
|
98 |
break;
|
99 |
case self::BEGIN_DATE:
|
100 |
-
$date = Mage::getStoreConfig(
|
101 |
$timestamp = strtotime($date);
|
102 |
$start = new \DateTime();
|
103 |
$start->setTimestamp($timestamp);
|
@@ -105,9 +124,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
105 |
case self::RANGE_1:
|
106 |
$delay = 1;
|
107 |
$startDate = new \DateTime('-' . $delay . ' months');
|
108 |
-
|
109 |
-
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
110 |
-
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
111 |
if ($strDate) {
|
112 |
$startDate->setTimestamp(strtotime($strDate));
|
113 |
$start = $startDate;
|
@@ -119,9 +136,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
119 |
case self::RANGE_3:
|
120 |
$delay = 3;
|
121 |
$startDate = new \DateTime('-' . $delay . ' months');
|
122 |
-
|
123 |
-
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
124 |
-
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
125 |
if ($strDate) {
|
126 |
$startDate->setTimestamp(strtotime($strDate));
|
127 |
$start = $startDate;
|
@@ -133,9 +148,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
133 |
case self::RANGE_6:
|
134 |
$delay = 6;
|
135 |
$startDate = new \DateTime('-' . $delay . ' months');
|
136 |
-
|
137 |
-
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
138 |
-
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
139 |
if ($strDate) {
|
140 |
$startDate->setTimestamp(strtotime($strDate));
|
141 |
$start = $startDate;
|
@@ -147,9 +160,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
147 |
case self::RANGE_12:
|
148 |
$delay = 12;
|
149 |
$startDate = new \DateTime('-' . $delay . ' months');
|
150 |
-
|
151 |
-
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
152 |
-
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
153 |
if ($strDate) {
|
154 |
$startDate->setTimestamp(strtotime($strDate));
|
155 |
$start = $startDate;
|
@@ -161,9 +172,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
161 |
case self::RANGE_24:
|
162 |
$delay = 24;
|
163 |
$startDate = new \DateTime('-' . $delay . ' months');
|
164 |
-
|
165 |
-
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
166 |
-
$strDate = $model->getFirstOrderDate($customerId, $startDate);
|
167 |
if ($strDate) {
|
168 |
$startDate->setTimestamp(strtotime($strDate));
|
169 |
$start = $startDate;
|
@@ -180,89 +189,106 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
180 |
);
|
181 |
}
|
182 |
|
183 |
-
|
|
|
|
|
|
|
184 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
);
|
|
|
211 |
|
212 |
-
|
|
|
|
|
|
|
213 |
|
214 |
-
|
215 |
-
$this->setData('orders_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
216 |
}
|
217 |
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
$this->save();
|
223 |
-
} catch (Exception $e) {
|
224 |
-
Mage::logException($e);
|
225 |
}
|
226 |
-
}
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
$
|
231 |
-
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode");
|
232 |
-
$lastOrderDate = $this->getLastOrderDate($customerId, true);
|
233 |
-
// load model
|
234 |
-
$this->load($customerId);
|
235 |
|
236 |
$now = new \DateTime();
|
237 |
$this->addData(array(
|
238 |
-
'
|
239 |
-
'
|
240 |
-
'
|
241 |
-
'
|
242 |
-
'
|
243 |
-
'
|
244 |
-
'
|
245 |
-
'
|
246 |
-
'
|
247 |
-
'
|
248 |
-
'
|
249 |
-
'
|
250 |
-
'
|
251 |
-
'
|
252 |
-
'
|
253 |
-
'
|
254 |
-
'
|
255 |
-
'last_unordered_cart_date' => $this->getLastUnorderedCartDate($customerId),
|
256 |
'config' => $config,
|
257 |
-
'start_date' => ($config == $this::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date") : null,
|
|
|
258 |
));
|
259 |
|
260 |
-
if (is_array($
|
261 |
-
$this->setData('orders_expire', $
|
262 |
-
$this->setData('cart_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
263 |
}
|
264 |
|
265 |
-
$
|
|
|
|
|
266 |
|
267 |
try {
|
268 |
$this->save();
|
@@ -271,139 +297,12 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
271 |
}
|
272 |
}
|
273 |
|
274 |
-
public function onNewOrder(Varien_Event_Observer $event)
|
275 |
-
{
|
276 |
-
$currentOrder = null;
|
277 |
-
/** @var Mage_Sales_Model_Order $currentOrder */
|
278 |
-
if ($event) {
|
279 |
-
$currentOrder = $event->getData('order');
|
280 |
-
}
|
281 |
-
|
282 |
-
if ($currentOrder) {
|
283 |
-
$customerId = $currentOrder->getData('customer_id');
|
284 |
-
|
285 |
-
if (!$customerId) {
|
286 |
-
return;
|
287 |
-
}
|
288 |
-
|
289 |
-
$dates = $this->computeDataTtl($customerId);
|
290 |
-
|
291 |
-
// load model
|
292 |
-
$this->load($customerId);
|
293 |
-
|
294 |
-
$now = new \DateTime();
|
295 |
-
// full update
|
296 |
-
if ($this->getData('customer_id') == null && $customerId != null) {
|
297 |
-
$this->compute($customerId);
|
298 |
-
} else {
|
299 |
-
if ((in_array(Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode'), array(self::RANGE_1, self::RANGE_3, self::RANGE_6, self::RANGE_12, self::RANGE_24)) && $this->getData('orders_expire') == null) || ($this->getData('orders_expire') != null && strtotime($this->getData('orders_expire')) < $now->getTimestamp())) {
|
300 |
-
$this->recompute($customerId);
|
301 |
-
} else {
|
302 |
-
$this->addData(array(
|
303 |
-
"total_orders_amount" => $this->getData('total_orders_amount') + ($currentOrder->getData('grand_total') - $currentOrder->getData('tax_amount')),
|
304 |
-
"total_orders_amount_with_vat" => $this->getData('total_orders_amount') + $currentOrder->getData('grand_total'),
|
305 |
-
"average_unique_product_count" => $this->computeAverageUniqueProductCount($customerId, $dates),
|
306 |
-
"average_product_count_by_command_line" => $this->computeAverageProductCountByCommandLine($customerId, $dates),
|
307 |
-
"total_product_count" => $this->getData('total_product_count') + $currentOrder->getData('total_item_count'),
|
308 |
-
"total_orders_count" => $this->getData('total_orders_count') + 1,
|
309 |
-
"discount_rule_count" => $this->computeDiscountRuleCount($customerId, $dates),
|
310 |
-
));
|
311 |
-
}
|
312 |
-
|
313 |
-
if (!$this->getData('first_order_amount') || $this->getData('first_order_amount') == 0) {
|
314 |
-
$this->setData('first_order_amount', $this->computeFirstOrderAmount($customerId));
|
315 |
-
}
|
316 |
-
if (!$this->getData('first_order_date')) {
|
317 |
-
$this->setData('first_order_date', $this->getFirstOrderDate($customerId));
|
318 |
-
}
|
319 |
-
|
320 |
-
if (!$this->getData('first_order_amount_with_vat')) {
|
321 |
-
$this->setData('first_order_amount_with_vat', $this->computeFirstOrderAmount($customerId, true));
|
322 |
-
}
|
323 |
-
|
324 |
-
if ($currentOrder) {
|
325 |
-
$this->setData('last_order_amount', $this->computeLastOrderAmount($customerId));
|
326 |
-
$this->setData('last_order_amount_with_vat', $this->computeLastOrderAmount($customerId, true));
|
327 |
-
$this->setData('last_order_date', $this->getLastOrderDate($customerId, true));
|
328 |
-
$this->setData('last_orders_range', (strtotime($currentOrder->getData('created_at')) - strtotime($this->getData('last_order_date'))) / 60 / 60 / 24);
|
329 |
-
}
|
330 |
-
$this->setData('updated_at', $now->format('Y-m-d H:i:s'));
|
331 |
-
$this->setData('customer_id', $customerId);
|
332 |
-
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
333 |
-
$this->setData('orders_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
334 |
-
}
|
335 |
-
try {
|
336 |
-
$this->save();
|
337 |
-
} catch (Exception $e) {
|
338 |
-
Mage::logException($e);
|
339 |
-
}
|
340 |
-
}
|
341 |
-
}
|
342 |
-
}
|
343 |
-
|
344 |
-
public function onNewCart(Varien_Event_Observer $observer)
|
345 |
-
{
|
346 |
-
$customerId = null;
|
347 |
-
if ($observer->hasData('quote_item')) {
|
348 |
-
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
|
349 |
-
$quoteItem = $observer->getQuoteItem();
|
350 |
-
|
351 |
-
if ($quoteItem->getQuote()->getCustomer()) {
|
352 |
-
$customerId = $quoteItem->getQuote()->getCustomer()->getId();
|
353 |
-
}
|
354 |
-
} elseif ($observer->hasData('cart')) {
|
355 |
-
/** @var Mage_Checkout_Model_Cart $cart */
|
356 |
-
$cart = $observer->getData('cart');
|
357 |
-
|
358 |
-
if ($cart->getQuote()->getCustomer()) {
|
359 |
-
$customerId = $cart->getQuote()->getCustomer()->getId();
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
if (!$customerId) {
|
364 |
-
return;
|
365 |
-
}
|
366 |
-
|
367 |
-
|
368 |
-
/** @var Mage_Core_Model_Abstract $model */
|
369 |
-
$model = Mage::getModel('dolist/dolistv8_calculatedfields');
|
370 |
-
|
371 |
-
// load model
|
372 |
-
$model->load($customerId);
|
373 |
-
|
374 |
-
$now = new \DateTime();
|
375 |
-
|
376 |
-
$dates = $this->computeDataTtl($customerId);
|
377 |
-
|
378 |
-
if ($this->getData('customer_id') == null && $customerId != null) {
|
379 |
-
$this->compute($customerId);
|
380 |
-
} else {
|
381 |
-
$model->addData(array(
|
382 |
-
'last_unordered_cart_amount' => $this->computeLastUnorderedCartAmount($customerId),
|
383 |
-
'last_unordered_cart_amount_with_vat' => $this->computeLastUnorderedCartAmount($customerId, true),
|
384 |
-
'last_unordered_cart_date' => $this->getLastUnorderedCartDate($customerId),
|
385 |
-
'updated_at' => $now->format('Y-m-d H:i:s')
|
386 |
-
));
|
387 |
-
|
388 |
-
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
389 |
-
$model->setData("cart_expire", $dates['stop']->format('Y-m-d H:i:s'));
|
390 |
-
}
|
391 |
-
|
392 |
-
try {
|
393 |
-
$model->save();
|
394 |
-
} catch (Exception $e) {
|
395 |
-
Mage::logException($e);
|
396 |
-
}
|
397 |
-
}
|
398 |
-
}
|
399 |
-
|
400 |
/**
|
401 |
-
* @param $customerId
|
402 |
* @param bool $withVat
|
403 |
*
|
404 |
* @return float
|
405 |
*/
|
406 |
-
|
407 |
{
|
408 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountInclTax $model */
|
409 |
$model = null;
|
@@ -413,16 +312,15 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
413 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_firstorderamountexcltax');
|
414 |
}
|
415 |
|
416 |
-
return $model->calculatedAttributeRequest($
|
417 |
}
|
418 |
|
419 |
/**
|
420 |
-
* @param $customerId
|
421 |
* @param bool $withVat
|
422 |
*
|
423 |
* @return float
|
424 |
*/
|
425 |
-
|
426 |
{
|
427 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountInclTax $model */
|
428 |
$model = null;
|
@@ -431,17 +329,16 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
431 |
else {
|
432 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastorderamountexcltax');
|
433 |
}
|
434 |
-
return $model->calculatedAttributeRequest($
|
435 |
}
|
436 |
|
437 |
/**
|
438 |
-
* @param $customerId
|
439 |
* @param array $dates
|
440 |
* @param bool $withVat
|
441 |
*
|
442 |
* @return float
|
443 |
*/
|
444 |
-
|
445 |
{
|
446 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTax $model */
|
447 |
$model = null;
|
@@ -451,18 +348,17 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
451 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderamountexcltax');
|
452 |
}
|
453 |
|
454 |
-
return $model->calculatedAttributeRequest($
|
455 |
}
|
456 |
|
457 |
|
458 |
/**
|
459 |
-
* @param $customerId
|
460 |
* @param array $dates
|
461 |
* @param bool $withVat
|
462 |
*
|
463 |
* @return float
|
464 |
*/
|
465 |
-
|
466 |
{
|
467 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax $model */
|
468 |
$model = null;
|
@@ -472,7 +368,7 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
472 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgorderamountexcltax');
|
473 |
}
|
474 |
|
475 |
-
return $model->calculatedAttributeRequest($
|
476 |
}
|
477 |
|
478 |
public function getAvgOrdersAmount($withVat = false)
|
@@ -488,16 +384,16 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
488 |
}
|
489 |
|
490 |
/**
|
491 |
-
* @param $customerId
|
492 |
* @param array $dates
|
493 |
*
|
494 |
* @return float
|
495 |
*/
|
496 |
-
|
497 |
{
|
498 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbProductsPerOrder $model */
|
499 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbproductsperorder');
|
500 |
-
|
|
|
501 |
}
|
502 |
|
503 |
public function getAvgProductCount()
|
@@ -514,16 +410,16 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
514 |
}
|
515 |
|
516 |
/**
|
517 |
-
* @param $customerId
|
518 |
*
|
519 |
* @param array $dates
|
520 |
* @return float
|
521 |
*/
|
522 |
-
|
523 |
{
|
524 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrder $model */
|
525 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbdifferentproductsperorder');
|
526 |
-
|
|
|
527 |
}
|
528 |
|
529 |
/**
|
@@ -532,50 +428,48 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
532 |
* @param array $dates
|
533 |
* @return float
|
534 |
*/
|
535 |
-
|
536 |
{
|
537 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrderLine $model */
|
538 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbdifferentproductsperorderline');
|
539 |
|
540 |
-
return $model->calculatedAttributeRequest($
|
541 |
}
|
542 |
|
543 |
/**
|
544 |
-
* @param $customerId
|
545 |
*
|
546 |
* @param array $dates
|
547 |
* @return float
|
548 |
*/
|
549 |
-
|
550 |
{
|
551 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts $model */
|
552 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderedproducts');
|
553 |
|
554 |
-
return $model->calculatedAttributeRequest($
|
555 |
}
|
556 |
|
557 |
/**
|
558 |
-
* @param $customerId
|
559 |
*
|
560 |
* @param array $dates
|
561 |
* @return float
|
562 |
*/
|
563 |
-
|
564 |
{
|
565 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders $model */
|
566 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorders');
|
567 |
|
568 |
-
return $model->calculatedAttributeRequest($
|
569 |
}
|
570 |
|
571 |
/**
|
572 |
-
*
|
573 |
* @param array $dates
|
574 |
* @param bool $withVat
|
575 |
*
|
576 |
* @return float
|
577 |
*/
|
578 |
-
|
579 |
{
|
580 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountInclTax $model */
|
581 |
$model = null;
|
@@ -585,55 +479,52 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
585 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastnotorderedcartamountexcltax');
|
586 |
}
|
587 |
|
588 |
-
return $model->calculatedAttributeRequest($
|
589 |
}
|
590 |
|
591 |
/**
|
592 |
-
* @param $customerId
|
593 |
*
|
594 |
* @param array $dates
|
595 |
* @return float
|
596 |
*/
|
597 |
-
|
598 |
{
|
599 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_NbPromotionRulesUsed $model */
|
600 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_nbpromotionrulesused');
|
601 |
|
602 |
-
return $model->calculatedAttributeRequest($
|
603 |
}
|
604 |
|
605 |
/**
|
606 |
-
* @param $customerId
|
607 |
*
|
608 |
* @return DateTime
|
609 |
*/
|
610 |
-
|
611 |
{
|
612 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder $model */
|
613 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_firstorder');
|
614 |
|
615 |
-
return $model->calculatedAttributeRequest($
|
616 |
}
|
617 |
|
618 |
/**
|
619 |
-
* @param $customerId
|
620 |
*
|
621 |
* @return DateTime
|
622 |
*/
|
623 |
-
|
624 |
{
|
625 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder $model */
|
626 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_lastorder');
|
627 |
|
628 |
-
return $model->calculatedAttributeRequest($
|
629 |
}
|
630 |
|
631 |
-
public function getLastTwoOrdersRange(
|
632 |
{
|
633 |
$readAdapter = $this->_getReadAdapter();
|
634 |
|
635 |
$tableName = null;
|
636 |
-
if(
|
637 |
$tableName = 'sales_flat_order';
|
638 |
}else{
|
639 |
$tableName = 'sales_order';
|
@@ -642,12 +533,12 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
642 |
/** @var Varien_Db_Select $select */
|
643 |
$select = $readAdapter->select();
|
644 |
$select->from(array('o' => $this->getTable($tableName)), array('o.created_at'))
|
|
|
|
|
645 |
->order('o.created_at DESC')
|
646 |
-
->where('o.customer_id = ?', $customerId)
|
647 |
->limit(2)
|
648 |
;
|
649 |
|
650 |
-
|
651 |
$data = $readAdapter->fetchAll($select);
|
652 |
|
653 |
if(count($data) < 2) {
|
@@ -656,21 +547,19 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
656 |
|
657 |
$diff = date_create_from_format('Y-m-d H:i:s', $data[1]['created_at'])->diff(date_create_from_format('Y-m-d H:i:s', $data[0]['created_at']));
|
658 |
|
659 |
-
|
660 |
return $diff->days;
|
661 |
}
|
662 |
|
663 |
/**
|
664 |
-
* @param $customerId
|
665 |
*
|
666 |
* @return DateTime
|
667 |
*/
|
668 |
-
|
669 |
{
|
670 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered $model */
|
671 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_lastquotenotordered');
|
672 |
|
673 |
-
return $model->calculatedAttributeRequest($
|
674 |
}
|
675 |
|
676 |
/**
|
@@ -695,4 +584,12 @@ class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstrac
|
|
695 |
$tablePrefix = (string)Mage::getConfig()->getTablePrefix();
|
696 |
return $tablePrefix . $tableName;
|
697 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class Dolist_Net_Model_Dolistv8_Calculatedfields
|
5 |
+
*
|
6 |
+
* @method $this setStoreId(int $storeId)
|
7 |
+
*/
|
8 |
class Dolist_Net_Model_Dolistv8_Calculatedfields extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
|
25 |
$this->debug = true;
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
public function getConfig()
|
29 |
{
|
30 |
return array(
|
62 |
return false;
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* @return Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields
|
67 |
+
*/
|
68 |
+
public function getResource()
|
69 |
+
{
|
70 |
+
return parent::getResource();
|
71 |
+
}
|
72 |
+
|
73 |
/**
|
74 |
* @param $customerId
|
75 |
+
* @return $this
|
76 |
+
*/
|
77 |
+
public function loadByCustomerId($customerId)
|
78 |
+
{
|
79 |
+
$this->getResource()->loadByCustomerId($this, $customerId);
|
80 |
+
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @param array $attribute
|
86 |
+
* @return mixed
|
87 |
+
*/
|
88 |
+
public function getColumnValue($attribute)
|
89 |
+
{
|
90 |
+
$config = $this->getConfig();
|
91 |
+
$adapter = Mage::getModel($attribute['adapter']);
|
92 |
+
|
93 |
+
return $adapter->getExportedValue($this->getData($config[$attribute['field']]));
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
* @return array
|
98 |
*/
|
99 |
+
public function computeOrderDataTtl()
|
100 |
{
|
101 |
/**
|
102 |
* FULL : ttl date is null
|
103 |
* BEGIN : ttl is from beginDate to currentDate
|
104 |
* RANGE_X : ttl is from currentDate - delay to currentDate
|
105 |
*/
|
106 |
+
$option = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode', $this->getData('store_id'));
|
|
|
107 |
|
108 |
if (!$option) {
|
109 |
$option = 1;
|
116 |
case self::FULL:
|
117 |
break;
|
118 |
case self::BEGIN_DATE:
|
119 |
+
$date = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_date', $this->getData('store_id'));
|
120 |
$timestamp = strtotime($date);
|
121 |
$start = new \DateTime();
|
122 |
$start->setTimestamp($timestamp);
|
124 |
case self::RANGE_1:
|
125 |
$delay = 1;
|
126 |
$startDate = new \DateTime('-' . $delay . ' months');
|
127 |
+
$strDate = $this->getResource()->getFirstOrderDate($this->getData('customer_id'), $startDate);
|
|
|
|
|
128 |
if ($strDate) {
|
129 |
$startDate->setTimestamp(strtotime($strDate));
|
130 |
$start = $startDate;
|
136 |
case self::RANGE_3:
|
137 |
$delay = 3;
|
138 |
$startDate = new \DateTime('-' . $delay . ' months');
|
139 |
+
$strDate = $this->getResource()->getFirstOrderDate($this->getData('customer_id'), $startDate);
|
|
|
|
|
140 |
if ($strDate) {
|
141 |
$startDate->setTimestamp(strtotime($strDate));
|
142 |
$start = $startDate;
|
148 |
case self::RANGE_6:
|
149 |
$delay = 6;
|
150 |
$startDate = new \DateTime('-' . $delay . ' months');
|
151 |
+
$strDate = $this->getResource()->getFirstOrderDate($this->getData('customer_id'), $startDate);
|
|
|
|
|
152 |
if ($strDate) {
|
153 |
$startDate->setTimestamp(strtotime($strDate));
|
154 |
$start = $startDate;
|
160 |
case self::RANGE_12:
|
161 |
$delay = 12;
|
162 |
$startDate = new \DateTime('-' . $delay . ' months');
|
163 |
+
$strDate = $this->getResource()->getFirstOrderDate($this->getData('customer_id'), $startDate);
|
|
|
|
|
164 |
if ($strDate) {
|
165 |
$startDate->setTimestamp(strtotime($strDate));
|
166 |
$start = $startDate;
|
172 |
case self::RANGE_24:
|
173 |
$delay = 24;
|
174 |
$startDate = new \DateTime('-' . $delay . ' months');
|
175 |
+
$strDate = $this->getResource()->getFirstOrderDate($this->getData('customer_id'), $startDate);
|
|
|
|
|
176 |
if ($strDate) {
|
177 |
$startDate->setTimestamp(strtotime($strDate));
|
178 |
$start = $startDate;
|
189 |
);
|
190 |
}
|
191 |
|
192 |
+
/**
|
193 |
+
* @return array
|
194 |
+
*/
|
195 |
+
public function computeCartDataTtl()
|
196 |
{
|
197 |
+
/**
|
198 |
+
* FULL : ttl date is null
|
199 |
+
* BEGIN : ttl is from beginDate to currentDate
|
200 |
+
* RANGE_X : ttl is from currentDate - delay to currentDate
|
201 |
+
*/
|
202 |
+
$option = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode', $this->getData('store_id'));
|
203 |
|
204 |
+
if (!$option) {
|
205 |
+
$option = 1;
|
206 |
+
}
|
207 |
+
|
208 |
+
$start = null;
|
209 |
+
$stop = null;
|
210 |
+
|
211 |
+
switch ($option) {
|
212 |
+
case self::FULL:
|
213 |
+
break;
|
214 |
+
case self::BEGIN_DATE:
|
215 |
+
$date = Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_date', $this->getData('store_id'));
|
216 |
+
$timestamp = strtotime($date);
|
217 |
+
$start = new \DateTime();
|
218 |
+
$start->setTimestamp($timestamp);
|
219 |
+
break;
|
220 |
+
case self::RANGE_1:
|
221 |
+
$start = new \DateTime('-1 months');
|
222 |
+
break;
|
223 |
+
case self::RANGE_3:
|
224 |
+
$start = new \DateTime('-3 months');
|
225 |
+
break;
|
226 |
+
case self::RANGE_6:
|
227 |
+
$start = new \DateTime('-6 months');
|
228 |
+
break;
|
229 |
+
case self::RANGE_12:
|
230 |
+
$start = new \DateTime('-12 months');
|
231 |
+
break;
|
232 |
+
case self::RANGE_24:
|
233 |
+
$start = new \DateTime('-24 months');
|
234 |
+
break;
|
235 |
+
}
|
236 |
+
|
237 |
+
return array(
|
238 |
+
'start' => $start,
|
239 |
+
'stop' => $stop
|
240 |
);
|
241 |
+
}
|
242 |
|
243 |
+
public function compute()
|
244 |
+
{
|
245 |
+
if (!$this->hasData('customer_id')) {
|
246 |
+
Mage::logException(new Exception('Missing customer ID to compute'));
|
247 |
|
248 |
+
return;
|
|
|
249 |
}
|
250 |
|
251 |
+
if (!$this->hasData('store_id')) {
|
252 |
+
Mage::logException(new Exception('Missing store ID to compute'));
|
253 |
|
254 |
+
return;
|
|
|
|
|
|
|
255 |
}
|
|
|
256 |
|
257 |
+
$datesOrder = $this->computeOrderDataTtl();
|
258 |
+
$datesCart = $this->computeCartDataTtl();
|
259 |
+
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode", $this->getData('store_id'));
|
|
|
|
|
|
|
|
|
260 |
|
261 |
$now = new \DateTime();
|
262 |
$this->addData(array(
|
263 |
+
'first_order_amount' => $this->computeFirstOrderAmount(),
|
264 |
+
'first_order_amount_with_vat' => $this->computeFirstOrderAmount(true),
|
265 |
+
'last_order_amount' => $this->computeLastOrderAmount(),
|
266 |
+
'last_order_amount_with_vat' => $this->computeLastOrderAmount(true),
|
267 |
+
'total_orders_amount' => $this->computeTotalOrdersAmount($datesOrder),
|
268 |
+
'total_orders_amount_with_vat' => $this->computeTotalOrdersAmount($datesOrder, true),
|
269 |
+
'average_unique_product_count' => $this->computeAverageUniqueProductCount($datesOrder),
|
270 |
+
'average_product_count_by_command_line' => $this->computeAverageProductCountByCommandLine($datesOrder),
|
271 |
+
'total_product_count' => $this->computeTotalProductCount($datesOrder),
|
272 |
+
'total_orders_count' => $this->computeTotalOrdersCount($datesOrder),
|
273 |
+
'last_unordered_cart_amount' => $this->computeLastUnorderedCartAmount($datesCart),
|
274 |
+
'last_unordered_cart_amount_with_vat' => $this->computeLastUnorderedCartAmount($datesCart, true),
|
275 |
+
'discount_rule_count' => $this->computeDiscountRuleCount(),
|
276 |
+
'last_orders_range' => $this->getLastTwoOrdersRange(),
|
277 |
+
'first_order_date' => $this->getFirstOrderDate(),
|
278 |
+
'last_order_date' => $this->getLastOrderDate(),
|
279 |
+
'last_unordered_cart_date' => $this->getLastUnorderedCartDate(),
|
|
|
280 |
'config' => $config,
|
281 |
+
'start_date' => ($config == $this::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date", $this->getData('store_id')) : null,
|
282 |
+
'updated_at' => $now->format('Y-m-d H:i:s')
|
283 |
));
|
284 |
|
285 |
+
if (is_array($datesOrder) && !empty($datesOrder) && array_key_exists('stop', $datesOrder) && $datesOrder['stop']) {
|
286 |
+
$this->setData('orders_expire', $datesOrder['stop']->format('Y-m-d H:i:s'));
|
|
|
287 |
}
|
288 |
|
289 |
+
if (is_array($datesCart) && !empty($datesCart) && array_key_exists('stop', $datesCart) && $datesCart['stop']) {
|
290 |
+
$this->setData('cart_expire', $datesCart['stop']->format('Y-m-d H:i:s'));
|
291 |
+
}
|
292 |
|
293 |
try {
|
294 |
$this->save();
|
297 |
}
|
298 |
}
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
/**
|
|
|
301 |
* @param bool $withVat
|
302 |
*
|
303 |
* @return float
|
304 |
*/
|
305 |
+
public function computeFirstOrderAmount($withVat = false)
|
306 |
{
|
307 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountInclTax $model */
|
308 |
$model = null;
|
312 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_firstorderamountexcltax');
|
313 |
}
|
314 |
|
315 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'));
|
316 |
}
|
317 |
|
318 |
/**
|
|
|
319 |
* @param bool $withVat
|
320 |
*
|
321 |
* @return float
|
322 |
*/
|
323 |
+
public function computeLastOrderAmount($withVat = false)
|
324 |
{
|
325 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountInclTax $model */
|
326 |
$model = null;
|
329 |
else {
|
330 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastorderamountexcltax');
|
331 |
}
|
332 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'));
|
333 |
}
|
334 |
|
335 |
/**
|
|
|
336 |
* @param array $dates
|
337 |
* @param bool $withVat
|
338 |
*
|
339 |
* @return float
|
340 |
*/
|
341 |
+
public function computeTotalOrdersAmount($dates = array(), $withVat = false)
|
342 |
{
|
343 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTax $model */
|
344 |
$model = null;
|
348 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderamountexcltax');
|
349 |
}
|
350 |
|
351 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
352 |
}
|
353 |
|
354 |
|
355 |
/**
|
|
|
356 |
* @param array $dates
|
357 |
* @param bool $withVat
|
358 |
*
|
359 |
* @return float
|
360 |
*/
|
361 |
+
public function computeAverageOrdersAmount($dates = array(), $withVat = false)
|
362 |
{
|
363 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax $model */
|
364 |
$model = null;
|
368 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgorderamountexcltax');
|
369 |
}
|
370 |
|
371 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
372 |
}
|
373 |
|
374 |
public function getAvgOrdersAmount($withVat = false)
|
384 |
}
|
385 |
|
386 |
/**
|
|
|
387 |
* @param array $dates
|
388 |
*
|
389 |
* @return float
|
390 |
*/
|
391 |
+
public function computeAverageProductCount($dates = array())
|
392 |
{
|
393 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbProductsPerOrder $model */
|
394 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbproductsperorder');
|
395 |
+
|
396 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
397 |
}
|
398 |
|
399 |
public function getAvgProductCount()
|
410 |
}
|
411 |
|
412 |
/**
|
|
|
413 |
*
|
414 |
* @param array $dates
|
415 |
* @return float
|
416 |
*/
|
417 |
+
public function computeAverageUniqueProductCount($dates = array())
|
418 |
{
|
419 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrder $model */
|
420 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbdifferentproductsperorder');
|
421 |
+
|
422 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
423 |
}
|
424 |
|
425 |
/**
|
428 |
* @param array $dates
|
429 |
* @return float
|
430 |
*/
|
431 |
+
public function computeAverageProductCountByCommandLine($dates = array())
|
432 |
{
|
433 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProductsPerOrderLine $model */
|
434 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_avgnbdifferentproductsperorderline');
|
435 |
|
436 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
437 |
}
|
438 |
|
439 |
/**
|
|
|
440 |
*
|
441 |
* @param array $dates
|
442 |
* @return float
|
443 |
*/
|
444 |
+
public function computeTotalProductCount($dates = array())
|
445 |
{
|
446 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts $model */
|
447 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorderedproducts');
|
448 |
|
449 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
450 |
}
|
451 |
|
452 |
/**
|
|
|
453 |
*
|
454 |
* @param array $dates
|
455 |
* @return float
|
456 |
*/
|
457 |
+
public function computeTotalOrdersCount($dates = array())
|
458 |
{
|
459 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders $model */
|
460 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_totalorders');
|
461 |
|
462 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
463 |
}
|
464 |
|
465 |
/**
|
466 |
+
*
|
467 |
* @param array $dates
|
468 |
* @param bool $withVat
|
469 |
*
|
470 |
* @return float
|
471 |
*/
|
472 |
+
public function computeLastUnorderedCartAmount($dates = array(), $withVat = false)
|
473 |
{
|
474 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountExclTax|Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountInclTax $model */
|
475 |
$model = null;
|
479 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_lastnotorderedcartamountexcltax');
|
480 |
}
|
481 |
|
482 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'), $dates);
|
483 |
}
|
484 |
|
485 |
/**
|
|
|
486 |
*
|
487 |
* @param array $dates
|
488 |
* @return float
|
489 |
*/
|
490 |
+
public function computeDiscountRuleCount()
|
491 |
{
|
492 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_NbPromotionRulesUsed $model */
|
493 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_int_nbpromotionrulesused');
|
494 |
|
495 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'));
|
496 |
}
|
497 |
|
498 |
/**
|
|
|
499 |
*
|
500 |
* @return DateTime
|
501 |
*/
|
502 |
+
public function getFirstOrderDate()
|
503 |
{
|
504 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder $model */
|
505 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_firstorder');
|
506 |
|
507 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'));
|
508 |
}
|
509 |
|
510 |
/**
|
|
|
511 |
*
|
512 |
* @return DateTime
|
513 |
*/
|
514 |
+
public function getLastOrderDate()
|
515 |
{
|
516 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder $model */
|
517 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_lastorder');
|
518 |
|
519 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'));
|
520 |
}
|
521 |
|
522 |
+
public function getLastTwoOrdersRange()
|
523 |
{
|
524 |
$readAdapter = $this->_getReadAdapter();
|
525 |
|
526 |
$tableName = null;
|
527 |
+
if($this->getDolistMainHelper()->isFlatTableEnabled()){
|
528 |
$tableName = 'sales_flat_order';
|
529 |
}else{
|
530 |
$tableName = 'sales_order';
|
533 |
/** @var Varien_Db_Select $select */
|
534 |
$select = $readAdapter->select();
|
535 |
$select->from(array('o' => $this->getTable($tableName)), array('o.created_at'))
|
536 |
+
->where('o.customer_id=?', $this->getData('customer_id'))
|
537 |
+
->where('o.store_id=?', $this->getData('store_id'))
|
538 |
->order('o.created_at DESC')
|
|
|
539 |
->limit(2)
|
540 |
;
|
541 |
|
|
|
542 |
$data = $readAdapter->fetchAll($select);
|
543 |
|
544 |
if(count($data) < 2) {
|
547 |
|
548 |
$diff = date_create_from_format('Y-m-d H:i:s', $data[1]['created_at'])->diff(date_create_from_format('Y-m-d H:i:s', $data[0]['created_at']));
|
549 |
|
|
|
550 |
return $diff->days;
|
551 |
}
|
552 |
|
553 |
/**
|
|
|
554 |
*
|
555 |
* @return DateTime
|
556 |
*/
|
557 |
+
public function getLastUnorderedCartDate()
|
558 |
{
|
559 |
/** @var Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered $model */
|
560 |
$model = Mage::getModel('dolist_mysql4/dolistv8_export_adapter_date_lastquotenotordered');
|
561 |
|
562 |
+
return $model->calculatedAttributeRequest($this->getData('customer_id'), $this->getData('store_id'));
|
563 |
}
|
564 |
|
565 |
/**
|
584 |
$tablePrefix = (string)Mage::getConfig()->getTablePrefix();
|
585 |
return $tablePrefix . $tableName;
|
586 |
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* @return Dolist_Net_Helper_Data
|
590 |
+
*/
|
591 |
+
public function getDolistMainHelper()
|
592 |
+
{
|
593 |
+
return Mage::helper('dolist');
|
594 |
+
}
|
595 |
}
|
app/code/community/Dolist/Net/Model/Exporter/Csv.php
CHANGED
@@ -10,9 +10,6 @@
|
|
10 |
*/
|
11 |
class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
12 |
{
|
13 |
-
private $_toExport;
|
14 |
-
private $_dolistToExport;
|
15 |
-
|
16 |
/**
|
17 |
* Constructor
|
18 |
*
|
@@ -21,73 +18,34 @@ class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
|
21 |
protected function _construct()
|
22 |
{
|
23 |
parent::_construct();
|
24 |
-
|
25 |
$this->setDelimiter(',');
|
26 |
$this->setEnclosure('"');
|
27 |
$this->setNoLineBreak(true);
|
28 |
}
|
29 |
|
30 |
-
/**
|
31 |
-
* Adds an object to export
|
32 |
-
*
|
33 |
-
* format:
|
34 |
-
* array(
|
35 |
-
* 'prefix' => '<string>' /// prefix to put before all data fields (in header row)
|
36 |
-
* 'object' => <Varien_Object>,
|
37 |
-
* 'fields' => array('field1','field2'), /// if ommited all fields are exported
|
38 |
-
* 'exclude' => array('field1','field2'), /// usefull if all fields but these must be exported
|
39 |
-
* )
|
40 |
-
*
|
41 |
-
* @param array $objectArray Object to export
|
42 |
-
*
|
43 |
-
* @return Dolist_Net_Model_Exporter_Csv
|
44 |
-
*/
|
45 |
-
public function addObjectToExport($objectArray)
|
46 |
-
{
|
47 |
-
$this->_toExport[] = $objectArray;
|
48 |
-
return $this;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Add subscriber to export queue
|
53 |
-
*
|
54 |
-
* @param Mage_Newsletter_Model_Subscriber $subscriber Newsletter subscriber
|
55 |
-
* @param mixed $dolistv8SystemConfig Config
|
56 |
-
*
|
57 |
-
* @return Dolist_Net_Model_Exporter_Csv
|
58 |
-
*/
|
59 |
-
public function setContactToExport($subscriber, $dolistv8SystemConfig)
|
60 |
-
{
|
61 |
-
$this->_dolistToExport = array(
|
62 |
-
'contact' => $subscriber,
|
63 |
-
'config' => $dolistv8SystemConfig
|
64 |
-
);
|
65 |
-
return $this;
|
66 |
-
}
|
67 |
-
|
68 |
/**
|
69 |
* render all objects previously added to a CSV file
|
70 |
*
|
71 |
* @param string $filename Filename
|
|
|
|
|
|
|
72 |
* @param mixed $addHeader auto => see $append, false => do not add, true => allways add
|
73 |
* @param boolean $append if set to true and the file already exists the content is added at the end of the file
|
74 |
* and the headers are not added (they are allready at the beginning of the file)
|
75 |
-
* @param bool|string $specificHeader Specific header key
|
76 |
-
* @param string $exportType Can be 'auto', or 'dolist'
|
77 |
-
*
|
78 |
* @param int $storeId
|
79 |
-
* @
|
80 |
-
* @return Smile_Interfaces_Model_Exporter_Csv
|
81 |
*/
|
82 |
-
public function export($filename, $
|
83 |
{
|
84 |
$varienCsv = new Varien_File_Csv();
|
85 |
|
86 |
$row = array();
|
87 |
if ($exportType == 'auto') {
|
88 |
-
$row = $this->
|
89 |
} elseif ($exportType == 'dolist') {
|
90 |
-
$row = $this->
|
91 |
}
|
92 |
|
93 |
//open the file
|
@@ -112,12 +70,7 @@ class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
|
112 |
$file = fopen($filename, $mode);
|
113 |
|
114 |
// Prepare header every time (needed to prepare cells even if empty)
|
115 |
-
$header =
|
116 |
-
if ($specificHeader == false) {
|
117 |
-
$header = array_keys($row);
|
118 |
-
} else if ($specificHeader == 'contact_header') {
|
119 |
-
$header = array_keys($this->getMapping(Mage::app()->getRequest()->getParam('store', $storeId)));
|
120 |
-
}
|
121 |
|
122 |
// but add the header only if needed
|
123 |
if ($addHeader) {
|
@@ -143,8 +96,7 @@ class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
|
143 |
fclose($file);
|
144 |
|
145 |
} catch (Exception $e) {
|
146 |
-
|
147 |
-
Mage::throwException($e->getMessage());
|
148 |
}
|
149 |
|
150 |
return $this;
|
@@ -153,153 +105,194 @@ class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
|
153 |
/**
|
154 |
* Return row to export - automatic method
|
155 |
*
|
|
|
156 |
* @return array
|
157 |
*/
|
158 |
-
protected function
|
159 |
{
|
160 |
$row = array();
|
161 |
//fill the row
|
162 |
-
$this->_getHelper(print_r($this->_toExport));
|
163 |
-
foreach ($this->_toExport as $exportObj) {
|
164 |
-
$this->_getHelper(print_r($exportObj));
|
165 |
-
//transform this array in local variables to have a more readable code
|
166 |
-
$obj = $exportObj['object'];
|
167 |
-
$prefix = "";
|
168 |
-
if (isset($exportObj['prefix'])) {
|
169 |
-
$prefix = $exportObj['prefix'];
|
170 |
-
}
|
171 |
-
$fields = false;
|
172 |
-
if (isset($exportObj['fields'])) {
|
173 |
-
$fields = $exportObj['fields'];
|
174 |
-
}
|
175 |
-
$exclude = false;
|
176 |
-
if (!$fields && isset($exportObj['exclude'])) {
|
177 |
-
$exclude = $exportObj['exclude'];
|
178 |
-
}
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
}
|
189 |
-
$row[$prefix . $k] = $this->_checkValueBeforeInsert($v);
|
190 |
}
|
|
|
|
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
}
|
205 |
}
|
206 |
}
|
207 |
}
|
208 |
-
return $row;
|
209 |
-
}
|
210 |
|
211 |
-
|
212 |
-
* @param $storeId
|
213 |
-
* @return array
|
214 |
-
*/
|
215 |
-
protected function getMapping($storeId)
|
216 |
-
{
|
217 |
-
/** @var Dolist_Net_Model_Dolistv8_Customfields $model */
|
218 |
-
$model = Mage::getModel('dolist/dolistv8_customfields');
|
219 |
-
return $model->getMapping($storeId);
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
* Return row to export - dolist method
|
224 |
*
|
225 |
* @param $storeId
|
|
|
226 |
* @return array
|
227 |
*/
|
228 |
-
|
229 |
{
|
230 |
$row = array();
|
231 |
|
232 |
$mappingConfig = $this->getMapping($storeId);
|
233 |
|
234 |
-
$contact = $this->_dolistToExport['contact'];
|
235 |
-
|
236 |
// If customer exists, load it
|
237 |
/** @var Mage_Customer_Model_Customer $customer */
|
238 |
$customer = null;
|
239 |
$forceAbonneNewsletter = false;
|
240 |
|
|
|
|
|
|
|
241 |
if (is_array($contact) && array_key_exists('customer_id', $contact) && filter_var($contact['customer_id'], FILTER_VALIDATE_INT) !== false) {
|
242 |
$customer = Mage::getModel('customer/customer')->load($contact['customer_id']);
|
243 |
} else {
|
244 |
-
// If no customer exists, create a fictive customer (but DO NOT save it) with email, only in order to be exported
|
245 |
-
$this->_getHelper()->logDebug('CustomerId : ' . $contact['customer_id']);
|
246 |
$customer = Mage::getModel('customer/customer');
|
247 |
-
$customer->setData('email', $contact['customer_id']);
|
248 |
|
249 |
-
|
250 |
-
$
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
252 |
|
|
|
|
|
|
|
|
|
253 |
|
254 |
/** @var Dolist_Net_Model_Dolistv8_Calculatedfields $dolistCalculatedFieldsModel */
|
255 |
$dolistCalculatedFieldsModel = Mage::getModel('dolist/dolistv8_calculatedfields');
|
|
|
|
|
256 |
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode", $storeId);
|
257 |
$configStartDate = ($config == Dolist_Net_Model_Dolistv8_Calculatedfields::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date", $storeId) : null;
|
|
|
258 |
|
259 |
foreach ($mappingConfig as $dolistHeader => $magentoAttributeCode) {
|
260 |
$v = '';
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
if (!$dolistCalculatedFieldsModel->getId()) {
|
263 |
-
$
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
280 |
}
|
281 |
|
|
|
282 |
if ($magentoAttributeCode['field'] == 'avg_order_amount_excl_tax') {
|
283 |
-
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
284 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgOrdersAmount());
|
285 |
} elseif ($magentoAttributeCode['field'] == 'avg_order_amount_incl_tax') {
|
286 |
-
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
287 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgOrdersAmount(true));
|
288 |
} elseif ($magentoAttributeCode['field'] == 'avg_nb_products_per_order') {
|
289 |
-
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
290 |
-
|
291 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgProductCount());
|
292 |
-
|
293 |
-
} elseif ($magentoAttributeCode['field'] == 'is_subscriber') {
|
294 |
-
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
295 |
-
$subscriber = null;
|
296 |
-
if (!$forceAbonneNewsletter) {
|
297 |
-
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
|
298 |
-
}
|
299 |
-
|
300 |
-
$v = $adapter->getExportedValue($forceAbonneNewsletter || $subscriber->getData('subscriber_status') == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED ? $this->_getHelper()->__('newsletter subscriber') : $this->_getHelper()->__('not subscribed newsletter'));
|
301 |
} else {
|
302 |
-
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
303 |
// Calculated fields
|
304 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getData($magentoAttributeCode['field']));
|
305 |
}
|
@@ -371,6 +364,17 @@ class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
|
371 |
return $row;
|
372 |
}
|
373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
/**
|
375 |
* Check a value before inserting it into a CSV file
|
376 |
*
|
10 |
*/
|
11 |
class Dolist_Net_Model_Exporter_Csv extends Varien_Object
|
12 |
{
|
|
|
|
|
|
|
13 |
/**
|
14 |
* Constructor
|
15 |
*
|
18 |
protected function _construct()
|
19 |
{
|
20 |
parent::_construct();
|
21 |
+
|
22 |
$this->setDelimiter(',');
|
23 |
$this->setEnclosure('"');
|
24 |
$this->setNoLineBreak(true);
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
/**
|
28 |
* render all objects previously added to a CSV file
|
29 |
*
|
30 |
* @param string $filename Filename
|
31 |
+
* @param $contact
|
32 |
+
*
|
33 |
+
* @param string $exportType
|
34 |
* @param mixed $addHeader auto => see $append, false => do not add, true => allways add
|
35 |
* @param boolean $append if set to true and the file already exists the content is added at the end of the file
|
36 |
* and the headers are not added (they are allready at the beginning of the file)
|
|
|
|
|
|
|
37 |
* @param int $storeId
|
38 |
+
* @return $this
|
|
|
39 |
*/
|
40 |
+
public function export($filename, $contact, $exportType = 'auto', $addHeader = 'auto', $append = true, $storeId = 0)
|
41 |
{
|
42 |
$varienCsv = new Varien_File_Csv();
|
43 |
|
44 |
$row = array();
|
45 |
if ($exportType == 'auto') {
|
46 |
+
$row = $this->autoExportGetRow($contact);
|
47 |
} elseif ($exportType == 'dolist') {
|
48 |
+
$row = $this->dolistExportGetRow($storeId, $contact);
|
49 |
}
|
50 |
|
51 |
//open the file
|
70 |
$file = fopen($filename, $mode);
|
71 |
|
72 |
// Prepare header every time (needed to prepare cells even if empty)
|
73 |
+
$header = array_keys($this->getMapping(Mage::app()->getRequest()->getParam('store', $storeId)));
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
// but add the header only if needed
|
76 |
if ($addHeader) {
|
96 |
fclose($file);
|
97 |
|
98 |
} catch (Exception $e) {
|
99 |
+
// file allready closed
|
|
|
100 |
}
|
101 |
|
102 |
return $this;
|
105 |
/**
|
106 |
* Return row to export - automatic method
|
107 |
*
|
108 |
+
* @param $contact
|
109 |
* @return array
|
110 |
*/
|
111 |
+
protected function autoExportGetRow($contact)
|
112 |
{
|
113 |
$row = array();
|
114 |
//fill the row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
+
//transform this array in local variables to have a more readable code
|
117 |
+
$obj = $contact['object'];
|
118 |
+
$prefix = "";
|
119 |
+
if (isset($contact['prefix'])) {
|
120 |
+
$prefix = $contact['prefix'];
|
121 |
+
}
|
122 |
+
$fields = false;
|
123 |
+
if (isset($contact['fields'])) {
|
124 |
+
$fields = $contact['fields'];
|
125 |
+
}
|
126 |
+
$exclude = false;
|
127 |
+
if (!$fields && isset($contact['exclude'])) {
|
128 |
+
$exclude = $contact['exclude'];
|
129 |
+
}
|
130 |
+
|
131 |
+
//check all fields
|
132 |
+
if ($fields !== false) {
|
133 |
+
// only some fields must be added
|
134 |
|
135 |
+
foreach ($fields as $k) {
|
136 |
+
$v = "-"; //avoid empty columns causing problems with the header
|
137 |
+
if ($obj->hasData($k) && $obj->getData($k) != '') {
|
138 |
+
$v = $obj->getData($k);
|
|
|
|
|
139 |
}
|
140 |
+
$row[$prefix . $k] = $this->_checkValueBeforeInsert($v);
|
141 |
+
}
|
142 |
|
143 |
+
} else {
|
144 |
+
foreach ($obj->getData() as $k => $v) {
|
145 |
+
$add = true;
|
146 |
|
147 |
+
if ($exclude !== false) {
|
148 |
+
//some fields musn't be exported
|
149 |
+
$add = !array_key_exists($k, $exclude);
|
150 |
+
}
|
151 |
|
152 |
+
if ($add) {
|
153 |
+
//add this field to the current row!
|
154 |
+
$row[$prefix . $k] = $this->_checkValueBeforeInsert($v);
|
|
|
155 |
}
|
156 |
}
|
157 |
}
|
|
|
|
|
158 |
|
159 |
+
return $row;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
* Return row to export - dolist method
|
164 |
*
|
165 |
* @param $storeId
|
166 |
+
* @param $contact
|
167 |
* @return array
|
168 |
*/
|
169 |
+
public function dolistExportGetRow($storeId, $contact)
|
170 |
{
|
171 |
$row = array();
|
172 |
|
173 |
$mappingConfig = $this->getMapping($storeId);
|
174 |
|
|
|
|
|
175 |
// If customer exists, load it
|
176 |
/** @var Mage_Customer_Model_Customer $customer */
|
177 |
$customer = null;
|
178 |
$forceAbonneNewsletter = false;
|
179 |
|
180 |
+
/** @var Mage_Core_Model_Store $store */
|
181 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
182 |
+
|
183 |
if (is_array($contact) && array_key_exists('customer_id', $contact) && filter_var($contact['customer_id'], FILTER_VALIDATE_INT) !== false) {
|
184 |
$customer = Mage::getModel('customer/customer')->load($contact['customer_id']);
|
185 |
} else {
|
|
|
|
|
186 |
$customer = Mage::getModel('customer/customer');
|
|
|
187 |
|
188 |
+
$customer->setWebsiteId($store->getWebsiteId());
|
189 |
+
$customer->loadByEmail($contact['customer_id']);
|
190 |
+
|
191 |
+
if (!$customer->getId()) {
|
192 |
+
// If no customer exists, create a fictive customer (but DO NOT save it) with email, only in order to be exported
|
193 |
+
$this->_getHelper()->logDebug('CustomerId : ' . $contact['customer_id']);
|
194 |
+
$customer = Mage::getModel('customer/customer');
|
195 |
+
$customer->setData('email', $contact['customer_id']);
|
196 |
|
197 |
+
//
|
198 |
+
$forceAbonneNewsletter = true;
|
199 |
+
}
|
200 |
+
}
|
201 |
|
202 |
/** @var Dolist_Net_Model_Dolistv8_Calculatedfields $dolistCalculatedFieldsModel */
|
203 |
$dolistCalculatedFieldsModel = Mage::getModel('dolist/dolistv8_calculatedfields');
|
204 |
+
$dolistCalculatedFieldsModel->setStoreId($storeId);
|
205 |
+
|
206 |
$config = Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_mode", $storeId);
|
207 |
$configStartDate = ($config == Dolist_Net_Model_Dolistv8_Calculatedfields::BEGIN_DATE) ? Mage::getStoreConfig("dolist/dolist_v8/calculatedfieds_date", $storeId) : null;
|
208 |
+
$computed = false;
|
209 |
|
210 |
foreach ($mappingConfig as $dolistHeader => $magentoAttributeCode) {
|
211 |
$v = '';
|
212 |
+
/** @var Dolist_Net_Model_Exporter_Adapter_Default $adapter */
|
213 |
+
$adapter = Mage::getModel($magentoAttributeCode['adapter']);
|
214 |
+
|
215 |
+
if ($magentoAttributeCode['field'] == 'is_subscriber') {
|
216 |
+
$subscriber = null;
|
217 |
+
if (!$forceAbonneNewsletter) {
|
218 |
+
$subscriber = $this->_getHelper()->loadSubscriberByCustomer($customer, $storeId);
|
219 |
+
}
|
220 |
+
else {
|
221 |
+
$subscriber = $this->_getHelper()->loadSubscriberByEmail($contact['customer_id'], $storeId);
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
// 0 : not subscribed
|
226 |
+
// 1 : subscribed
|
227 |
+
// 2 : unsubscribed
|
228 |
+
// 3 : dolist error
|
229 |
+
if ($subscriber && ($forceAbonneNewsletter || ($subscriber instanceof Mage_Newsletter_Model_Subscriber && strlen($subscriber->getData('subscriber_status')) != 0))) {
|
230 |
+
switch($subscriber->getData('subscriber_status')) {
|
231 |
+
case 0:
|
232 |
+
$v = 0;
|
233 |
+
break;
|
234 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED:
|
235 |
+
$v = 1;
|
236 |
+
break;
|
237 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED:
|
238 |
+
$v = 2;
|
239 |
+
break;
|
240 |
+
default:
|
241 |
+
$v = 3;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
else {
|
245 |
+
$v = 0;
|
246 |
+
}
|
247 |
+
|
248 |
+
$v = $adapter->getExportedValue($v);
|
249 |
+
|
250 |
+
} else if ($customer->getId() && $dolistCalculatedFieldsModel->isCalculatedFieldConfig($magentoAttributeCode['field'])) {
|
251 |
+
if (!$dolistCalculatedFieldsModel->getId()) {
|
252 |
+
$this->_getHelper()->logDebug(sprintf('Try to load calculatedfields for customerId %s and store %s', $customer->getId(), $storeId));
|
253 |
+
$dolistCalculatedFieldsModel->loadByCustomerId($customer->getId());
|
254 |
+
}
|
255 |
+
|
256 |
if (!$dolistCalculatedFieldsModel->getId()) {
|
257 |
+
$this->_getHelper()->logDebug('Missing calculatedfields. Create it');
|
258 |
+
$dolistCalculatedFieldsModel->compute();
|
259 |
+
$computed = true;
|
260 |
+
} elseif ($dolistCalculatedFieldsModel->getData('order_expire') && ($dolistCalculatedFieldsModel->getData('orders_expire')) <= time()) {
|
261 |
+
if (!$computed) {
|
262 |
+
$this->_getHelper()->logDebug('Calculatedfield is expired. Refresh it');
|
263 |
+
$dolistCalculatedFieldsModel->compute();
|
264 |
+
$computed = true;
|
265 |
+
}
|
266 |
+
} elseif ((!$dolistCalculatedFieldsModel->getData('first_order_amount') || $dolistCalculatedFieldsModel->getData('first_order_amount') == 0 || !$dolistCalculatedFieldsModel->getData('last_order_amount') || strlen($dolistCalculatedFieldsModel->getData('first_order_date')) > 0)) {
|
267 |
+
if (!$computed) {
|
268 |
+
$this->_getHelper()->logDebug('Calculatedfield is empty. Refresh it');
|
269 |
+
$dolistCalculatedFieldsModel->compute();
|
270 |
+
$computed = true;
|
271 |
+
}
|
272 |
+
} elseif ($dolistCalculatedFieldsModel->getData('config') != $config || $dolistCalculatedFieldsModel->getData('start_date') != $configStartDate) {
|
273 |
+
// Calculated fields config has changed
|
274 |
+
if (!$computed) {
|
275 |
+
$this->_getHelper()->logDebug('Calculatedfield config has changed. Refresh it');
|
276 |
+
$dolistCalculatedFieldsModel->compute();
|
277 |
+
$computed = true;
|
278 |
+
}
|
279 |
+
} elseif (strpos($magentoAttributeCode['field'], 'last_unordered_cart_') === 0) {
|
280 |
+
// Always
|
281 |
+
if (!$computed) {
|
282 |
+
$this->_getHelper()->logDebug('Unordered cart data used. Refresg calculatedfield');
|
283 |
+
$dolistCalculatedFieldsModel->compute();
|
284 |
+
$computed = true;
|
285 |
}
|
286 |
}
|
287 |
|
288 |
+
|
289 |
if ($magentoAttributeCode['field'] == 'avg_order_amount_excl_tax') {
|
|
|
290 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgOrdersAmount());
|
291 |
} elseif ($magentoAttributeCode['field'] == 'avg_order_amount_incl_tax') {
|
|
|
292 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgOrdersAmount(true));
|
293 |
} elseif ($magentoAttributeCode['field'] == 'avg_nb_products_per_order') {
|
|
|
|
|
294 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getAvgProductCount());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
} else {
|
|
|
296 |
// Calculated fields
|
297 |
$v = $adapter->getExportedValue($dolistCalculatedFieldsModel->getData($magentoAttributeCode['field']));
|
298 |
}
|
364 |
return $row;
|
365 |
}
|
366 |
|
367 |
+
/**
|
368 |
+
* @param $storeId
|
369 |
+
* @return array
|
370 |
+
*/
|
371 |
+
protected function getMapping($storeId)
|
372 |
+
{
|
373 |
+
/** @var Dolist_Net_Model_Dolistv8_Customfields $model */
|
374 |
+
$model = Mage::getModel('dolist/dolistv8_customfields');
|
375 |
+
return $model->getMapping($storeId);
|
376 |
+
}
|
377 |
+
|
378 |
/**
|
379 |
* Check a value before inserting it into a CSV file
|
380 |
*
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Calculatedfields.php
CHANGED
@@ -9,7 +9,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields extends Mage_Core_Model_
|
|
9 |
protected function _construct()
|
10 |
{
|
11 |
$this->_isPkAutoIncrement=false;
|
12 |
-
$this->_init('dolist/dolistv8_calculatedfields', '
|
13 |
}
|
14 |
|
15 |
/**
|
@@ -41,4 +41,53 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Calculatedfields extends Mage_Core_Model_
|
|
41 |
$row = $readAdapter->fetchOne($select);
|
42 |
return $row;
|
43 |
}
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
protected function _construct()
|
10 |
{
|
11 |
$this->_isPkAutoIncrement=false;
|
12 |
+
$this->_init('dolist/dolistv8_calculatedfields', 'id');
|
13 |
}
|
14 |
|
15 |
/**
|
41 |
$row = $readAdapter->fetchOne($select);
|
42 |
return $row;
|
43 |
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrieve select object for loading base entity row
|
47 |
+
*
|
48 |
+
* @param string $field
|
49 |
+
* @param mixed $value
|
50 |
+
* @param Mage_Core_Model_Abstract $object
|
51 |
+
* @return Varien_Db_Select
|
52 |
+
* @throws Exception
|
53 |
+
*/
|
54 |
+
protected function _getLoadSelect($field, $value, $object)
|
55 |
+
{
|
56 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
57 |
+
if ($object->getStoreId()) {
|
58 |
+
$storeIdField = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), 'store_id'));
|
59 |
+
$select->where($storeIdField . '=?', (int)$object->getStoreId());
|
60 |
+
}
|
61 |
+
else {
|
62 |
+
throw new \Exception('Unable to load calculated field without store_id');
|
63 |
+
}
|
64 |
+
|
65 |
+
return $select;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Load calculated field by customer id
|
70 |
+
* @param Dolist_Net_Model_Dolistv8_Calculatedfields $object
|
71 |
+
* @param $customerId
|
72 |
+
* @param bool $testOnly
|
73 |
+
* @return $this
|
74 |
+
* @throws Exception
|
75 |
+
*/
|
76 |
+
public function loadByCustomerId(Dolist_Net_Model_Dolistv8_Calculatedfields $object, $customerId, $testOnly = false)
|
77 |
+
{
|
78 |
+
$adapter = $this->_getReadAdapter();
|
79 |
+
$select = $this->_getLoadSelect('customer_id', $customerId, $object);
|
80 |
+
|
81 |
+
$objectId = $adapter->fetchOne($select);
|
82 |
+
if ($objectId) {
|
83 |
+
$this->load($object, $objectId);
|
84 |
+
} else {
|
85 |
+
$object->setData(array(
|
86 |
+
'store_id' => $object->getData('store_id'),
|
87 |
+
'customer_id' => $customerId,
|
88 |
+
));
|
89 |
+
}
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Firstorder.php
CHANGED
@@ -11,66 +11,11 @@
|
|
11 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
{
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @
|
17 |
-
* @param Varien_Object $config Config for this attribute
|
18 |
-
*
|
19 |
-
* @return string Exported value
|
20 |
*/
|
21 |
-
public function
|
22 |
-
{
|
23 |
-
// Load array from cache
|
24 |
-
$serializedData = Mage::app()->loadCache(get_class($this));
|
25 |
-
$cacheArray = unserialize($serializedData);
|
26 |
-
$value = '';
|
27 |
-
|
28 |
-
// Return value if in array
|
29 |
-
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
30 |
-
$value = $cacheArray[$customer->getEmail()]['created_at'];
|
31 |
-
$value = $this->formatDate($value);
|
32 |
-
}
|
33 |
-
|
34 |
-
return $value;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Perform SQl request for calculated attribute and save result in cache
|
39 |
-
* Call to this method is performed before exporting, to be done only once.
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function performCalculatedAttributeRequest()
|
44 |
-
{
|
45 |
-
$readAdapter = $this->_getReadAdapter();
|
46 |
-
|
47 |
-
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
48 |
-
$tableName = 'sales_flat_order';
|
49 |
-
$select = $readAdapter->select()
|
50 |
-
->from($this->getTable($tableName), array('customer_email', 'MIN(created_at) AS created_at'))
|
51 |
-
->group('customer_email');
|
52 |
-
} else {
|
53 |
-
$tableName = 'sales_order';
|
54 |
-
$customerTableName = 'customer_entity';
|
55 |
-
$select = $readAdapter->select()
|
56 |
-
->from(array('sa' => $this->getTable($tableName)), array('ce.email AS customer_email', 'MIN(sa.created_at) AS created_at'))
|
57 |
-
->join(
|
58 |
-
array('ce' => $this->getTable($customerTableName)),
|
59 |
-
"ce.entity_id=sa.customer_id",
|
60 |
-
array()
|
61 |
-
)
|
62 |
-
->group('customer_email');
|
63 |
-
//SELECT ce.email as customer_email, min(o.created_at) as created_at FROM sales_order AS o INNER JOIN customer_entity ce ON ce.entity_id = o.customer_id GROUP BY o.customer_id;
|
64 |
-
}
|
65 |
-
|
66 |
-
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
67 |
-
$serializedData = serialize($rows);
|
68 |
-
|
69 |
-
// Save array to cache: use class_name as cache key
|
70 |
-
Mage::app()->saveCache($serializedData, get_class($this));
|
71 |
-
}
|
72 |
-
|
73 |
-
public function calculatedAttributeRequest($customerId)
|
74 |
{
|
75 |
$readAdapter = $this->_getReadAdapter();
|
76 |
|
@@ -86,7 +31,8 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder extends Do
|
|
86 |
array(
|
87 |
'date' => 'MIN(created_at)'
|
88 |
))
|
89 |
-
->where('o.customer_id = ?', $customerId)
|
|
|
90 |
|
91 |
$row = $readAdapter->fetchOne($select);
|
92 |
return $row;
|
11 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_FirstOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
{
|
13 |
/**
|
14 |
+
* @param int $customerId
|
15 |
+
* @param int $storeId
|
16 |
+
* @return mixed
|
|
|
|
|
|
|
17 |
*/
|
18 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
{
|
20 |
$readAdapter = $this->_getReadAdapter();
|
21 |
|
31 |
array(
|
32 |
'date' => 'MIN(created_at)'
|
33 |
))
|
34 |
+
->where('o.customer_id = ?', $customerId)
|
35 |
+
->where('o.store_id = ?', $storeId);
|
36 |
|
37 |
$row = $readAdapter->fetchOne($select);
|
38 |
return $row;
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastorder.php
CHANGED
@@ -10,66 +10,11 @@
|
|
10 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
{
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @
|
16 |
-
* @param Varien_Object $config Config for this attribute
|
17 |
-
*
|
18 |
-
* @return void
|
19 |
*/
|
20 |
-
public function
|
21 |
-
{
|
22 |
-
// Load array from cache
|
23 |
-
$serializedData = Mage::app()->loadCache(get_class($this));
|
24 |
-
$cacheArray = unserialize($serializedData);
|
25 |
-
$value = '';
|
26 |
-
|
27 |
-
// Return value if in array
|
28 |
-
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
29 |
-
$value = $cacheArray[$customer->getEmail()]['created_at'];
|
30 |
-
$value = $this->formatDate($value);
|
31 |
-
}
|
32 |
-
|
33 |
-
return $value;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Perform SQl request for calculated attribute and save result in cache
|
38 |
-
* Call to this method is performed before exporting, to be done only once.
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
-
*/
|
42 |
-
public function performCalculatedAttributeRequest()
|
43 |
-
{
|
44 |
-
$readAdapter = $this->_getReadAdapter();
|
45 |
-
|
46 |
-
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
47 |
-
$tableName = 'sales_flat_order';
|
48 |
-
$select = $readAdapter->select()
|
49 |
-
->from($this->getTable($tableName), array('customer_email', 'MAX(created_at) AS created_at'))
|
50 |
-
->group('customer_email');
|
51 |
-
}else{
|
52 |
-
$tableName = 'sales_order';
|
53 |
-
$customerTableName = 'customer_entity';
|
54 |
-
$select = $readAdapter->select()
|
55 |
-
->from(array('sa' => $this->getTable($tableName)), array('ce.email AS customer_email', 'MAX(sa.created_at) AS created_at'))
|
56 |
-
->join(
|
57 |
-
array('ce' => $this->getTable($customerTableName)),
|
58 |
-
"ce.entity_id=sa.customer_id",
|
59 |
-
array()
|
60 |
-
)
|
61 |
-
->group('customer_email');
|
62 |
-
//SELECT ce.email as customer_email, max(o.created_at) as created_at FROM sales_order AS o INNER JOIN customer_entity ce ON ce.entity_id = o.customer_id GROUP BY o.customer_id;
|
63 |
-
}
|
64 |
-
|
65 |
-
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
66 |
-
$serializedData = serialize($rows);
|
67 |
-
|
68 |
-
// Save array to cache: use class_name as cache key
|
69 |
-
Mage::app()->saveCache($serializedData, get_class($this));
|
70 |
-
}
|
71 |
-
|
72 |
-
public function calculatedAttributeRequest($customerId)
|
73 |
{
|
74 |
$readAdapter = $this->_getReadAdapter();
|
75 |
|
@@ -86,7 +31,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder extends Dol
|
|
86 |
'date'=>'MAX(created_at)'
|
87 |
))
|
88 |
->where('o.customer_id = ?', $customerId)
|
89 |
-
|
90 |
|
91 |
|
92 |
$row = $readAdapter->fetchOne($select);
|
10 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastOrder extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
{
|
12 |
/**
|
13 |
+
* @param int $customerId
|
14 |
+
* @param int $storeId
|
15 |
+
* @return mixed
|
|
|
|
|
|
|
16 |
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
{
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
|
31 |
'date'=>'MAX(created_at)'
|
32 |
))
|
33 |
->where('o.customer_id = ?', $customerId)
|
34 |
+
->where('o.store_id = ?', $storeId);
|
35 |
|
36 |
|
37 |
$row = $readAdapter->fetchOne($select);
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Date/Lastquotenotordered.php
CHANGED
@@ -7,173 +7,18 @@
|
|
7 |
* @copyright 2012 Dolist
|
8 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
*/
|
10 |
-
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered
|
11 |
-
extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
{
|
13 |
/**
|
14 |
-
*
|
15 |
-
*
|
16 |
-
* @
|
17 |
-
* @param Varien_Object $config Config for this attribute
|
18 |
-
*
|
19 |
-
* @return void
|
20 |
*/
|
21 |
-
public function
|
22 |
{
|
23 |
-
// Load array from cache
|
24 |
-
$serializedData = Mage::app()->loadCache(get_class($this));
|
25 |
-
$cacheArray = unserialize($serializedData);
|
26 |
-
$value = '';
|
27 |
-
|
28 |
-
// Return value if in array
|
29 |
-
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
30 |
-
$value = $cacheArray[$customer->getEmail()]['created_at'];
|
31 |
-
$value = $this->formatDate($value);
|
32 |
-
}
|
33 |
-
|
34 |
-
return $value;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Perform SQl request for calculated attribute and save result in cache
|
39 |
-
* Call to this method is performed before exporting, to be done only once.
|
40 |
-
*
|
41 |
-
* @return void
|
42 |
-
*/
|
43 |
-
public function performCalculatedAttributeRequest()
|
44 |
-
{
|
45 |
-
$readAdapter = $this->_getReadAdapter();
|
46 |
-
|
47 |
-
$quoteTableName = 'sales_flat_quote';
|
48 |
-
$orderTableName = 'sales_flat_order';
|
49 |
-
$customerTableName = 'customer_entity';
|
50 |
-
|
51 |
-
|
52 |
-
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
53 |
-
// Nested request
|
54 |
-
$nestedRequest = $readAdapter->select()
|
55 |
-
->from(
|
56 |
-
array('q' => $this->getTable($quoteTableName)),
|
57 |
-
array(
|
58 |
-
'q.entity_id AS quote_id',
|
59 |
-
'q.customer_id',
|
60 |
-
'q.created_at'
|
61 |
-
)
|
62 |
-
)
|
63 |
-
->joinLeft(
|
64 |
-
array('o' => $this->getTable($orderTableName)),
|
65 |
-
"q.entity_id=o.quote_id",
|
66 |
-
array()
|
67 |
-
)
|
68 |
-
->where('o.entity_id IS NULL')
|
69 |
-
->order('q.created_at DESC');
|
70 |
-
|
71 |
-
$select = $readAdapter->select()
|
72 |
-
->from(
|
73 |
-
array('l' => $nestedRequest),
|
74 |
-
array(
|
75 |
-
'c.email AS customer_email',
|
76 |
-
'l.created_at'
|
77 |
-
)
|
78 |
-
)
|
79 |
-
->join(
|
80 |
-
array('c' => $this->getTable($customerTableName)),
|
81 |
-
"c.entity_id=l.customer_id",
|
82 |
-
array()
|
83 |
-
)
|
84 |
-
->group('l.customer_id');
|
85 |
-
|
86 |
-
/*
|
87 |
-
* MySQL request
|
88 |
-
SELECT customer_entity.email, last_not_ordered_carts.created_at
|
89 |
-
FROM
|
90 |
-
(
|
91 |
-
SELECT sales_flat_quote.entity_id AS quote_id, sales_flat_quote.customer_id, sales_flat_quote.created_at
|
92 |
-
FROM sales_flat_quote
|
93 |
-
LEFT JOIN sales_flat_order ON sales_flat_quote.entity_id = sales_flat_order.quote_id
|
94 |
-
WHERE sales_flat_order.entity_id IS NULL
|
95 |
-
ORDER BY sales_flat_quote.created_at DESC
|
96 |
-
)
|
97 |
-
AS last_not_ordered_carts
|
98 |
-
INNER JOIN customer_entity ON customer_entity.entity_id = last_not_ordered_carts.customer_id
|
99 |
-
GROUP BY last_not_ordered_carts.customer_id
|
100 |
-
*/
|
101 |
-
}else{
|
102 |
-
$quoteTableName = 'sales_flat_quote';
|
103 |
-
$customerTableName = 'customer_entity';
|
104 |
-
$orderTableName = 'sales_order';
|
105 |
-
$attributeTableName = 'sales_order_int';
|
106 |
-
$eavTableName = 'eav_attribute';
|
107 |
-
$nestedRequest = $readAdapter->select()
|
108 |
-
->from(
|
109 |
-
array('q' => $this->getTable($quoteTableName)),
|
110 |
-
array(
|
111 |
-
'q.entity_id AS quote_id',
|
112 |
-
'q.customer_id',
|
113 |
-
'q.created_at'
|
114 |
-
)
|
115 |
-
)
|
116 |
-
->joinLeft(
|
117 |
-
array('e' => $this->getTable($eavTableName)),
|
118 |
-
"e.attribute_code='quote_id'",
|
119 |
-
array()
|
120 |
-
)
|
121 |
-
->joinLeft(
|
122 |
-
array('a' => $this->getTable($attributeTableName)),
|
123 |
-
"a.value=q.entity_id AND a.attribute_id = e.attribute_id",
|
124 |
-
array()
|
125 |
-
)
|
126 |
-
->joinLeft(
|
127 |
-
array('o' => $this->getTable($orderTableName)),
|
128 |
-
"a.entity_id=o.entity_id",
|
129 |
-
array()
|
130 |
-
)
|
131 |
-
->where('o.entity_id IS NULL')
|
132 |
-
->order('q.created_at DESC');
|
133 |
-
|
134 |
-
$select = $readAdapter->select()
|
135 |
-
->from(
|
136 |
-
array('l' => $nestedRequest),
|
137 |
-
array(
|
138 |
-
'c.email AS customer_email',
|
139 |
-
'l.created_at'
|
140 |
-
)
|
141 |
-
)
|
142 |
-
->join(
|
143 |
-
array('c' => $this->getTable($customerTableName)),
|
144 |
-
"c.entity_id=l.customer_id",
|
145 |
-
array()
|
146 |
-
)
|
147 |
-
->group('l.customer_id');
|
148 |
-
|
149 |
-
/*
|
150 |
-
* MySQL request
|
151 |
-
SELECT customer_entity.email, last_not_ordered_carts.created_at
|
152 |
-
FROM
|
153 |
-
(
|
154 |
-
SELECT sales_flat_quote.entity_id AS quote_id, sales_flat_quote.customer_id, sales_flat_quote.created_at
|
155 |
-
FROM sales_flat_quote
|
156 |
-
LEFT JOIN sales_flat_order ON sales_flat_quote.entity_id = sales_flat_order.quote_id
|
157 |
-
WHERE sales_flat_order.entity_id IS NULL
|
158 |
-
ORDER BY sales_flat_quote.created_at DESC
|
159 |
-
)
|
160 |
-
AS last_not_ordered_carts
|
161 |
-
INNER JOIN customer_entity ON customer_entity.entity_id = last_not_ordered_carts.customer_id
|
162 |
-
GROUP BY last_not_ordered_carts.customer_id
|
163 |
-
*/
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
168 |
-
$serializedData = serialize($rows);
|
169 |
-
|
170 |
-
// Save array to cache: use class_name as cache key
|
171 |
-
Mage::app()->saveCache($serializedData, get_class($this));
|
172 |
-
}
|
173 |
-
|
174 |
-
public function calculatedAttributeRequest($customerId){
|
175 |
$readAdapter = $this->_getReadAdapter();
|
176 |
$quoteTableName = null;
|
|
|
177 |
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
178 |
$quoteTableName = 'sales_flat_quote';
|
179 |
} else {
|
@@ -184,12 +29,14 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered
|
|
184 |
->from(
|
185 |
array('q' => $this->getTable($quoteTableName)),
|
186 |
array(
|
187 |
-
'q.
|
188 |
)
|
189 |
)
|
190 |
->where('q.customer_id = ?', $customerId)
|
191 |
-
->where('q.
|
192 |
-
->
|
|
|
|
|
193 |
|
194 |
$row = $readAdapter->fetchOne($request);
|
195 |
return $row;
|
7 |
* @copyright 2012 Dolist
|
8 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
9 |
*/
|
10 |
+
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Date_LastQuoteNotOrdered extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
|
|
11 |
{
|
12 |
/**
|
13 |
+
* @param int $customerId
|
14 |
+
* @param int $storeId
|
15 |
+
* @return mixed
|
|
|
|
|
|
|
16 |
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
18 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
$quoteTableName = null;
|
21 |
+
|
22 |
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
23 |
$quoteTableName = 'sales_flat_quote';
|
24 |
} else {
|
29 |
->from(
|
30 |
array('q' => $this->getTable($quoteTableName)),
|
31 |
array(
|
32 |
+
'q.updated_at'
|
33 |
)
|
34 |
)
|
35 |
->where('q.customer_id = ?', $customerId)
|
36 |
+
->where('q.is_active = 1')
|
37 |
+
->where('q.items_count > 0')
|
38 |
+
->where('q.store_id = ?', $storeId)
|
39 |
+
->order('q.updated_at DESC');
|
40 |
|
41 |
$row = $readAdapter->fetchOne($request);
|
42 |
return $row;
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorder.php
CHANGED
@@ -13,10 +13,12 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProducts
|
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
-
* @param $customerId
|
|
|
|
|
17 |
* @return mixed
|
18 |
*/
|
19 |
-
public function calculatedAttributeRequest($customerId, $dates = array())
|
20 |
{
|
21 |
$readAdapter = $this->_getReadAdapter();
|
22 |
|
@@ -31,7 +33,8 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProducts
|
|
31 |
'AVG(o.total_item_count) AS avg_total_item_count'
|
32 |
)
|
33 |
)
|
34 |
-
->where('o.customer_id = ?', $customerId)
|
|
|
35 |
} else {
|
36 |
$orderTableName = 'sales_order';
|
37 |
$orderItemTableName = 'sales_flat_order_item';
|
@@ -48,7 +51,8 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProducts
|
|
48 |
"sf.order_id = o.entity_id",
|
49 |
array()
|
50 |
)
|
51 |
-
->where('o.customer_id = ?', $customerId)
|
|
|
52 |
}
|
53 |
|
54 |
if (!empty($dates)) {
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
+
* @param array $dates
|
19 |
* @return mixed
|
20 |
*/
|
21 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates = array())
|
22 |
{
|
23 |
$readAdapter = $this->_getReadAdapter();
|
24 |
|
33 |
'AVG(o.total_item_count) AS avg_total_item_count'
|
34 |
)
|
35 |
)
|
36 |
+
->where('o.customer_id = ?', $customerId)
|
37 |
+
->where('o.store_id = ?', $storeId);
|
38 |
} else {
|
39 |
$orderTableName = 'sales_order';
|
40 |
$orderItemTableName = 'sales_flat_order_item';
|
51 |
"sf.order_id = o.entity_id",
|
52 |
array()
|
53 |
)
|
54 |
+
->where('o.customer_id = ?', $customerId)
|
55 |
+
->where('o.store_id = ?', $storeId);
|
56 |
}
|
57 |
|
58 |
if (!empty($dates)) {
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbdifferentproductsperorderline.php
CHANGED
@@ -13,10 +13,12 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProducts
|
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
-
* @param $customerId
|
|
|
|
|
17 |
* @return mixed
|
18 |
*/
|
19 |
-
public function calculatedAttributeRequest($customerId, $dates=array())
|
20 |
{
|
21 |
$readAdapter = $this->_getReadAdapter();
|
22 |
|
@@ -32,7 +34,8 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProducts
|
|
32 |
'AVG(total_qty_ordered / total_item_count) AS avg_products_per_line'
|
33 |
)
|
34 |
)
|
35 |
-
->where('o.customer_id = ?', $customerId)
|
|
|
36 |
} else {
|
37 |
$orderTableName = 'sales_order';
|
38 |
$orderItemTableName = 'sales_flat_order_item';
|
@@ -48,7 +51,8 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbDifferentProducts
|
|
48 |
"sf.order_id = o.entity_id",
|
49 |
array()
|
50 |
)
|
51 |
-
->where('o.customer_id = ?', $customerId)
|
|
|
52 |
}
|
53 |
|
54 |
if (!empty($dates)) {
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
+
* @param array $dates
|
19 |
* @return mixed
|
20 |
*/
|
21 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates=array())
|
22 |
{
|
23 |
$readAdapter = $this->_getReadAdapter();
|
24 |
|
34 |
'AVG(total_qty_ordered / total_item_count) AS avg_products_per_line'
|
35 |
)
|
36 |
)
|
37 |
+
->where('o.customer_id = ?', $customerId)
|
38 |
+
->where('o.store_id = ?', $storeId);
|
39 |
} else {
|
40 |
$orderTableName = 'sales_order';
|
41 |
$orderItemTableName = 'sales_flat_order_item';
|
51 |
"sf.order_id = o.entity_id",
|
52 |
array()
|
53 |
)
|
54 |
+
->where('o.customer_id = ?', $customerId)
|
55 |
+
->where('o.store_id = ?', $storeId);
|
56 |
}
|
57 |
|
58 |
if (!empty($dates)) {
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgnbproductsperorder.php
CHANGED
@@ -13,8 +13,13 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbProductsPerOrder
|
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
|
|
16 |
*/
|
17 |
-
public function calculatedAttributeRequest($customerId, $dates = array())
|
18 |
{
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
$orderTableName = null;
|
@@ -33,6 +38,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgNbProductsPerOrder
|
|
33 |
)
|
34 |
)
|
35 |
->where('o.customer_id = ?', $customerId)
|
|
|
36 |
->order('o.created_at ASC');
|
37 |
|
38 |
if (!empty($dates)) {
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*
|
17 |
+
* @param $customerId
|
18 |
+
* @param array $dates
|
19 |
+
* @param $storeId
|
20 |
+
* @return
|
21 |
*/
|
22 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates = array())
|
23 |
{
|
24 |
$readAdapter = $this->_getReadAdapter();
|
25 |
$orderTableName = null;
|
38 |
)
|
39 |
)
|
40 |
->where('o.customer_id = ?', $customerId)
|
41 |
+
->where('o.store_id = ?', $storeId)
|
42 |
->order('o.created_at ASC');
|
43 |
|
44 |
if (!empty($dates)) {
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountexcltax.php
CHANGED
@@ -14,8 +14,13 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountExclTax
|
|
14 |
/**
|
15 |
* Perform SQl request for calculated attribute and save result in cache
|
16 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
|
|
17 |
*/
|
18 |
-
public function calculatedAttributeRequest($customerId, $dates = array())
|
19 |
{
|
20 |
$readAdapter = $this->_getReadAdapter();
|
21 |
$orderTableName = null;
|
@@ -34,6 +39,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountExclTax
|
|
34 |
)
|
35 |
)
|
36 |
->where('o.customer_id = ?', $customerId)
|
|
|
37 |
->order('o.created_at ASC');
|
38 |
|
39 |
if (!empty($dates)) {
|
14 |
/**
|
15 |
* Perform SQl request for calculated attribute and save result in cache
|
16 |
* Call to this method is performed before exporting, to be done only once.
|
17 |
+
*
|
18 |
+
* @param int $customerId
|
19 |
+
* @param int $storeId
|
20 |
+
* @param array $dates
|
21 |
+
* @return
|
22 |
*/
|
23 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates = array())
|
24 |
{
|
25 |
$readAdapter = $this->_getReadAdapter();
|
26 |
$orderTableName = null;
|
39 |
)
|
40 |
)
|
41 |
->where('o.customer_id = ?', $customerId)
|
42 |
+
->where('o.store_id = ?', $storeId)
|
43 |
->order('o.created_at ASC');
|
44 |
|
45 |
if (!empty($dates)) {
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Avgorderamountincltax.php
CHANGED
@@ -10,90 +10,12 @@
|
|
10 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
{
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @param
|
16 |
-
* @
|
17 |
-
*
|
18 |
-
* @return void
|
19 |
*/
|
20 |
-
public function
|
21 |
-
{
|
22 |
-
// Load array from cache
|
23 |
-
$serializedData = Mage::app()->loadCache(get_class($this));
|
24 |
-
$cacheArray = unserialize($serializedData);
|
25 |
-
$value = '';
|
26 |
-
|
27 |
-
// Return value if in array
|
28 |
-
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
29 |
-
$value = $cacheArray[$customer->getEmail()]['avg_grand_total'];
|
30 |
-
$value = $this->formatInt($value);
|
31 |
-
}
|
32 |
-
|
33 |
-
return $value;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Perform SQl request for calculated attribute and save result in cache
|
38 |
-
* Call to this method is performed before exporting, to be done only once.
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
-
*/
|
42 |
-
public function performCalculatedAttributeRequest()
|
43 |
-
{
|
44 |
-
$readAdapter = $this->_getReadAdapter();
|
45 |
-
|
46 |
-
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
47 |
-
$orderTableName = 'sales_flat_order';
|
48 |
-
|
49 |
-
// Nested request
|
50 |
-
$select = $readAdapter->select()
|
51 |
-
->from(
|
52 |
-
array('o' => $this->getTable($orderTableName)),
|
53 |
-
array(
|
54 |
-
'o.customer_email AS customer_email',
|
55 |
-
'o.customer_id',
|
56 |
-
'AVG(o.grand_total) AS avg_grand_total'
|
57 |
-
)
|
58 |
-
)
|
59 |
-
->group('o.customer_id');
|
60 |
-
|
61 |
-
/*
|
62 |
-
* MySQL request
|
63 |
-
SELECT o.customer_id, o.customer_email, AVG(o.subtotal), AVG(o.grand_total)
|
64 |
-
FROM sales_flat_order AS o
|
65 |
-
GROUP BY o.customer_id
|
66 |
-
*/
|
67 |
-
}else{
|
68 |
-
$orderTableName = 'sales_order';
|
69 |
-
$customerTableName = 'customer_entity';
|
70 |
-
|
71 |
-
// Nested request
|
72 |
-
$select = $readAdapter->select()
|
73 |
-
->from(
|
74 |
-
array('o' => $this->getTable($orderTableName)),
|
75 |
-
array(
|
76 |
-
'ce.email AS customer_email',
|
77 |
-
'o.customer_id',
|
78 |
-
'AVG(o.grand_total) AS avg_grand_total'
|
79 |
-
)
|
80 |
-
)->join(
|
81 |
-
array('ce' => $this->getTable($customerTableName)),
|
82 |
-
"ce.entity_id=o.customer_id",
|
83 |
-
array()
|
84 |
-
)
|
85 |
-
->group('o.customer_id');
|
86 |
-
//SELECT o.customer_id, ce.email as customer_email, AVG(o.grand_total) as avg_grand_total FROM sales_order AS o INNER JOIN customer_entity ce ON ce.entity_id = o.customer_id GROUP BY o.customer_id
|
87 |
-
}
|
88 |
-
|
89 |
-
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
90 |
-
$serializedData = serialize($rows);
|
91 |
-
|
92 |
-
// Save array to cache: use class_name as cache key
|
93 |
-
Mage::app()->saveCache($serializedData, get_class($this));
|
94 |
-
}
|
95 |
-
|
96 |
-
public function calculatedAttributeRequest($customerId, $dates=array())
|
97 |
{
|
98 |
$readAdapter = $this->_getReadAdapter();
|
99 |
$orderTableName = null;
|
@@ -112,6 +34,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax
|
|
112 |
)
|
113 |
)
|
114 |
->where('o.customer_id = ?', $customerId)
|
|
|
115 |
->order('o.created_at ASC');
|
116 |
|
117 |
if (!empty($dates)) {
|
10 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_AvgOrderAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
{
|
12 |
/**
|
13 |
+
* @param int $customerId
|
14 |
+
* @param int $storeId
|
15 |
+
* @param array $dates
|
16 |
+
* @return mixed
|
|
|
|
|
17 |
*/
|
18 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates=array())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
{
|
20 |
$readAdapter = $this->_getReadAdapter();
|
21 |
$orderTableName = null;
|
34 |
)
|
35 |
)
|
36 |
->where('o.customer_id = ?', $customerId)
|
37 |
+
->where('o.store_id = ?', $storeId)
|
38 |
->order('o.created_at ASC');
|
39 |
|
40 |
if (!empty($dates)) {
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountexcltax.php
CHANGED
@@ -10,16 +10,15 @@
|
|
10 |
*/
|
11 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
{
|
13 |
-
|
14 |
-
|
15 |
/**
|
16 |
* Perform SQl request for calculated attribute and save result in cache
|
17 |
* Call to this method is performed before exporting, to be done only once.
|
18 |
*
|
19 |
-
* @param $customerId
|
|
|
20 |
* @return mixed
|
21 |
*/
|
22 |
-
public function calculatedAttributeRequest($customerId)
|
23 |
{
|
24 |
$readAdapter = $this->_getReadAdapter();
|
25 |
$orderTableName = null;
|
@@ -38,6 +37,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTa
|
|
38 |
)
|
39 |
)
|
40 |
->where('o.customer_id = ?', $customerId)
|
|
|
41 |
->order('o.created_at ASC');
|
42 |
|
43 |
$row = $readAdapter->fetchOne($select);
|
10 |
*/
|
11 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountExclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
12 |
{
|
|
|
|
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
16 |
*
|
17 |
+
* @param int $customerId
|
18 |
+
* @param int $storeId
|
19 |
* @return mixed
|
20 |
*/
|
21 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
22 |
{
|
23 |
$readAdapter = $this->_getReadAdapter();
|
24 |
$orderTableName = null;
|
37 |
)
|
38 |
)
|
39 |
->where('o.customer_id = ?', $customerId)
|
40 |
+
->where('o.store_id = ?', $storeId)
|
41 |
->order('o.created_at ASC');
|
42 |
|
43 |
$row = $readAdapter->fetchOne($select);
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Firstorderamountincltax.php
CHANGED
@@ -15,8 +15,11 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountInclTa
|
|
15 |
* Perform SQl request for calculated attribute and save result in cache
|
16 |
* Call to this method is performed before exporting, to be done only once.
|
17 |
*
|
|
|
|
|
|
|
18 |
*/
|
19 |
-
public function calculatedAttributeRequest($customerId)
|
20 |
{
|
21 |
$readAdapter = $this->_getReadAdapter();
|
22 |
$orderTableName = null;
|
@@ -34,6 +37,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_FirstOrderAmountInclTa
|
|
34 |
)
|
35 |
)
|
36 |
->where('o.customer_id = ?', $customerId)
|
|
|
37 |
->order('o.created_at ASC');
|
38 |
|
39 |
$row = $readAdapter->fetchOne($select);
|
15 |
* Perform SQl request for calculated attribute and save result in cache
|
16 |
* Call to this method is performed before exporting, to be done only once.
|
17 |
*
|
18 |
+
* @param int $customerId
|
19 |
+
* @param int $storeId
|
20 |
+
* @return
|
21 |
*/
|
22 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
23 |
{
|
24 |
$readAdapter = $this->_getReadAdapter();
|
25 |
$orderTableName = null;
|
37 |
)
|
38 |
)
|
39 |
->where('o.customer_id = ?', $customerId)
|
40 |
+
->where('o.store_id = ?', $storeId)
|
41 |
->order('o.created_at ASC');
|
42 |
|
43 |
$row = $readAdapter->fetchOne($select);
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountexcltax.php
CHANGED
@@ -13,10 +13,11 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmou
|
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
-
* @param $customerId
|
|
|
17 |
* @return mixed
|
18 |
*/
|
19 |
-
public function calculatedAttributeRequest($customerId)
|
20 |
{
|
21 |
$readAdapter = $this->_getReadAdapter();
|
22 |
|
@@ -31,15 +32,17 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmou
|
|
31 |
->from(
|
32 |
array('q' => $this->getTable($quoteTableName)),
|
33 |
array(
|
34 |
-
'q.
|
35 |
)
|
36 |
)
|
37 |
->where('q.customer_id = ?', $customerId)
|
38 |
-
->where('q.
|
39 |
-
->
|
|
|
|
|
40 |
|
41 |
$row = $readAdapter->fetchOne($request);
|
42 |
|
43 |
-
return $row;
|
44 |
}
|
45 |
}
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
* @return mixed
|
19 |
*/
|
20 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
21 |
{
|
22 |
$readAdapter = $this->_getReadAdapter();
|
23 |
|
32 |
->from(
|
33 |
array('q' => $this->getTable($quoteTableName)),
|
34 |
array(
|
35 |
+
'q.base_subtotal_with_discount'
|
36 |
)
|
37 |
)
|
38 |
->where('q.customer_id = ?', $customerId)
|
39 |
+
->where('q.is_active = 1')
|
40 |
+
->where('q.items_count > 0')
|
41 |
+
->where('q.store_id = ?', $storeId)
|
42 |
+
->order('q.updated_at DESC');
|
43 |
|
44 |
$row = $readAdapter->fetchOne($request);
|
45 |
|
46 |
+
return $row === false ? null : $row;
|
47 |
}
|
48 |
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastnotorderedcartamountincltax.php
CHANGED
@@ -10,153 +10,11 @@
|
|
10 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
{
|
12 |
/**
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* @param Mage_Customer_Model_Customer $customer Current customer
|
16 |
-
* @param Varien_Object $config Config for this attribute
|
17 |
-
*
|
18 |
-
* @return void
|
19 |
-
*/
|
20 |
-
public function getExportedValue($customer, $config)
|
21 |
-
{
|
22 |
-
// Load array from cache
|
23 |
-
$serializedData = Mage::app()->loadCache(get_class($this));
|
24 |
-
$cacheArray = unserialize($serializedData);
|
25 |
-
$value = '';
|
26 |
-
|
27 |
-
// Return value if in array
|
28 |
-
if (is_array($cacheArray) && array_key_exists($customer->getEmail(), $cacheArray)) {
|
29 |
-
$value = $cacheArray[$customer->getEmail()]['grand_total'];
|
30 |
-
$value = $this->formatInt($value);
|
31 |
-
}
|
32 |
-
|
33 |
-
return $value;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Perform SQl request for calculated attribute and save result in cache
|
38 |
-
* Call to this method is performed before exporting, to be done only once.
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
-
*/
|
42 |
-
public function performCalculatedAttributeRequest()
|
43 |
-
{
|
44 |
-
$readAdapter = $this->_getReadAdapter();
|
45 |
-
|
46 |
-
|
47 |
-
if(Mage::helper('dolist')->isFlatTableEnabled()){
|
48 |
-
$quoteTableName = 'sales_flat_quote';
|
49 |
-
$orderTableName = 'sales_flat_order';
|
50 |
-
$customerTableName = 'customer_entity';
|
51 |
-
// Nested request
|
52 |
-
$nestedRequest = $readAdapter->select()
|
53 |
-
->from(
|
54 |
-
array('q' => $this->getTable($quoteTableName)),
|
55 |
-
array(
|
56 |
-
'q.entity_id AS quote_id',
|
57 |
-
'q.customer_id',
|
58 |
-
'q.grand_total'
|
59 |
-
)
|
60 |
-
)
|
61 |
-
->joinLeft(
|
62 |
-
array('o' => $this->getTable($orderTableName)),
|
63 |
-
"q.entity_id=o.quote_id",
|
64 |
-
array()
|
65 |
-
)
|
66 |
-
->where('o.entity_id IS NULL')
|
67 |
-
->order('q.created_at DESC');
|
68 |
-
|
69 |
-
$select = $readAdapter->select()
|
70 |
-
->from(
|
71 |
-
array('l' => $nestedRequest),
|
72 |
-
array(
|
73 |
-
'c.email AS customer_email',
|
74 |
-
'l.grand_total'
|
75 |
-
)
|
76 |
-
)
|
77 |
-
->join(
|
78 |
-
array('c' => $this->getTable($customerTableName)),
|
79 |
-
"c.entity_id=l.customer_id",
|
80 |
-
array()
|
81 |
-
)
|
82 |
-
->group('l.customer_id');
|
83 |
-
|
84 |
-
/*
|
85 |
-
* MySQL request
|
86 |
-
SELECT customer_entity.email, last_not_ordered_carts.grand_total, last_not_ordered_carts.subtotal
|
87 |
-
FROM
|
88 |
-
(
|
89 |
-
SELECT q.grand_total, q.subtotal, q.customer_id
|
90 |
-
FROM sales_flat_quote AS q
|
91 |
-
LEFT JOIN sales_flat_order ON q.entity_id = sales_flat_order.quote_id
|
92 |
-
WHERE sales_flat_order.entity_id IS NULL
|
93 |
-
ORDER BY q.created_at DESC
|
94 |
-
)
|
95 |
-
AS last_not_ordered_carts
|
96 |
-
INNER JOIN customer_entity ON customer_entity.entity_id = last_not_ordered_carts.customer_id
|
97 |
-
*/
|
98 |
-
}else{
|
99 |
-
$quoteTableName = 'sales_flat_quote';
|
100 |
-
$customerTableName = 'customer_entity';
|
101 |
-
$orderTableName = 'sales_order';
|
102 |
-
$attributeTableName = 'sales_order_int';
|
103 |
-
$eavTableName = 'eav_attribute';
|
104 |
-
// Nested request
|
105 |
-
$nestedRequest = $readAdapter->select()
|
106 |
-
->from(
|
107 |
-
array('q' => $this->getTable($quoteTableName)),
|
108 |
-
array(
|
109 |
-
'q.entity_id AS quote_id',
|
110 |
-
'q.customer_id',
|
111 |
-
'q.grand_total'
|
112 |
-
)
|
113 |
-
)
|
114 |
-
->joinLeft(
|
115 |
-
array('e' => $this->getTable($eavTableName)),
|
116 |
-
"e.attribute_code='quote_id'",
|
117 |
-
array()
|
118 |
-
)
|
119 |
-
->joinLeft(
|
120 |
-
array('a' => $this->getTable($attributeTableName)),
|
121 |
-
"a.value=q.entity_id AND a.attribute_id = e.attribute_id",
|
122 |
-
array()
|
123 |
-
)
|
124 |
-
->joinLeft(
|
125 |
-
array('o' => $this->getTable($orderTableName)),
|
126 |
-
"a.entity_id=o.entity_id",
|
127 |
-
array()
|
128 |
-
)
|
129 |
-
->where('o.entity_id IS NULL')
|
130 |
-
->order('q.created_at DESC');
|
131 |
-
|
132 |
-
$select = $readAdapter->select()
|
133 |
-
->from(
|
134 |
-
array('l' => $nestedRequest),
|
135 |
-
array(
|
136 |
-
'c.email AS customer_email',
|
137 |
-
'l.grand_total'
|
138 |
-
)
|
139 |
-
)
|
140 |
-
->join(
|
141 |
-
array('c' => $this->getTable($customerTableName)),
|
142 |
-
"c.entity_id=l.customer_id",
|
143 |
-
array()
|
144 |
-
)
|
145 |
-
->group('l.customer_id');
|
146 |
-
}
|
147 |
-
|
148 |
-
$rows = $readAdapter->fetchAssoc($select, 'customer_email');
|
149 |
-
$serializedData = serialize($rows);
|
150 |
-
|
151 |
-
// Save array to cache: use class_name as cache key
|
152 |
-
Mage::app()->saveCache($serializedData, get_class($this));
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* @param $customerId
|
157 |
* @return mixed
|
158 |
*/
|
159 |
-
public function calculatedAttributeRequest($customerId)
|
160 |
{
|
161 |
$readAdapter = $this->_getReadAdapter();
|
162 |
$quoteTableName = null;
|
@@ -166,18 +24,22 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmou
|
|
166 |
$quoteTableName = 'sales_flat_quote';
|
167 |
}
|
168 |
|
|
|
169 |
$request = $readAdapter->select()
|
170 |
->from(
|
171 |
array('q' => $this->getTable($quoteTableName)),
|
172 |
array(
|
173 |
-
'q.
|
174 |
)
|
175 |
)
|
176 |
->where('q.customer_id = ?', $customerId)
|
177 |
-
->where('q.
|
178 |
-
->
|
|
|
|
|
179 |
|
180 |
$row = $readAdapter->fetchOne($request);
|
181 |
-
|
|
|
182 |
}
|
183 |
}
|
10 |
class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastNotOrderedCartAmountInclTax extends Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Abstract
|
11 |
{
|
12 |
/**
|
13 |
+
* @param int $customerId
|
14 |
+
* @param int $storeId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
* @return mixed
|
16 |
*/
|
17 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
18 |
{
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
$quoteTableName = null;
|
24 |
$quoteTableName = 'sales_flat_quote';
|
25 |
}
|
26 |
|
27 |
+
/** @var Varien_Db_Select $request */
|
28 |
$request = $readAdapter->select()
|
29 |
->from(
|
30 |
array('q' => $this->getTable($quoteTableName)),
|
31 |
array(
|
32 |
+
'subtotal' => '(q.base_subtotal_with_discount*q.base_to_global_rate)',
|
33 |
)
|
34 |
)
|
35 |
->where('q.customer_id = ?', $customerId)
|
36 |
+
->where('q.is_active = 1')
|
37 |
+
->where('q.items_count > 0')
|
38 |
+
->where('q.store_id = ?', $storeId)
|
39 |
+
->order('q.updated_at DESC');
|
40 |
|
41 |
$row = $readAdapter->fetchOne($request);
|
42 |
+
|
43 |
+
return $row === false ? null : $row;
|
44 |
}
|
45 |
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountexcltax.php
CHANGED
@@ -12,8 +12,12 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountExclTax
|
|
12 |
/**
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
-
public function calculatedAttributeRequest($customerId)
|
17 |
{
|
18 |
$readAdapter = $this->_getReadAdapter();
|
19 |
$orderTableName = null;
|
@@ -32,6 +36,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountExclTax
|
|
32 |
)
|
33 |
)
|
34 |
->where('o.customer_id = ?', $customerId)
|
|
|
35 |
->order('o.created_at DESC');
|
36 |
|
37 |
$row = $readAdapter->fetchOne($select);
|
12 |
/**
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
+
* @return
|
19 |
*/
|
20 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
21 |
{
|
22 |
$readAdapter = $this->_getReadAdapter();
|
23 |
$orderTableName = null;
|
36 |
)
|
37 |
)
|
38 |
->where('o.customer_id = ?', $customerId)
|
39 |
+
->where('o.store_id = ?', $storeId)
|
40 |
->order('o.created_at DESC');
|
41 |
|
42 |
$row = $readAdapter->fetchOne($select);
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Lastorderamountincltax.php
CHANGED
@@ -13,10 +13,11 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountInclTax
|
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
-
* @param $customerId
|
|
|
17 |
* @return mixed
|
18 |
*/
|
19 |
-
public function calculatedAttributeRequest($customerId)
|
20 |
{
|
21 |
$readAdapter = $this->_getReadAdapter();
|
22 |
$orderTableName = null;
|
@@ -34,6 +35,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_LastOrderAmountInclTax
|
|
34 |
)
|
35 |
)
|
36 |
->where('o.customer_id = ?', $customerId)
|
|
|
37 |
->order('o.created_at DESC');
|
38 |
|
39 |
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
* @return mixed
|
19 |
*/
|
20 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
21 |
{
|
22 |
$readAdapter = $this->_getReadAdapter();
|
23 |
$orderTableName = null;
|
35 |
)
|
36 |
)
|
37 |
->where('o.customer_id = ?', $customerId)
|
38 |
+
->where('o.store_id = ?', $storeId)
|
39 |
->order('o.created_at DESC');
|
40 |
|
41 |
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Nbpromotionrulesused.php
CHANGED
@@ -12,8 +12,12 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_NbPromotionRulesUsed e
|
|
12 |
/**
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
-
public function calculatedAttributeRequest($customerId)
|
17 |
{
|
18 |
$readAdapter = $this->_getReadAdapter();
|
19 |
|
@@ -31,6 +35,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_NbPromotionRulesUsed e
|
|
31 |
|
32 |
|
33 |
$row = $readAdapter->fetchOne($select);
|
34 |
-
|
|
|
35 |
}
|
36 |
}
|
12 |
/**
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
+
* @return
|
19 |
*/
|
20 |
+
public function calculatedAttributeRequest($customerId, $storeId)
|
21 |
{
|
22 |
$readAdapter = $this->_getReadAdapter();
|
23 |
|
35 |
|
36 |
|
37 |
$row = $readAdapter->fetchOne($select);
|
38 |
+
|
39 |
+
return $row !== null ? $row : 0;
|
40 |
}
|
41 |
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountexcltax.php
CHANGED
@@ -13,8 +13,13 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountExclTa
|
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
|
|
16 |
*/
|
17 |
-
public function calculatedAttributeRequest($customerId, $dates=array())
|
18 |
{
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
$orderTableName = null;
|
@@ -33,6 +38,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountExclTa
|
|
33 |
)
|
34 |
)
|
35 |
->where('o.customer_id = ?', $customerId)
|
|
|
36 |
->order('o.created_at ASC');
|
37 |
|
38 |
if (!empty($dates)) {
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*
|
17 |
+
* @param int $customerId
|
18 |
+
* @param int $storeId
|
19 |
+
* @param array $dates
|
20 |
+
* @return
|
21 |
*/
|
22 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates=array())
|
23 |
{
|
24 |
$readAdapter = $this->_getReadAdapter();
|
25 |
$orderTableName = null;
|
38 |
)
|
39 |
)
|
40 |
->where('o.customer_id = ?', $customerId)
|
41 |
+
->where('o.store_id = ?', $storeId)
|
42 |
->order('o.created_at ASC');
|
43 |
|
44 |
if (!empty($dates)) {
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderamountincltax.php
CHANGED
@@ -13,8 +13,13 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTa
|
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
|
|
16 |
*/
|
17 |
-
public function calculatedAttributeRequest($customerId, $dates = array())
|
18 |
{
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
$orderTableName = null;
|
@@ -32,7 +37,9 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTa
|
|
32 |
'total' => 'SUM(o.grand_total)'
|
33 |
)
|
34 |
)
|
35 |
-
->where('o.customer_id = ?', $customerId)
|
|
|
|
|
36 |
|
37 |
|
38 |
if (!empty($dates)) {
|
@@ -44,8 +51,6 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderAmountInclTa
|
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
$select->order('o.created_at ASC');
|
48 |
-
|
49 |
$row = $readAdapter->fetchOne($select);
|
50 |
return $row;
|
51 |
}
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*
|
17 |
+
* @param int $customerId
|
18 |
+
* @param int $storeId
|
19 |
+
* @param array $dates
|
20 |
+
* @return
|
21 |
*/
|
22 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates = array())
|
23 |
{
|
24 |
$readAdapter = $this->_getReadAdapter();
|
25 |
$orderTableName = null;
|
37 |
'total' => 'SUM(o.grand_total)'
|
38 |
)
|
39 |
)
|
40 |
+
->where('o.customer_id = ?', $customerId)
|
41 |
+
->where('o.store_id = ?', $storeId)
|
42 |
+
->order('o.created_at ASC');
|
43 |
|
44 |
|
45 |
if (!empty($dates)) {
|
51 |
}
|
52 |
}
|
53 |
|
|
|
|
|
54 |
$row = $readAdapter->fetchOne($select);
|
55 |
return $row;
|
56 |
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorderedproducts.php
CHANGED
@@ -12,17 +12,24 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts e
|
|
12 |
/**
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
|
|
15 |
*/
|
16 |
-
public function calculatedAttributeRequest($customerId, $dates = array())
|
17 |
{
|
18 |
$readAdapter = $this->_getReadAdapter();
|
19 |
$orderTableName = null;
|
|
|
20 |
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
21 |
$orderTableName = 'sales_flat_order';
|
22 |
|
23 |
} else {
|
24 |
$orderTableName = 'sales_order';
|
25 |
}
|
|
|
26 |
$select = $readAdapter
|
27 |
->select()
|
28 |
->from(
|
@@ -32,6 +39,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts e
|
|
32 |
)
|
33 |
)
|
34 |
->where('o.customer_id = ?', $customerId)
|
|
|
35 |
->order('o.created_at ASC');
|
36 |
|
37 |
if (!empty($dates)) {
|
@@ -42,6 +50,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrderedProducts e
|
|
42 |
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
43 |
}
|
44 |
}
|
|
|
45 |
$row = $readAdapter->fetchOne($select);
|
46 |
return $row;
|
47 |
}
|
12 |
/**
|
13 |
* Perform SQl request for calculated attribute and save result in cache
|
14 |
* Call to this method is performed before exporting, to be done only once.
|
15 |
+
*
|
16 |
+
* @param int $customerId
|
17 |
+
* @param int $storeId
|
18 |
+
* @param array $dates
|
19 |
+
* @return
|
20 |
*/
|
21 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates = array())
|
22 |
{
|
23 |
$readAdapter = $this->_getReadAdapter();
|
24 |
$orderTableName = null;
|
25 |
+
|
26 |
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
27 |
$orderTableName = 'sales_flat_order';
|
28 |
|
29 |
} else {
|
30 |
$orderTableName = 'sales_order';
|
31 |
}
|
32 |
+
|
33 |
$select = $readAdapter
|
34 |
->select()
|
35 |
->from(
|
39 |
)
|
40 |
)
|
41 |
->where('o.customer_id = ?', $customerId)
|
42 |
+
->where('o.store_id = ?', $storeId)
|
43 |
->order('o.created_at ASC');
|
44 |
|
45 |
if (!empty($dates)) {
|
50 |
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
51 |
}
|
52 |
}
|
53 |
+
|
54 |
$row = $readAdapter->fetchOne($select);
|
55 |
return $row;
|
56 |
}
|
app/code/community/Dolist/Net/Model/Mysql4/Dolistv8/Export/Adapter/Int/Totalorders.php
CHANGED
@@ -13,17 +13,24 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders extends Do
|
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
|
|
|
|
|
|
|
|
|
|
16 |
*/
|
17 |
-
public function calculatedAttributeRequest($customerId, $dates = array())
|
18 |
{
|
19 |
$readAdapter = $this->_getReadAdapter();
|
20 |
$orderTableName = null;
|
|
|
21 |
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
22 |
$orderTableName = 'sales_flat_order';
|
23 |
|
24 |
} else {
|
25 |
$orderTableName = 'sales_order';
|
26 |
}
|
|
|
27 |
$select = $readAdapter
|
28 |
->select()
|
29 |
->from(
|
@@ -33,6 +40,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders extends Do
|
|
33 |
)
|
34 |
)
|
35 |
->where('o.customer_id = ?', $customerId)
|
|
|
36 |
->order('o.created_at ASC');
|
37 |
|
38 |
if (!empty($dates)) {
|
@@ -43,6 +51,7 @@ class Dolist_Net_Model_Mysql4_Dolistv8_Export_Adapter_Int_TotalOrders extends Do
|
|
43 |
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
44 |
}
|
45 |
}
|
|
|
46 |
$row = $readAdapter->fetchOne($select);
|
47 |
return $row;
|
48 |
}
|
13 |
/**
|
14 |
* Perform SQl request for calculated attribute and save result in cache
|
15 |
* Call to this method is performed before exporting, to be done only once.
|
16 |
+
*
|
17 |
+
* @param int $customerId
|
18 |
+
* @param int $storeId
|
19 |
+
* @param array $dates
|
20 |
+
* @return
|
21 |
*/
|
22 |
+
public function calculatedAttributeRequest($customerId, $storeId, $dates = array())
|
23 |
{
|
24 |
$readAdapter = $this->_getReadAdapter();
|
25 |
$orderTableName = null;
|
26 |
+
|
27 |
if (Mage::helper('dolist')->isFlatTableEnabled()) {
|
28 |
$orderTableName = 'sales_flat_order';
|
29 |
|
30 |
} else {
|
31 |
$orderTableName = 'sales_order';
|
32 |
}
|
33 |
+
|
34 |
$select = $readAdapter
|
35 |
->select()
|
36 |
->from(
|
40 |
)
|
41 |
)
|
42 |
->where('o.customer_id = ?', $customerId)
|
43 |
+
->where('o.store_id = ?', $storeId)
|
44 |
->order('o.created_at ASC');
|
45 |
|
46 |
if (!empty($dates)) {
|
51 |
$select->where('o.created_at < ?', $dates['stop']->format('Y-m-d H:i:s'));
|
52 |
}
|
53 |
}
|
54 |
+
|
55 |
$row = $readAdapter->fetchOne($select);
|
56 |
return $row;
|
57 |
}
|
app/code/community/Dolist/Net/Model/Observer.php
CHANGED
@@ -12,7 +12,81 @@ class Dolist_Net_Model_Observer extends Mage_Core_Model_Abstract
|
|
12 |
const SEND_MESSAGE_PROCESS_ID = 'dolist_send_message';
|
13 |
|
14 |
protected $_processes = array();
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
/**
|
17 |
* List all queued messages and send its
|
18 |
*
|
@@ -295,6 +369,41 @@ class Dolist_Net_Model_Observer extends Mage_Core_Model_Abstract
|
|
295 |
|
296 |
return $this;
|
297 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
|
300 |
/**
|
12 |
const SEND_MESSAGE_PROCESS_ID = 'dolist_send_message';
|
13 |
|
14 |
protected $_processes = array();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Update calculatedfields table on new order
|
18 |
+
*
|
19 |
+
* @param Varien_Event_Observer $event
|
20 |
+
*/
|
21 |
+
public function onNewOrder(Varien_Event_Observer $event)
|
22 |
+
{
|
23 |
+
$currentOrder = null;
|
24 |
+
/** @var Mage_Sales_Model_Order $currentOrder */
|
25 |
+
if ($event) {
|
26 |
+
$currentOrder = $event->getData('order');
|
27 |
+
}
|
28 |
+
|
29 |
+
if ($currentOrder) {
|
30 |
+
$customerId = $currentOrder->getData('customer_id');
|
31 |
+
|
32 |
+
if (!$customerId) {
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
|
36 |
+
/** @var Dolist_Net_Model_Dolistv8_Calculatedfields $calculatedFields */
|
37 |
+
$calculatedFields = Mage::getModel('dolist/dolistv8_calculatedfields');
|
38 |
+
$calculatedFields->setStoreId($currentOrder->getStoreId())->loadByCustomerId($customerId);
|
39 |
+
|
40 |
+
$dates = $calculatedFields->computeOrderDataTtl();
|
41 |
+
$now = new DateTime('now');
|
42 |
+
|
43 |
+
// full update
|
44 |
+
if (!$calculatedFields->getId()) {
|
45 |
+
$calculatedFields->compute();
|
46 |
+
} else {
|
47 |
+
if ((in_array(Mage::getStoreConfig('dolist/dolist_v8/calculatedfieds_mode'), array(Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_1, Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_3, Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_6, Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_12, Dolist_Net_Model_Dolistv8_Calculatedfields::RANGE_24)) && $calculatedFields->getData('orders_expire') == null) || ($calculatedFields->getData('orders_expire') != null && strtotime($calculatedFields->getData('orders_expire')) < $now->getTimestamp())) {
|
48 |
+
$calculatedFields->compute();
|
49 |
+
} else {
|
50 |
+
$calculatedFields->addData(array(
|
51 |
+
"total_orders_amount" => $calculatedFields->getData('total_orders_amount') + ($currentOrder->getData('grand_total') - $currentOrder->getData('tax_amount')),
|
52 |
+
"total_orders_amount_with_vat" => $calculatedFields->getData('total_orders_amount') + $currentOrder->getData('grand_total'),
|
53 |
+
"average_unique_product_count" => $calculatedFields->computeAverageUniqueProductCount($dates),
|
54 |
+
"average_product_count_by_command_line" => $calculatedFields->computeAverageProductCountByCommandLine($dates),
|
55 |
+
"total_product_count" => $calculatedFields->getData('total_product_count') + $currentOrder->getData('total_item_count'),
|
56 |
+
"total_orders_count" => $calculatedFields->getData('total_orders_count') + 1,
|
57 |
+
"discount_rule_count" => $calculatedFields->computeDiscountRuleCount(),
|
58 |
+
));
|
59 |
+
}
|
60 |
+
|
61 |
+
if (!$calculatedFields->getData('first_order_amount') || $calculatedFields->getData('first_order_amount') == 0) {
|
62 |
+
$calculatedFields->setData('first_order_amount', $calculatedFields->computeFirstOrderAmount());
|
63 |
+
}
|
64 |
+
if (!$calculatedFields->getData('first_order_date')) {
|
65 |
+
$calculatedFields->setData('first_order_date', $calculatedFields->getFirstOrderDate());
|
66 |
+
}
|
67 |
+
|
68 |
+
if (!$calculatedFields->getData('first_order_amount_with_vat')) {
|
69 |
+
$calculatedFields->setData('first_order_amount_with_vat', $calculatedFields->computeFirstOrderAmount(true));
|
70 |
+
}
|
71 |
+
|
72 |
+
$calculatedFields->setData('last_order_amount', $calculatedFields->computeLastOrderAmount());
|
73 |
+
$calculatedFields->setData('last_order_amount_with_vat', $calculatedFields->computeLastOrderAmount(true));
|
74 |
+
$calculatedFields->setData('last_order_date', $calculatedFields->getLastOrderDate());
|
75 |
+
$calculatedFields->setData('last_orders_range', (strtotime($currentOrder->getData('created_at')) - strtotime($calculatedFields->getData('last_order_date'))) / 60 / 60 / 24);
|
76 |
+
$calculatedFields->setData('updated_at', $now->format('Y-m-d H:i:s'));
|
77 |
+
|
78 |
+
if (is_array($dates) && !empty($dates) && array_key_exists('stop', $dates) && $dates['stop']) {
|
79 |
+
$calculatedFields->setData('orders_expire', $dates['stop']->format('Y-m-d H:i:s'));
|
80 |
+
}
|
81 |
+
try {
|
82 |
+
$calculatedFields->save();
|
83 |
+
} catch (Exception $e) {
|
84 |
+
Mage::logException($e);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
/**
|
91 |
* List all queued messages and send its
|
92 |
*
|
369 |
|
370 |
return $this;
|
371 |
}
|
372 |
+
|
373 |
+
public function cronSegmentExport()
|
374 |
+
{
|
375 |
+
|
376 |
+
$this->_getHelper()->logDebug('Starting Segments export');
|
377 |
+
$process = new Mage_Index_Model_Process();
|
378 |
+
$process->setId("segment_export");
|
379 |
+
if($process->isLocked()){
|
380 |
+
$this->_getHelper()->logError('segment_export is locked');
|
381 |
+
return;
|
382 |
+
}
|
383 |
+
$process->lockAndBlock();
|
384 |
+
|
385 |
+
$segments = Mage::getModel('enterprise_customersegment/segment')->getCollection();
|
386 |
+
|
387 |
+
/* @var $segment Dolist_Net_Model_Customersegment */
|
388 |
+
foreach ($segments as $segment) {
|
389 |
+
$exportSuccess = FALSE;
|
390 |
+
if($this->_getHelper()->isSegmentExportCronEnabled($segment->getId())) {
|
391 |
+
$this->_getHelper()->logDebug('segment ' . $segment->getName() .' export is set to be processed by cron');
|
392 |
+
|
393 |
+
$exportSuccess = $this->_getHelper()->exportSegment($segment->getId());
|
394 |
+
if($exportSuccess) {
|
395 |
+
$this->_getHelper()->logDebug('segment ' . $segment->getName() .' has been successfully exported by cron');
|
396 |
+
} else {
|
397 |
+
$this->_getHelper()->logError('segment ' . $segment->getName() . ' has not been successfully exported by cron');
|
398 |
+
}
|
399 |
+
} else {
|
400 |
+
$this->_getHelper()->logDebug('segment ' . $segment->getName() .' export is not set to be exported by cron ');
|
401 |
+
}
|
402 |
+
}
|
403 |
+
|
404 |
+
$process->unlock();
|
405 |
+
$this->_getHelper()->logDebug('Ending Segments export');
|
406 |
+
}
|
407 |
|
408 |
|
409 |
/**
|
app/code/community/Dolist/Net/Model/Reports.php
CHANGED
@@ -30,7 +30,9 @@ class Dolist_Net_Model_Reports extends Mage_Core_Model_Abstract
|
|
30 |
public function end($result = 'success')
|
31 |
{
|
32 |
$now = new DateTime();
|
33 |
-
|
|
|
|
|
34 |
$this->setData('result', $result);
|
35 |
$this->setData('ended_at', $now->format(DateTime::W3C));
|
36 |
|
@@ -60,6 +62,8 @@ class Dolist_Net_Model_Reports extends Mage_Core_Model_Abstract
|
|
60 |
*/
|
61 |
public function log($message)
|
62 |
{
|
|
|
|
|
63 |
$this->setData('last_logs', $message);
|
64 |
$this->setData('logs', $this->getData('logs') . PHP_EOL . $message);
|
65 |
|
30 |
public function end($result = 'success')
|
31 |
{
|
32 |
$now = new DateTime();
|
33 |
+
if('success' === $result) {
|
34 |
+
$this->setData('progress_current', $this->getData('progress_end'));
|
35 |
+
}
|
36 |
$this->setData('result', $result);
|
37 |
$this->setData('ended_at', $now->format(DateTime::W3C));
|
38 |
|
62 |
*/
|
63 |
public function log($message)
|
64 |
{
|
65 |
+
$message = sprintf('[%s] %s', date('Y-m-d H:i:s'), $message);
|
66 |
+
|
67 |
$this->setData('last_logs', $message);
|
68 |
$this->setData('logs', $this->getData('logs') . PHP_EOL . $message);
|
69 |
|
app/code/community/Dolist/Net/Model/Service.php
CHANGED
@@ -447,7 +447,7 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
447 |
*
|
448 |
* @param int $storeId Store ID
|
449 |
*
|
450 |
-
* @return
|
451 |
*/
|
452 |
public function dolistV8ContactImport($storeId = 0)
|
453 |
{
|
@@ -563,7 +563,8 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
563 |
// Remove flag on current store id to be exported
|
564 |
$this->_getHelper()->removeExportStoreId('full', $storeId);
|
565 |
|
566 |
-
$report->log($this->_getHelper()->__('Nothing to export'))
|
|
|
567 |
$report->end();
|
568 |
return;
|
569 |
}
|
@@ -688,7 +689,7 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
688 |
|
689 |
if ($result[0]['total'] == 0) {
|
690 |
if ($report) {
|
691 |
-
$report->log($this->_getHelper()->__('Nothing to export'))
|
692 |
$report->end();
|
693 |
}
|
694 |
$this->_getHelper()->removeExportStoreId('differential', $storeId);
|
@@ -706,8 +707,6 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
706 |
$now = time();
|
707 |
// Export for differential subscribers
|
708 |
$exportDiffPerformed = false;
|
709 |
-
// Export for differential unsubscribers
|
710 |
-
$exportUnsubsPerformed = false;
|
711 |
|
712 |
// 1. Retrieve differential export file name (either in configuration table, either from webservice)
|
713 |
$exportFileName = $this->retrieveFileName('differential_export', $storeId);
|
@@ -722,16 +721,8 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
722 |
$exportDiffPerformed = $this->pushExportFile($exportFileName, $localFilename, $storeId, $report);
|
723 |
}
|
724 |
|
725 |
-
// 4.
|
726 |
-
|
727 |
-
|
728 |
-
// 5. Push newsletter unsubscribed contacts file on Dolist FTP server
|
729 |
-
if (!is_null($localUnsubscribeFilename)) {
|
730 |
-
$exportUnsubsPerformed = $this->pushUnsubscribeFile($localUnsubscribeFilename, $storeId);
|
731 |
-
}
|
732 |
-
|
733 |
-
// 6. Save dolist_last_export flag; only if export has been performed
|
734 |
-
if ($exportDiffPerformed || $exportUnsubsPerformed) {
|
735 |
|
736 |
// First, try to retrieve stored object
|
737 |
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
@@ -759,8 +750,8 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
759 |
|
760 |
public function getCustomerIdCollection($startPagination, $storeId, $count = false, $differential = false)
|
761 |
{
|
762 |
-
$exportPageSize = Mage::getStoreConfig('dolist/dolist_v8/export_page_size');
|
763 |
-
$exportWithCustomer = Mage::getStoreConfig('dolist/dolist_v8/export_customer_with_order');
|
764 |
|
765 |
$query = null;
|
766 |
if ($exportWithCustomer) {
|
@@ -772,7 +763,7 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
772 |
->getSelect();
|
773 |
$select2 = Mage::getModel('newsletter/subscriber')
|
774 |
->getCollection()
|
775 |
-
|
776 |
->addFieldToFilter('store_id', $storeId)
|
777 |
->getSelect();
|
778 |
$select2->reset(Zend_Db_Select::COLUMNS);
|
@@ -800,7 +791,7 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
800 |
/** @var Varien_Db_Select $query */
|
801 |
$query = Mage::getModel('newsletter/subscriber')
|
802 |
->getCollection()
|
803 |
-
|
804 |
->addFieldToFilter('store_id', $storeId)
|
805 |
->getSelect();
|
806 |
|
@@ -809,7 +800,7 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
809 |
->reset(Zend_Db_Select::FROM)
|
810 |
->reset(Zend_Db_Select::WHERE)
|
811 |
->from($this->getTable('newsletter_subscriber'), '')
|
812 |
-
|
813 |
->where($this->getTable('newsletter_subscriber') . '.store_id = ?', $storeId);
|
814 |
|
815 |
if ($count) {
|
@@ -836,6 +827,8 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
836 |
return $query;
|
837 |
}
|
838 |
|
|
|
|
|
839 |
/**
|
840 |
* Retrieve export file name, either stored value or generated by webservice
|
841 |
*
|
@@ -902,8 +895,6 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
902 |
$exportPageSize = 5000;
|
903 |
}
|
904 |
|
905 |
-
$query = $this->getCustomerIdCollection($startPagination, $storeId, false);
|
906 |
-
|
907 |
$report = null;
|
908 |
$reportId = $this->_getHelper()->getCurrentReportId($exportType, $storeId);
|
909 |
|
@@ -937,6 +928,10 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
937 |
}
|
938 |
}
|
939 |
|
|
|
|
|
|
|
|
|
940 |
if (Mage::getStoreConfig('dev/log/active') && $report) {
|
941 |
$report->log($query->assemble());
|
942 |
}
|
@@ -953,9 +948,6 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
953 |
$exporter->setEnclosure(); // Dolist does not use enclosures
|
954 |
$exporter->setDelimiter(chr(9));
|
955 |
|
956 |
-
// Retrieve export config. Fields to export and mapping attributes
|
957 |
-
$dolistv8SystemConfig = $this->_getDolistV8SystemConfig($storeId);
|
958 |
-
|
959 |
$i = 0;
|
960 |
// Write one line for each subscriber to export
|
961 |
foreach ($collection as $object) {
|
@@ -967,11 +959,10 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
967 |
}
|
968 |
}
|
969 |
|
970 |
-
$exporter->setContactToExport($object, $dolistv8SystemConfig);
|
971 |
$localFilename = sys_get_temp_dir() . '/' . $exportFileName; // Temporary filename
|
972 |
|
973 |
// Write in tmp CSV file
|
974 |
-
$exporter->export($localFilename,
|
975 |
|
976 |
//We reset until all content is exported
|
977 |
$localFilename = null;
|
@@ -1004,164 +995,6 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1004 |
return $localFilename;
|
1005 |
}
|
1006 |
|
1007 |
-
/**
|
1008 |
-
* Retrieve Dolist-V8 system config from back-office
|
1009 |
-
* and return Mapping between Export file header fields and Magento attributes to export
|
1010 |
-
*
|
1011 |
-
* @param int $storeId Store ID
|
1012 |
-
*
|
1013 |
-
* @return array Mapping between Export file header fields and Magento attributes to export
|
1014 |
-
*/
|
1015 |
-
protected function _getDolistV8SystemConfig($storeId)
|
1016 |
-
{
|
1017 |
-
// System configuration (set in back office)
|
1018 |
-
$systemConfig = Mage::getStoreConfig('dolist/dolist_v8', $storeId);
|
1019 |
-
|
1020 |
-
// Mapping configuration (set in config.xml)
|
1021 |
-
$mappingConfig = $this->_getHelper()->getContactExportRowAdapterConfig();
|
1022 |
-
|
1023 |
-
$exportContactFileMapping = array_flip($this->_getHelper()->getDolistExportContactFileHeader());
|
1024 |
-
// Empty values
|
1025 |
-
$this->_eraseVal($exportContactFileMapping);
|
1026 |
-
|
1027 |
-
// Keys are Magento system config attribute names
|
1028 |
-
$mandatoryFields = array('email');
|
1029 |
-
foreach ($mandatoryFields as $mandatoryField) {
|
1030 |
-
$object = $mappingConfig[$mandatoryField];
|
1031 |
-
$exportContactFileMapping[$object->getHeader()] = $mandatoryField;
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
// Specific case: group
|
1035 |
-
if (array_key_exists('group', $systemConfig)) {
|
1036 |
-
$exportContactFileMapping[$systemConfig['group']] = 'group_id';
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
// Usual fields can only be enabled and disabled. Their name in export file is defined in config.xml
|
1040 |
-
$usualFields = array();
|
1041 |
-
|
1042 |
-
// Filter enabled fields
|
1043 |
-
$enabledUsualFields = array();
|
1044 |
-
foreach ($usualFields as $usualField) {
|
1045 |
-
if ($systemConfig[$usualField] == 1) {
|
1046 |
-
$enabledUsualFields[] = $usualField;
|
1047 |
-
}
|
1048 |
-
}
|
1049 |
-
|
1050 |
-
// Add enabled field to export file mapping
|
1051 |
-
foreach ($enabledUsualFields as $usualField) {
|
1052 |
-
$object = $mappingConfig[$usualField];
|
1053 |
-
$exportContactFileMapping[$object->getHeader()] = $usualField;
|
1054 |
-
}
|
1055 |
-
|
1056 |
-
// Retrieve Custom fields (str, int and date)
|
1057 |
-
if (array_key_exists('custom_str_fields', $systemConfig)) {
|
1058 |
-
$customStrFields = unserialize($systemConfig['custom_str_fields']);
|
1059 |
-
foreach ($customStrFields as $customStrField) {
|
1060 |
-
$exportContactFileMapping[$customStrField['dolist_custom_str_fields']] = $customStrField['magento_customer_attribute_1'];
|
1061 |
-
}
|
1062 |
-
}
|
1063 |
-
if (array_key_exists('custom_int_fields', $systemConfig)) {
|
1064 |
-
$customIntFields = unserialize($systemConfig['custom_int_fields']);
|
1065 |
-
foreach ($customIntFields as $customIntField) {
|
1066 |
-
$exportContactFileMapping[$customIntField['dolist_custom_int_fields']] = $customIntField['magento_customer_attribute_2'];
|
1067 |
-
}
|
1068 |
-
}
|
1069 |
-
if (array_key_exists('custom_date_fields', $systemConfig)) {
|
1070 |
-
$customDateFields = unserialize($systemConfig['custom_date_fields']);
|
1071 |
-
foreach ($customDateFields as $customDateField) {
|
1072 |
-
$exportContactFileMapping[$customDateField['dolist_custom_date_fields']] = $customDateField['magento_customer_attribute_3'];
|
1073 |
-
}
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
return $exportContactFileMapping;
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
/**
|
1080 |
-
* Empty array values per reference
|
1081 |
-
*
|
1082 |
-
* @param array &$myarr Input array
|
1083 |
-
*
|
1084 |
-
* @return array
|
1085 |
-
*/
|
1086 |
-
protected function _eraseVal(&$myarr)
|
1087 |
-
{
|
1088 |
-
$myarr = array_map(create_function('$n', 'return null;'), $myarr);
|
1089 |
-
}
|
1090 |
-
|
1091 |
-
/**
|
1092 |
-
* Generate unsubscribe file
|
1093 |
-
* Contain contacts unsubscribed from last export
|
1094 |
-
* File format:
|
1095 |
-
* - file at UTF-8 format
|
1096 |
-
* - separator: carriage return
|
1097 |
-
* - no header line
|
1098 |
-
* - only email address per line
|
1099 |
-
* - filename unsubscribe_<YYYYMMDD_hhmmss>.txt
|
1100 |
-
*
|
1101 |
-
* @param int $storeId Store ID
|
1102 |
-
*
|
1103 |
-
* @return string Tmp unsubscribe file name
|
1104 |
-
*/
|
1105 |
-
public function generateUnsubscribeFile($storeId)
|
1106 |
-
{
|
1107 |
-
$shortFileName = null;
|
1108 |
-
$unsubscribeFilename = null;
|
1109 |
-
$error = false;
|
1110 |
-
|
1111 |
-
// Look for last export date
|
1112 |
-
// First, try to retrieve stored value
|
1113 |
-
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
1114 |
-
|
1115 |
-
// Log error if flag has never been set
|
1116 |
-
if ($flag->getId() == null) {
|
1117 |
-
$this->_getHelper()->logError(
|
1118 |
-
$this->_getHelper()->__(
|
1119 |
-
'At least one full export should have been perfomed before generating unsubscribe file.'
|
1120 |
-
)
|
1121 |
-
);
|
1122 |
-
|
1123 |
-
// Stop processing if export never performed
|
1124 |
-
$error = true;
|
1125 |
-
|
1126 |
-
} else {
|
1127 |
-
$lastExportTimestamp = $flag->getFlagData(); // timestamp format
|
1128 |
-
$collection = Mage::getModel('newsletter/subscriber')
|
1129 |
-
->getCollection()
|
1130 |
-
->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
|
1131 |
-
->addFieldToFilter('updated_at', array('from' => $lastExportTimestamp))
|
1132 |
-
->addFieldToFilter('store_id', $storeId);
|
1133 |
-
|
1134 |
-
// Perform only if collection is not empty and no error found
|
1135 |
-
if ($collection->getSize() > 0 && !$error) {
|
1136 |
-
$exporter = Mage::getModel('dolist/exporter_csv');
|
1137 |
-
$exporter->setEnclosure(); // Dolist does not use enclosures
|
1138 |
-
$exporter->setDelimiter(chr(9));
|
1139 |
-
|
1140 |
-
// Write one line for each subscriber to export
|
1141 |
-
foreach ($collection as $subscriber) {
|
1142 |
-
|
1143 |
-
$exporter->addObjectToExport(
|
1144 |
-
array(
|
1145 |
-
'prefix' => '',
|
1146 |
-
'object' => $subscriber,
|
1147 |
-
'fields' => array(
|
1148 |
-
'subscriber_email'
|
1149 |
-
)
|
1150 |
-
)
|
1151 |
-
);
|
1152 |
-
|
1153 |
-
$now = new Zend_Date();
|
1154 |
-
$shortFileName = 'unsubscribe_' . $now->toString('YYYYMMdd_HHmmss') . '.txt';
|
1155 |
-
$unsubscribeFilename = sys_get_temp_dir() . '/' . $shortFileName; // Temporary filename
|
1156 |
-
// Write in tmp CSV file, no header
|
1157 |
-
$exporter->export($unsubscribeFilename, false);
|
1158 |
-
}
|
1159 |
-
}
|
1160 |
-
}
|
1161 |
-
|
1162 |
-
return $shortFileName;
|
1163 |
-
}
|
1164 |
-
|
1165 |
/**
|
1166 |
* Generate segment file
|
1167 |
* File format:
|
@@ -1175,33 +1008,39 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1175 |
*
|
1176 |
* @return string Tmp segment file name
|
1177 |
*/
|
1178 |
-
public function generateSegmentFile($collection, $exportFileName)
|
1179 |
{
|
1180 |
$localFilename = null;
|
1181 |
|
1182 |
// Perform only if collection is not empty
|
1183 |
if ($collection->getSize() > 0) {
|
|
|
1184 |
$exporter = Mage::getModel('dolist/exporter_csv');
|
1185 |
$exporter->setEnclosure(); // Dolist does not use enclosures
|
1186 |
$exporter->setDelimiter(chr(9));
|
1187 |
|
1188 |
// Write one line for each customer to export
|
|
|
1189 |
foreach ($collection as $customer) {
|
1190 |
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
)
|
1200 |
);
|
|
|
1201 |
|
1202 |
-
$
|
1203 |
-
|
1204 |
-
|
|
|
|
|
|
|
1205 |
}
|
1206 |
}
|
1207 |
|
@@ -1283,50 +1122,6 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1283 |
return $result;
|
1284 |
}
|
1285 |
|
1286 |
-
/**
|
1287 |
-
* Push unsubscribe file to FTP server
|
1288 |
-
*
|
1289 |
-
* @param string $shortFilename Local unsubscribe filename (usually in /tmp directory)
|
1290 |
-
* @param int $storeId Store ID
|
1291 |
-
*
|
1292 |
-
* @return void
|
1293 |
-
*/
|
1294 |
-
public function pushUnsubscribeFile($shortFilename, $storeId)
|
1295 |
-
{
|
1296 |
-
$ftpConnection = Mage::getSingleton('dolist/dolistv8_ftp', array('store_id' => $storeId));
|
1297 |
-
$connection = $ftpConnection->getConnection();
|
1298 |
-
$result = false;
|
1299 |
-
|
1300 |
-
$unsubscribeFilename = sys_get_temp_dir() . '/' . $shortFilename; // Temporary filename
|
1301 |
-
|
1302 |
-
try {
|
1303 |
-
// Generate remote filename from export filename
|
1304 |
-
$remoteFolder = (string)Mage::getConfig()->getNode('dolistparams/ftp/unsubscribe_contact_directory');
|
1305 |
-
// To be sure to get only one slash
|
1306 |
-
$remoteFolder = rtrim($remoteFolder, '/') . '/';
|
1307 |
-
$remoteFilename = $remoteFolder . $shortFilename;
|
1308 |
-
|
1309 |
-
//reencode file in UTF16 with BOM
|
1310 |
-
$this->_reencodeFileToExport($localFilename);
|
1311 |
-
|
1312 |
-
// Push on FTP server
|
1313 |
-
$result = $connection->write($remoteFilename, $unsubscribeFilename);
|
1314 |
-
|
1315 |
-
// Close FTP connection
|
1316 |
-
$connection->close();
|
1317 |
-
|
1318 |
-
// Delete tmp file
|
1319 |
-
unlink($unsubscribeFilename);
|
1320 |
-
|
1321 |
-
} catch (Exception $e) {
|
1322 |
-
// Delete tmp file
|
1323 |
-
unlink($unsubscribeFilename);
|
1324 |
-
$this->_getHelper()->logError($e->getMessage());
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
return $result;
|
1328 |
-
}
|
1329 |
-
|
1330 |
/**
|
1331 |
* Perfom segment export for given $segmentId to Dolist-V8
|
1332 |
* Perform one export for each website.
|
@@ -1342,6 +1137,7 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1342 |
{
|
1343 |
$return = true;
|
1344 |
|
|
|
1345 |
$customerSegment = Mage::getModel('enterprise_customersegment/segment')->load($segmentId);
|
1346 |
$exportPerformed = false;
|
1347 |
|
@@ -1350,6 +1146,22 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1350 |
|
1351 |
$storeId = $storeIds[$configWebsiteId];
|
1352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1353 |
if ($customerSegment->getId()) {
|
1354 |
|
1355 |
// Retrieve segment customers to export
|
@@ -1359,43 +1171,70 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1359 |
->addSegmentFilter($customerSegment)
|
1360 |
->addWebsiteFilter($websiteListToFilter);
|
1361 |
|
|
|
|
|
1362 |
if ($collection->count() > 0) {
|
1363 |
|
1364 |
// Create new import.
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1370 |
|
1371 |
// Create segment file
|
1372 |
if (!is_null($exportFileName)) {
|
1373 |
-
$localFilename = $this->generateSegmentFile($collection, $exportFileName);
|
1374 |
|
1375 |
if (!is_null($localFilename)) {
|
1376 |
// Push file on FTP server
|
1377 |
-
$exportPerformed = $this->pushExportFile($exportFileName, $localFilename, $storeId);
|
1378 |
}
|
1379 |
}
|
1380 |
|
1381 |
if ($exportPerformed) {
|
1382 |
// If success, check if this segment has already been exported
|
1383 |
// If never exported, add it to exported segment list (dolist_exported_segment_list)
|
1384 |
-
|
|
|
|
|
|
|
1385 |
|
1386 |
Mage::getSingleton('adminhtml/session')
|
1387 |
->addSuccess($this->_getHelper()->__("Exporting segment id %s to Dolist-V8 succeeded", $segmentId));
|
1388 |
-
|
|
|
1389 |
} else {
|
1390 |
|
1391 |
Mage::getSingleton('adminhtml/session')
|
1392 |
->addError($this->_getHelper()->__("Exporting segment id %s to Dolist-V8 failed", $segmentId));
|
|
|
|
|
|
|
|
|
1393 |
$return = false;
|
1394 |
}
|
1395 |
|
1396 |
} else {
|
1397 |
Mage::getSingleton('adminhtml/session')
|
1398 |
->addError($this->_getHelper()->__("Segment id %s has not been exported because it is empty", $segmentId));
|
|
|
|
|
|
|
1399 |
$return = false;
|
1400 |
}
|
1401 |
|
@@ -1403,9 +1242,18 @@ class Dolist_Net_Model_Service extends Varien_Object
|
|
1403 |
Mage::getSingleton('adminhtml/session')
|
1404 |
->addNotice($this->_getHelper()->__("Segment id %s couldn't be loaded", $segmentId));
|
1405 |
|
|
|
|
|
1406 |
|
1407 |
// Remove this segment from dolist exported segment list
|
1408 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1409 |
}
|
1410 |
}
|
1411 |
|
447 |
*
|
448 |
* @param int $storeId Store ID
|
449 |
*
|
450 |
+
* @return boolean
|
451 |
*/
|
452 |
public function dolistV8ContactImport($storeId = 0)
|
453 |
{
|
563 |
// Remove flag on current store id to be exported
|
564 |
$this->_getHelper()->removeExportStoreId('full', $storeId);
|
565 |
|
566 |
+
$report->log($this->_getHelper()->__('Nothing to export'));
|
567 |
+
$report->start(0);
|
568 |
$report->end();
|
569 |
return;
|
570 |
}
|
689 |
|
690 |
if ($result[0]['total'] == 0) {
|
691 |
if ($report) {
|
692 |
+
$report->log($this->_getHelper()->__('Nothing to export'));
|
693 |
$report->end();
|
694 |
}
|
695 |
$this->_getHelper()->removeExportStoreId('differential', $storeId);
|
707 |
$now = time();
|
708 |
// Export for differential subscribers
|
709 |
$exportDiffPerformed = false;
|
|
|
|
|
710 |
|
711 |
// 1. Retrieve differential export file name (either in configuration table, either from webservice)
|
712 |
$exportFileName = $this->retrieveFileName('differential_export', $storeId);
|
721 |
$exportDiffPerformed = $this->pushExportFile($exportFileName, $localFilename, $storeId, $report);
|
722 |
}
|
723 |
|
724 |
+
// 4. Save dolist_last_export flag; only if export has been performed
|
725 |
+
if ($exportDiffPerformed) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
726 |
|
727 |
// First, try to retrieve stored object
|
728 |
$flag = $this->_getHelper()->getFlagDolistLastExport($storeId);
|
750 |
|
751 |
public function getCustomerIdCollection($startPagination, $storeId, $count = false, $differential = false)
|
752 |
{
|
753 |
+
$exportPageSize = Mage::getStoreConfig('dolist/dolist_v8/export_page_size', $storeId);
|
754 |
+
$exportWithCustomer = Mage::getStoreConfig('dolist/dolist_v8/export_customer_with_order', $storeId);
|
755 |
|
756 |
$query = null;
|
757 |
if ($exportWithCustomer) {
|
763 |
->getSelect();
|
764 |
$select2 = Mage::getModel('newsletter/subscriber')
|
765 |
->getCollection()
|
766 |
+
//->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
767 |
->addFieldToFilter('store_id', $storeId)
|
768 |
->getSelect();
|
769 |
$select2->reset(Zend_Db_Select::COLUMNS);
|
791 |
/** @var Varien_Db_Select $query */
|
792 |
$query = Mage::getModel('newsletter/subscriber')
|
793 |
->getCollection()
|
794 |
+
//->addFieldToFilter('subscriber_status', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
795 |
->addFieldToFilter('store_id', $storeId)
|
796 |
->getSelect();
|
797 |
|
800 |
->reset(Zend_Db_Select::FROM)
|
801 |
->reset(Zend_Db_Select::WHERE)
|
802 |
->from($this->getTable('newsletter_subscriber'), '')
|
803 |
+
//->where($this->getTable('newsletter_subscriber') . '.subscriber_status = ?', Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
804 |
->where($this->getTable('newsletter_subscriber') . '.store_id = ?', $storeId);
|
805 |
|
806 |
if ($count) {
|
827 |
return $query;
|
828 |
}
|
829 |
|
830 |
+
|
831 |
+
|
832 |
/**
|
833 |
* Retrieve export file name, either stored value or generated by webservice
|
834 |
*
|
895 |
$exportPageSize = 5000;
|
896 |
}
|
897 |
|
|
|
|
|
898 |
$report = null;
|
899 |
$reportId = $this->_getHelper()->getCurrentReportId($exportType, $storeId);
|
900 |
|
928 |
}
|
929 |
}
|
930 |
|
931 |
+
if (!isset($query) || !$query) {
|
932 |
+
$query = $this->getCustomerIdCollection($startPagination, $storeId, false);
|
933 |
+
}
|
934 |
+
|
935 |
if (Mage::getStoreConfig('dev/log/active') && $report) {
|
936 |
$report->log($query->assemble());
|
937 |
}
|
948 |
$exporter->setEnclosure(); // Dolist does not use enclosures
|
949 |
$exporter->setDelimiter(chr(9));
|
950 |
|
|
|
|
|
|
|
951 |
$i = 0;
|
952 |
// Write one line for each subscriber to export
|
953 |
foreach ($collection as $object) {
|
959 |
}
|
960 |
}
|
961 |
|
|
|
962 |
$localFilename = sys_get_temp_dir() . '/' . $exportFileName; // Temporary filename
|
963 |
|
964 |
// Write in tmp CSV file
|
965 |
+
$exporter->export($localFilename, $object, 'dolist', 'auto', true, $storeId);
|
966 |
|
967 |
//We reset until all content is exported
|
968 |
$localFilename = null;
|
995 |
return $localFilename;
|
996 |
}
|
997 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
998 |
/**
|
999 |
* Generate segment file
|
1000 |
* File format:
|
1008 |
*
|
1009 |
* @return string Tmp segment file name
|
1010 |
*/
|
1011 |
+
public function generateSegmentFile($collection, $exportFileName, $report = null)
|
1012 |
{
|
1013 |
$localFilename = null;
|
1014 |
|
1015 |
// Perform only if collection is not empty
|
1016 |
if ($collection->getSize() > 0) {
|
1017 |
+
/** @var Dolist_Net_Model_Exporter_Csv $exporter */
|
1018 |
$exporter = Mage::getModel('dolist/exporter_csv');
|
1019 |
$exporter->setEnclosure(); // Dolist does not use enclosures
|
1020 |
$exporter->setDelimiter(chr(9));
|
1021 |
|
1022 |
// Write one line for each customer to export
|
1023 |
+
$i = 0;
|
1024 |
foreach ($collection as $customer) {
|
1025 |
|
1026 |
+
$localFilename = sys_get_temp_dir() . '/' . $exportFileName; // Temporary filename
|
1027 |
+
|
1028 |
+
// Write in tmp CSV file
|
1029 |
+
$exportObj = array(
|
1030 |
+
'prefix' => '',
|
1031 |
+
'object' => $customer,
|
1032 |
+
'fields' => array(
|
1033 |
+
'email'
|
1034 |
)
|
1035 |
);
|
1036 |
+
$exporter->export($localFilename, $exportObj, 'auto', 'auto', true);
|
1037 |
|
1038 |
+
if($i && $i%100 === 0)
|
1039 |
+
if($report instanceof Dolist_Net_Model_Reports) {
|
1040 |
+
$report->progress(100);
|
1041 |
+
$report->log('100 lines added...');
|
1042 |
+
}
|
1043 |
+
$i++;
|
1044 |
}
|
1045 |
}
|
1046 |
|
1122 |
return $result;
|
1123 |
}
|
1124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1125 |
/**
|
1126 |
* Perfom segment export for given $segmentId to Dolist-V8
|
1127 |
* Perform one export for each website.
|
1137 |
{
|
1138 |
$return = true;
|
1139 |
|
1140 |
+
/** @var Enterprise_CustomerSegment_Model_Segment $customerSegment */
|
1141 |
$customerSegment = Mage::getModel('enterprise_customersegment/segment')->load($segmentId);
|
1142 |
$exportPerformed = false;
|
1143 |
|
1146 |
|
1147 |
$storeId = $storeIds[$configWebsiteId];
|
1148 |
|
1149 |
+
$websiteNames = array();
|
1150 |
+
if(is_array($websiteListToFilter)) {
|
1151 |
+
foreach($websiteListToFilter as $websiteId) {
|
1152 |
+
$websiteNames[] = Mage::app()->getWebsite($websiteId)->getName();
|
1153 |
+
}
|
1154 |
+
} else {
|
1155 |
+
$websiteNames[] = Mage::app()->getWebsite(reset($websiteIds))->getName();
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
/** @var Dolist_Net_Model_Reports $report */
|
1159 |
+
$report = Mage::getModel('dolist/reports');
|
1160 |
+
$report->setData(array(
|
1161 |
+
'type' => 'export',
|
1162 |
+
'name' => sprintf('Segment Export %s - (%s)',$customerSegment->getName(),join(',', $websiteNames ))
|
1163 |
+
))->save();
|
1164 |
+
|
1165 |
if ($customerSegment->getId()) {
|
1166 |
|
1167 |
// Retrieve segment customers to export
|
1171 |
->addSegmentFilter($customerSegment)
|
1172 |
->addWebsiteFilter($websiteListToFilter);
|
1173 |
|
1174 |
+
$report->start($collection->count());
|
1175 |
+
|
1176 |
if ($collection->count() > 0) {
|
1177 |
|
1178 |
// Create new import.
|
1179 |
+
$flagCode = 'dolist_segment_filename_' . $segmentId;
|
1180 |
+
|
1181 |
+
// First, try to retrieve stored value
|
1182 |
+
/** @var Mage_Core_Model_Flag $flag */
|
1183 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
1184 |
+
|
1185 |
+
if ($flag->getId() != null) {
|
1186 |
+
$exportFileName = $flag->getFlagData();
|
1187 |
+
}
|
1188 |
+
else {
|
1189 |
+
// ImportName : 'MAGENTO - <segment.name> - <YYYYMMDD_HHmmss>
|
1190 |
+
$now = new Zend_Date();
|
1191 |
+
$importName = 'MAGENTO - ' . $customerSegment->getName() . ' - ' . $now->toString('YYYYMMdd_HHmmss');
|
1192 |
+
$response = $this->dolistV8CreateImport($importName, true, $storeId);
|
1193 |
+
$exportFileName = $response->getData('FileName');
|
1194 |
+
|
1195 |
+
$flag = Mage::getModel('core/flag', array('flag_code' => $flagCode));
|
1196 |
+
$flag->setFlagData($exportFileName)->save();
|
1197 |
+
}
|
1198 |
|
1199 |
// Create segment file
|
1200 |
if (!is_null($exportFileName)) {
|
1201 |
+
$localFilename = $this->generateSegmentFile($collection, $exportFileName, $report);
|
1202 |
|
1203 |
if (!is_null($localFilename)) {
|
1204 |
// Push file on FTP server
|
1205 |
+
$exportPerformed = $this->pushExportFile($exportFileName, $localFilename, $storeId, $report);
|
1206 |
}
|
1207 |
}
|
1208 |
|
1209 |
if ($exportPerformed) {
|
1210 |
// If success, check if this segment has already been exported
|
1211 |
// If never exported, add it to exported segment list (dolist_exported_segment_list)
|
1212 |
+
foreach($websiteListToFilter as $websiteId) {
|
1213 |
+
$storeId = Mage::app()->getWebsite($websiteId)->getDefaultStore()->getId();
|
1214 |
+
$this->_getHelper()->addExportedSegment($customerSegment->getId(), $storeId);
|
1215 |
+
}
|
1216 |
|
1217 |
Mage::getSingleton('adminhtml/session')
|
1218 |
->addSuccess($this->_getHelper()->__("Exporting segment id %s to Dolist-V8 succeeded", $segmentId));
|
1219 |
+
$report->end('success');
|
1220 |
+
$report->log(sprintf('Exporting segment id %s to Dolist-V8 succeeded', $segmentId));
|
1221 |
} else {
|
1222 |
|
1223 |
Mage::getSingleton('adminhtml/session')
|
1224 |
->addError($this->_getHelper()->__("Exporting segment id %s to Dolist-V8 failed", $segmentId));
|
1225 |
+
|
1226 |
+
$report->end('error');
|
1227 |
+
$report->log(sprintf('Exporting segment id %s to Dolist-V8 failed', $segmentId));
|
1228 |
+
|
1229 |
$return = false;
|
1230 |
}
|
1231 |
|
1232 |
} else {
|
1233 |
Mage::getSingleton('adminhtml/session')
|
1234 |
->addError($this->_getHelper()->__("Segment id %s has not been exported because it is empty", $segmentId));
|
1235 |
+
$report->end('error');
|
1236 |
+
$report->log(sprintf('Segment id %s has not been exported because it is empty', $segmentId));
|
1237 |
+
|
1238 |
$return = false;
|
1239 |
}
|
1240 |
|
1242 |
Mage::getSingleton('adminhtml/session')
|
1243 |
->addNotice($this->_getHelper()->__("Segment id %s couldn't be loaded", $segmentId));
|
1244 |
|
1245 |
+
$report->end('error');
|
1246 |
+
$report->log(sprintf('Segment id %s couldn\'t be loaded', $segmentId));
|
1247 |
|
1248 |
// Remove this segment from dolist exported segment list
|
1249 |
+
$allStoreIds = array_keys(Mage::app()->getStores());
|
1250 |
+
// Remove exported segments from all stores
|
1251 |
+
foreach ($allStoreIds as $storeId) {
|
1252 |
+
$this->_getHelper()->removeExportedSegment($segmentId, $storeId);
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
$report->delete();
|
1256 |
+
|
1257 |
}
|
1258 |
}
|
1259 |
|
app/code/community/Dolist/Net/Model/System/Config/Source/Dolistv8/Customerattributelist.php
CHANGED
@@ -79,18 +79,21 @@ class Dolist_Net_Model_System_Config_Source_Dolistv8_Customerattributelist
|
|
79 |
// Display these attributes
|
80 |
if (in_array($key, $backendType)) {
|
81 |
$options[] = array('value' => array(), 'label' => Mage::helper('dolist')->__("Calculated attributes"));
|
82 |
-
foreach ($calculatedAttributeList as $id => $calculatedAttributeItem) {
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
}
|
96 |
}
|
79 |
// Display these attributes
|
80 |
if (in_array($key, $backendType)) {
|
81 |
$options[] = array('value' => array(), 'label' => Mage::helper('dolist')->__("Calculated attributes"));
|
|
|
82 |
|
83 |
+
if(is_array($calculatedAttributeList)) {
|
84 |
+
foreach ($calculatedAttributeList as $id => $calculatedAttributeItem) {
|
85 |
+
|
86 |
+
if ($calculatedAttributeItem['adapter'] == "separator") {
|
87 |
+
$options[] = array(
|
88 |
+
'value' => array(),
|
89 |
+
'label' => Mage::helper('dolist')->__($calculatedAttributeItem['label'])
|
90 |
+
);
|
91 |
+
} else {
|
92 |
+
$options[] = array(
|
93 |
+
'value' => $id,
|
94 |
+
'label' => Mage::helper('dolist')->__($calculatedAttributeItem['label'])
|
95 |
+
);
|
96 |
+
}
|
97 |
}
|
98 |
}
|
99 |
}
|
app/code/community/Dolist/Net/controllers/Adminhtml/CustomerdolistController.php
CHANGED
@@ -10,6 +10,10 @@
|
|
10 |
*/
|
11 |
class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Controller_Action
|
12 |
{
|
|
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* index action
|
@@ -27,6 +31,9 @@ class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Contr
|
|
27 |
$this->renderLayout();
|
28 |
}
|
29 |
|
|
|
|
|
|
|
30 |
public function reportAction()
|
31 |
{
|
32 |
$this->loadLayout();
|
@@ -163,6 +170,8 @@ class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Contr
|
|
163 |
}
|
164 |
|
165 |
$this->_getSession()->addSuccess($this->_getHelper()->__('Saved.'));
|
|
|
|
|
166 |
} catch (Exception $e) {
|
167 |
$this->_getSession()->addError($e->getMessage());
|
168 |
$this->_redirect('*/*/', array('store' => $storeId));
|
@@ -346,6 +355,18 @@ class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Contr
|
|
346 |
$stores = $this->_getStoreList($storeId);
|
347 |
$error = false;
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
// Loop on every store
|
350 |
foreach ($stores as $storeId) {
|
351 |
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
@@ -395,6 +416,10 @@ class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Contr
|
|
395 |
);
|
396 |
}
|
397 |
|
|
|
|
|
|
|
|
|
398 |
$this->_redirect('*/*/', array('store' => $initStoreId));
|
399 |
}
|
400 |
|
@@ -468,17 +493,28 @@ class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Contr
|
|
468 |
*/
|
469 |
public function exportSegmentAction()
|
470 |
{
|
471 |
-
// Load segment
|
472 |
$segmentId = $this->getRequest()->getParam('segment_id');
|
473 |
-
$
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
|
479 |
-
|
480 |
-
$
|
481 |
-
|
|
|
482 |
|
483 |
// Redirect to segment index page
|
484 |
$this->_redirect('*/customersegment/index');
|
@@ -500,10 +536,40 @@ class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Contr
|
|
500 |
$this->_getHelper()->removeExportedSegment($segmentId, $storeId);
|
501 |
}
|
502 |
|
|
|
|
|
|
|
|
|
503 |
// Redirect to segment index page
|
504 |
$this->_redirect('*/customersegment/index');
|
505 |
}
|
506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
/**
|
508 |
* Return array with default store view ids for each website
|
509 |
*
|
10 |
*/
|
11 |
class Dolist_Net_Adminhtml_CustomerdolistController extends Mage_Adminhtml_Controller_Action
|
12 |
{
|
13 |
+
protected function _isAllowed()
|
14 |
+
{
|
15 |
+
return Mage::getSingleton('admin/session')->isAllowed('customer/customerdolist');
|
16 |
+
}
|
17 |
|
18 |
/**
|
19 |
* index action
|
31 |
$this->renderLayout();
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
*/
|
37 |
public function reportAction()
|
38 |
{
|
39 |
$this->loadLayout();
|
170 |
}
|
171 |
|
172 |
$this->_getSession()->addSuccess($this->_getHelper()->__('Saved.'));
|
173 |
+
|
174 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
175 |
} catch (Exception $e) {
|
176 |
$this->_getSession()->addError($e->getMessage());
|
177 |
$this->_redirect('*/*/', array('store' => $storeId));
|
355 |
$stores = $this->_getStoreList($storeId);
|
356 |
$error = false;
|
357 |
|
358 |
+
|
359 |
+
$process = new Mage_Index_Model_Process();
|
360 |
+
$process->setId("segment_export");
|
361 |
+
if($process->isLocked()){
|
362 |
+
$this->_getHelper()->logError('segment_export is locked');
|
363 |
+
$this->_getSession()->addError($this->_getHelper()->__('Another export is already running. Please try again later.'));
|
364 |
+
// Redirect to segment edit page
|
365 |
+
$this->_redirect('*/*/', array('store' => $initStoreId));
|
366 |
+
return;
|
367 |
+
}
|
368 |
+
$process->lockAndBlock();
|
369 |
+
|
370 |
// Loop on every store
|
371 |
foreach ($stores as $storeId) {
|
372 |
if ($this->_getHelper()->isDolistV8Enabled($storeId)) {
|
416 |
);
|
417 |
}
|
418 |
|
419 |
+
|
420 |
+
$process->unlock();
|
421 |
+
|
422 |
+
|
423 |
$this->_redirect('*/*/', array('store' => $initStoreId));
|
424 |
}
|
425 |
|
493 |
*/
|
494 |
public function exportSegmentAction()
|
495 |
{
|
|
|
496 |
$segmentId = $this->getRequest()->getParam('segment_id');
|
497 |
+
$process = new Mage_Index_Model_Process();
|
498 |
+
$process->setId("segment_export");
|
499 |
+
if($process->isLocked()){
|
500 |
+
$this->_getHelper()->logError('segment_export is locked');
|
501 |
+
$this->_getSession()->addError($this->_getHelper()->__('Another export is already running. Please try again later.'));
|
502 |
+
// Redirect to segment edit page
|
503 |
+
$this->_redirect('*/customersegment/edit/',array('id'=> $segmentId));
|
504 |
+
return;
|
505 |
+
}
|
506 |
+
$process->lockAndBlock();
|
507 |
+
|
508 |
+
// Force new segment on dolist platforme
|
509 |
+
$flagCode = 'dolist_segment_filename_' . $segmentId;
|
510 |
+
$flag = Mage::getModel('core/flag')->load($flagCode, 'flag_code');
|
511 |
+
$flag->delete();
|
512 |
+
|
513 |
|
514 |
+
// Trigger Export
|
515 |
+
$this->_getHelper()->exportSegment($segmentId);
|
516 |
+
|
517 |
+
$process->unlock();
|
518 |
|
519 |
// Redirect to segment index page
|
520 |
$this->_redirect('*/customersegment/index');
|
536 |
$this->_getHelper()->removeExportedSegment($segmentId, $storeId);
|
537 |
}
|
538 |
|
539 |
+
//we can assume that segment's Export should not be cronned
|
540 |
+
$this->_getHelper()->removeSegmentExportFromCron($segmentId);
|
541 |
+
|
542 |
+
|
543 |
// Redirect to segment index page
|
544 |
$this->_redirect('*/customersegment/index');
|
545 |
}
|
546 |
|
547 |
+
/**
|
548 |
+
* Add Segment Export to Magento Cron
|
549 |
+
*/
|
550 |
+
public function addSegmentExportToCronAction() {
|
551 |
+
// Load segment
|
552 |
+
$segmentId = $this->getRequest()->getParam('segment_id');
|
553 |
+
|
554 |
+
$this->_getHelper()->addSegmentExportToCron($segmentId);
|
555 |
+
|
556 |
+
// Redirect to segment edit page
|
557 |
+
$this->_redirect('*/customersegment/edit/',array('id'=> $segmentId));
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Remove Segment Export from Magento Cron
|
562 |
+
*/
|
563 |
+
public function removeSegmentExportFromCronAction() {
|
564 |
+
// Load segment
|
565 |
+
$segmentId = $this->getRequest()->getParam('segment_id');
|
566 |
+
|
567 |
+
$this->_getHelper()->removeSegmentExportFromCron($segmentId);
|
568 |
+
|
569 |
+
// Redirect to segment edit page
|
570 |
+
$this->_redirect('*/customersegment/edit/',array('id'=> $segmentId));
|
571 |
+
}
|
572 |
+
|
573 |
/**
|
574 |
* Return array with default store view ids for each website
|
575 |
*
|
app/code/community/Dolist/Net/controllers/Adminhtml/System/Config/TestconnectionController.php
CHANGED
@@ -9,6 +9,11 @@
|
|
9 |
*/
|
10 |
class Dolist_Net_Adminhtml_System_Config_TestconnectionController extends Mage_Adminhtml_Controller_Action
|
11 |
{
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* Check connection to Dolist-V8 webservice,
|
14 |
* then check connection to Dolist-V8 FTP server
|
9 |
*/
|
10 |
class Dolist_Net_Adminhtml_System_Config_TestconnectionController extends Mage_Adminhtml_Controller_Action
|
11 |
{
|
12 |
+
protected function _isAllowed()
|
13 |
+
{
|
14 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/config/dolist');
|
15 |
+
}
|
16 |
+
|
17 |
/**
|
18 |
* Check connection to Dolist-V8 webservice,
|
19 |
* then check connection to Dolist-V8 FTP server
|
app/code/community/Dolist/Net/etc/config.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
<modules>
|
6 |
<Dolist_Net>
|
7 |
-
<version>2.0.0.
|
8 |
</Dolist_Net>
|
9 |
</modules>
|
10 |
|
@@ -149,13 +149,12 @@
|
|
149 |
<!-- Calculated attributes -->
|
150 |
<!-- Custom int fields -->
|
151 |
<calculated_attributes>
|
152 |
-
<varchar
|
|
|
153 |
<is_subscriber>
|
154 |
<label>Subscriber state of the customer</label>
|
155 |
-
<adapter
|
156 |
</is_subscriber>
|
157 |
-
</varchar>
|
158 |
-
<int>
|
159 |
<first_order_amount>
|
160 |
<label>First order amount excluding tax</label>
|
161 |
<adapter>dolist/dolistv8_export_adapter_int_firstOrderAmountExclTax</adapter>
|
@@ -458,27 +457,11 @@
|
|
458 |
<sales_order_place_after>
|
459 |
<observers>
|
460 |
<dolist_sales_order_place_after>
|
461 |
-
<class>dolist/
|
462 |
<method>onNewOrder</method>
|
463 |
</dolist_sales_order_place_after>
|
464 |
</observers>
|
465 |
</sales_order_place_after>
|
466 |
-
<checkout_cart_product_add_after>
|
467 |
-
<observers>
|
468 |
-
<dolist_checkout_cart_product_add_after>
|
469 |
-
<class>dolist/dolistv8_calculatedfields</class>
|
470 |
-
<method>onNewCart</method>
|
471 |
-
</dolist_checkout_cart_product_add_after>
|
472 |
-
</observers>
|
473 |
-
</checkout_cart_product_add_after>
|
474 |
-
<checkout_cart_save_after>
|
475 |
-
<observers>
|
476 |
-
<dolist_checkout_cart_save_after>
|
477 |
-
<class>dolist/dolistv8_calculatedfields</class>
|
478 |
-
<method>onNewCart</method>
|
479 |
-
</dolist_checkout_cart_save_after>
|
480 |
-
</observers>
|
481 |
-
</checkout_cart_save_after>
|
482 |
</events>
|
483 |
</frontend>
|
484 |
|
@@ -520,6 +503,13 @@
|
|
520 |
<model>dolist/observer::sendQueuedMessages</model>
|
521 |
</run>
|
522 |
</dolist_send_queued_messages>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
</jobs>
|
524 |
</crontab>
|
525 |
|
4 |
|
5 |
<modules>
|
6 |
<Dolist_Net>
|
7 |
+
<version>2.0.0.7</version>
|
8 |
</Dolist_Net>
|
9 |
</modules>
|
10 |
|
149 |
<!-- Calculated attributes -->
|
150 |
<!-- Custom int fields -->
|
151 |
<calculated_attributes>
|
152 |
+
<varchar />
|
153 |
+
<int>
|
154 |
<is_subscriber>
|
155 |
<label>Subscriber state of the customer</label>
|
156 |
+
<adapter />
|
157 |
</is_subscriber>
|
|
|
|
|
158 |
<first_order_amount>
|
159 |
<label>First order amount excluding tax</label>
|
160 |
<adapter>dolist/dolistv8_export_adapter_int_firstOrderAmountExclTax</adapter>
|
457 |
<sales_order_place_after>
|
458 |
<observers>
|
459 |
<dolist_sales_order_place_after>
|
460 |
+
<class>dolist/observer</class>
|
461 |
<method>onNewOrder</method>
|
462 |
</dolist_sales_order_place_after>
|
463 |
</observers>
|
464 |
</sales_order_place_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
</events>
|
466 |
</frontend>
|
467 |
|
503 |
<model>dolist/observer::sendQueuedMessages</model>
|
504 |
</run>
|
505 |
</dolist_send_queued_messages>
|
506 |
+
<dolist_segment_export>
|
507 |
+
<!-- Every 5 minutes -->
|
508 |
+
<schedule><cron_expr>0 5 * * *</cron_expr></schedule>
|
509 |
+
<run>
|
510 |
+
<model>dolist/observer::cronSegmentExport</model>
|
511 |
+
</run>
|
512 |
+
</dolist_segment_export>
|
513 |
</jobs>
|
514 |
</crontab>
|
515 |
|
app/code/community/Dolist/Net/sql/dolist_setup/mysql4-upgrade-2.0.0.6-2.0.0.7.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/** @var Mage_Core_Model_Resource_Setup $installer */
|
4 |
+
$installer = $this;
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
// Create new table to store Dolist-EMT templates
|
8 |
+
$installer->run("ALTER TABLE {$this->getTable('dolist_dolistv8_calculatedfields')} DROP PRIMARY KEY;");
|
9 |
+
$installer->run("ALTER TABLE {$this->getTable('dolist_dolistv8_calculatedfields')} ADD id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
|
10 |
+
$installer->run("ALTER TABLE {$this->getTable('dolist_dolistv8_calculatedfields')} ADD store_id INT AFTER start_date;");
|
11 |
+
$installer->run("ALTER TABLE {$this->getTable('dolist_dolistv8_calculatedfields')} ADD CONSTRAINT uc_customerid_storeid UNIQUE (customer_id,store_id);");
|
12 |
+
$installer->run("TRUNCATE TABLE {$this->getTable('dolist_dolistv8_calculatedfields')};");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/dolist/customerexport.phtml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
/** @var
|
3 |
?>
|
4 |
<?php echo $this->getChildHtml(); ?>
|
5 |
<table class="form-list">
|
1 |
<?php
|
2 |
+
/** @var Dolist_Net_Block_Adminhtml_Edit_Tab_Export $this */
|
3 |
?>
|
4 |
<?php echo $this->getChildHtml(); ?>
|
5 |
<table class="form-list">
|
app/locale/fr_FR/Dolist_Net.csv
CHANGED
@@ -85,6 +85,8 @@
|
|
85 |
"Last not ordered cart date","Date de dernier panier non commandé"
|
86 |
"Export again this segment to Dolist-V8","Exporter à nouveau ce segment vers Dolist-V8"
|
87 |
"Remove this segment from exported list","Cesser l'export de ce segment"
|
|
|
|
|
88 |
"Connection test refreshes Dolist-EMT template list","Le test de connexion rafraîchit la liste des gabarits Dolist-EMT"
|
89 |
"Save configuration before adding first template mapping","Sauvegarder la configuration avant d'ajouter des correspondances de gabarits"
|
90 |
"Magento customer attribute","Attribut client Magento"
|
85 |
"Last not ordered cart date","Date de dernier panier non commandé"
|
86 |
"Export again this segment to Dolist-V8","Exporter à nouveau ce segment vers Dolist-V8"
|
87 |
"Remove this segment from exported list","Cesser l'export de ce segment"
|
88 |
+
"Enable export from Cron","Activer l'export par le Cron"
|
89 |
+
"Disable export from Cron","Désactiver l'export par le Cron"
|
90 |
"Connection test refreshes Dolist-EMT template list","Le test de connexion rafraîchit la liste des gabarits Dolist-EMT"
|
91 |
"Save configuration before adding first template mapping","Sauvegarder la configuration avant d'ajouter des correspondances de gabarits"
|
92 |
"Magento customer attribute","Attribut client Magento"
|
package.xml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?xml version='1.0' encoding='utf-8'?>
|
2 |
-
<package><name>Dolist_Net</name><license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license><notes>v2</notes><time>10:05:15</time><__packager>build_package.py v0.0.3</__packager><summary>Official extension for Dolist email marketing solution.</summary><stability>stable</stability><__commit_hash>bbe8758e8f3259cf09224fa34f534d7db35b050e</__commit_hash><version>2.0.0.6</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="9116ca5966c127c3a065d3ccf991f6dd" name="dolist.xml" /></dir><dir name="template"><dir name="dolist"><file hash="05db7ca8032551aea167c573c06d0287" name="configuration.phtml" /><file hash="930ce49748a97b9bd3b0024cf08ba026" name="customerexport.phtml" /><dir name="store"><file hash="4100093e08cf4ce57c317ee017cba630" name="switcher.phtml" /></dir><dir name="system"><dir name="config"><dir name="dolistemt"><file hash="ba10b87cd51fef3d88a0dcf747d8b8dc" name="testconnection.phtml" /></dir><dir name="dolistv8"><file hash="a9b57b458cb1dfb83f0f5061be82f9f9" name="array.phtml" /><file hash="5c89a07ee29d11640870592c2edfc114" name="testconnection.phtml" /></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Dolist"><dir name="Net"><dir name="Block"><dir name="Adminhtml"><file hash="b5c65ae9b68d820870fb38e78e100265" name="Customerexport.php" /><file hash="fd8f4ad560d6777587a9ed90223c18c4" name="Edit.php" /><file hash="2e37abf70940f00b110279cef8b82280" name="Report.php" /><dir name="Customer"><file hash="8f6d9965be320c972d998f34171c4a5a" name="Edit.php" /></dir><dir name="Customersegment"><file hash="cf6a52e571dd475b96e93c00a8e2b5f0" name="Edit.php" /></dir><dir name="Edit"><file hash="057c9ee5853ea17801c990b42385fa5f" name="Form.php" /><file hash="45aba333e3e017601eff3a730e2991df" name="Tabs.php" /><dir name="Tab"><file hash="d93a56df1f7d60a8f4d275886f150ddf" name="Configuration.php" /><file hash="d1299519d583afd8b8afdad5ddafc326" name="Export.php" /><file hash="a55d01b5e4d114b20adef94f5dc503db" name="Report.php" /></dir></dir><dir name="System"><dir name="Config"><file hash="8393df0943d5575c31cb596c8d368ce6" name="Abstract.php" /><file hash="77b6b112b2492beb3dae124efe0b924a" name="Date.php" /><file hash="59fa9be3d71a648ab9d4dfe697d2e183" name="Enable.php" /><file hash="c62a40696ae0028b2908ed34768d8c2a" name="Switcher.php" /><file hash="883194919f569b7f49a12fd9d4f83082" name="Templatelist.php" /><dir name="Dolistemt"><file hash="9193591b22b093d9e5baaf83b0818ec8" name="Templatelist.php" /><file hash="4025ca1026614c48996c57112b25cf1c" name="Templatemapping.php" /><file hash="b95697d6fea9d16003f01b5a1f63db6a" name="Testconnection.php" /></dir><dir name="Dolistv8"><file hash="5be525c4398c036956d6489aa8fa582d" name="Attributelist.php" /><file hash="88336cf98961a1df4e23bf2de819c17d" name="Customdatefields.php" /><file hash="485252191fb609780609f7ec6b9d0fad" name="Customerattributelist.php" /><file hash="96a8428b3503291204d8922500e39210" name="Customintfields.php" /><file hash="2011749c69cae4968ded68dc4cce6945" name="Customstrfields.php" /><file hash="cb016b986834178808cad7dd9c8d96c2" name="Testconnection.php" /></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file hash="794e6ade20567baee95139a73d684ea7" name="CustomerdolistController.php" /><dir name="System"><dir name="Config"><file hash="50676bfa56ac975dfb6a4d717d71e550" name="TestconnectionController.php" /></dir></dir></dir></dir><dir name="etc"><file hash="1f9d77e2b9f8e4b86f54f272eb213218" name="adminhtml.xml" /><file hash="59d110f1b2c3b4028e8ba062c1c7acf3" name="config.xml" /><file hash="f0d6b4651431d1d11532fe9402fc5003" name="system.xml" /></dir><dir name="Helper"><file hash="8693ced58cdbe1c151a04e5611eee235" name="Data.php" /><file hash="1d28b2acc7b47c17bb17af60e60c891d" name="Log.php" /><file hash="46b027b6f19b5a4ba72e1e992ac95269" name="Queue.php" /></dir><dir name="Model"><file hash="61da7cc29853bb9ce85b0bb587545c99" name="Customersegment.php" /><file hash="bf7e03605a1bd1d5fc5eba5c96f8231d" name="Observer.php" /><file hash="df11dd8d15b4603d5434fabf9cbf1d0e" name="Reports.php" /><file hash="889862dc356c85a109eebd2389dd1528" name="Service.php" /><dir name="Adminhtml"><file hash="c50d803637b3b679e1d944ed882c201e" name="Observer.php" /><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Serialized"><file hash="ce8002b5ba1bd19901b5de4db7200672" name="Array.php" /></dir></dir><dir name="Source"><file hash="d594a5df0ec9c76ca0f55ac0c4422f56" name="Timeperiods.php" /></dir></dir></dir></dir><dir name="Dolistemt"><file hash="67917ea713604769bdc5e348d04830b4" name="Template.php" /><dir name="Email"><file hash="7e39b7cdc9a6f62c784937317d344d0b" name="Template.php" /></dir><dir name="Message"><file hash="3dd939ec132047606cc1f322677bcc1c" name="Queued.php" /></dir></dir><dir name="Dolistv8"><file hash="c15976cfb0b7a5805e724f11f89fe417" name="Calculatedfields.php" /><file hash="b1d4006ddf6c62b46bcadeb6a6b56fc0" name="Customfields.php" /><file hash="6a91b08ff749b635ffaff68a267cee53" name="Ftp.php" /></dir><dir name="Exporter"><file hash="010c818b65be9e51519e476d59c5e735" name="Csv.php" /><dir name="Adapter"><file hash="c52f8d05c198b2ee691d25104aa191ca" name="Date.php" /><file hash="66b2ee18bdf3924011a068f936b8818a" name="Default.php" /><file hash="797f1a935a1f8e1a9ce213d6cf03c235" name="Int.php" /></dir></dir><dir name="Mysql4"><file hash="7a3a3de6ef2fd144c192ef60357e370f" name="Reports.php" /><dir name="Dolistemt"><file hash="f972ef82ba3003da8d849e60df044440" name="Template.php" /><dir name="Message"><file hash="466461ebec5e905d89659698a21ed0ed" name="Queued.php" /><dir name="Queued"><file hash="1b0ed0a91ecd7fb5941c694221d12578" name="Collection.php" /></dir></dir><dir name="Template"><file hash="7b845449076c1dfaee11a7b04cb50400" name="Collection.php" /></dir></dir><dir name="Dolistv8"><file hash="255c05052b1a4371193d6174ea9a8a94" name="Calculatedfields.php" /><file hash="0c66d48562faaa3641a190becc66f618" name="Customfields.php" /><dir name="Calculatedfields"><file hash="106dc6dd921c134378002992e4d94e08" name="Collection.php" /></dir><dir name="Customfields"><file hash="93a52bb46b05487e79471448b46ca51e" name="Collection.php" /></dir><dir name="Export"><dir name="Adapter"><file hash="08a870e9120893dfe74349313bbb0c75" name="Abstract.php" /><file hash="83d064b83909ac3a4421d474397b5029" name="Address1.php" /><file hash="b9dc124ff88ecbaa750e580f97b246f2" name="Address2.php" /><file hash="b87316bf23926e93485b6868323f88a4" name="Address3.php" /><file hash="75e243f2a3526955ea7d94cad4798ec2" name="City.php" /><file hash="b2372fe91c4a61bd81549fbee4722e85" name="Company.php" /><file hash="176e3a58ab1371ffd87a8dd41ff6231b" name="Country.php" /><file hash="a47e3ada99704b2cfebd7ed151d39762" name="Default.php" /><file hash="a96d9b7d0d6e810533df36901e0dc7ac" name="Fax.php" /><file hash="f044aed5b697abb4b5b7722307413fef" name="Phone.php" /><file hash="1a84be76756c8b6e550a683301bf455f" name="Postcode.php" /><dir name="Date"><file hash="c46a5408f7f314ff3a81c71af1fa15e2" name="Default.php" /><file hash="5e90b0c82c4c462d4c54354d4ded91eb" name="Firstorder.php" /><file hash="918c1394a1079430b1805d424766d057" name="Lastorder.php" /><file hash="0e27cb7666aa7d95c0208e86bf29f15c" name="Lastquotenotordered.php" /></dir><dir name="Int"><file hash="d7f2bf25cde508f18ef3591aa9b7239d" name="Avgnbdifferentproductsperorder.php" /><file hash="0e7cef58f9745684107006c1f19c3c18" name="Avgnbdifferentproductsperorderline.php" /><file hash="1072246ffeaaf5c65b2c44a831a9197c" name="Avgnbproductsperorder.php" /><file hash="01676e283d4796cb156d8e7ca9443f8b" name="Avgorderamountexcltax.php" /><file hash="aaa1d0f0019ded333b6f01c29ca30484" name="Avgorderamountincltax.php" /><file hash="695e7ca8c23c38962257db17c5de17f9" name="Firstorderamountexcltax.php" /><file hash="121c81d6629a62e03845391b263fc21a" name="Firstorderamountincltax.php" /><file hash="5e1363c976eb7cc14f3ca64ff1de9d1a" name="Lastnotorderedcartamountexcltax.php" /><file hash="383b2b6d23e6073c1719fcdda44f63fb" name="Lastnotorderedcartamountincltax.php" /><file hash="4ae1b5a8956d432aa224a07d39eda15b" name="Lastorderamountexcltax.php" /><file hash="0db2ba5e1f4a36aca38b003ba88daf3d" name="Lastorderamountincltax.php" /><file hash="c32efb9a18ad8f6645a940c9bd925c6c" name="Nbpromotionrulesused.php" /><file hash="b2d30d69093ac1e1971de239f2294414" name="Totalorderamountexcltax.php" /><file hash="fe7a821618d817fff93eb23a6e162c4c" name="Totalorderamountincltax.php" /><file hash="b203fbd80b38d7dd974fddb042661af0" name="Totalorderedproducts.php" /><file hash="d8fea3d3d98cd4ade81931d72b7eba0c" name="Totalorders.php" /></dir></dir></dir></dir><dir name="Reports"><file hash="3ec7cc4fd35c539db1411cbe0bf98a25" name="Collection.php" /></dir></dir><dir name="Service"><dir name="Dolistemt"><dir name="Request"><file hash="bfe76bef2f1301562f9003cacd82b5b1" name="Getauthenticationtoken.php" /><file hash="f08c835bbcb6ca69daf2bdeaaea28a4c" name="Gettemplatelist.php" /><file hash="06062e2ccf54c189874000d50d909de6" name="SendEmail.php" /></dir><dir name="Response"><file hash="387210c798ed818d410ac7a62a8f7a08" name="Getauthenticationtoken.php" /><file hash="ab3db8a6a1bc1e38dc163c28f64f9612" name="Gettemplatelist.php" /><file hash="45d3740fe05ecd90bf722b19725ad7d8" name="SendEmail.php" /></dir></dir><dir name="Dolistv8"><dir name="Request"><file hash="55a56a710b88398c99f1aaeb01816976" name="Createimport.php" /><file hash="af14961d044f007696452307b9f7a89e" name="Getauthenticationtoken.php" /><file hash="d085194dc5f599884969de6f5cc32f9d" name="Getcontact.php" /><file hash="d710c9e4d512a929e4aa2a0c32d1becc" name="Getfieldlist.php" /></dir><dir name="Response"><file hash="93e32967b4c1ba7ae0981023e49f9471" name="Createimport.php" /><file hash="5f14b532c12728495b6163092bce1003" name="Getauthenticationtoken.php" /><file hash="59c766c7fefe70fb1e18571f8904942a" name="Getcontact.php" /><file hash="1ab5aef6b09f671a382d5eef5a182bce" name="Getfieldlist.php" /></dir></dir><dir name="Message"><file hash="e10bee52c6cebf4ccd4c93a41afe5ae0" name="Abstract.php" /></dir></dir><dir name="System"><dir name="Config"><file hash="b64b291b560a8522094c203333cadae6" name="Check.php" /><dir name="Source"><file hash="3d7e993ac25b0ade883df78a9ef97b19" name="Group.php" /><dir name="Dolistemt"><file hash="de59edbfbae9db377ff561a49fcb8ff5" name="Defaulttemplate.php" /><file hash="6fe1abcf43f76468eaea0e3616584243" name="Errors.php" /><file hash="8debc19194b97203394b012b0258ac91" name="Template.php" /></dir><dir name="Dolistv8"><file hash="081e4f0dea584a9d4ff435069190671a" name="Customerattributelist.php" /><file hash="10485fb8f6477d5a55c2b8ddcd4c9d02" name="Customfield.php" /></dir><dir name="Email"><file hash="e5af986543b65db2684e4a62a3967a89" name="Template.php" /></dir></dir></dir></dir></dir><dir name="sql"><dir name="dolist_setup"><file hash="dfd2ee346a310bb35daafbe68c4794a3" name="mysql4-install-0.0.1.0.php" /><file hash="f073c48493bc6a0b9a58faec608c870c" name="mysql4-upgrade-0.0.1.0-0.0.1.1.php" /><file hash="cd2920e566d6733b9688720416ed5211" name="mysql4-upgrade-0.0.1.1-0.0.2.0.php" /><file hash="33db9c1fa136d893692a73e1b670caff" name="mysql4-upgrade-0.0.2.0-0.0.3.0.php" /><file hash="8b8d0544161894ab0c9ae56a5d2cca8c" name="mysql4-upgrade-0.0.3.0-0.0.4.0.php" /><file hash="afc7e28dd865ab008376ab58453a3221" name="mysql4-upgrade-0.0.4.0-0.0.5.0.php" /><file hash="33f55ec12f8b0481320491bfb71da3b1" name="mysql4-upgrade-0.0.5.0-0.0.6.0.php" /></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file hash="5c3a5d77ce534894afdaaabde6ef6af7" name="Dolist_Net.csv" /></dir></target><target name="magelocal"><dir name="modules"><file hash="73c963262d3cb6831bf1240a165b215e" name="Dolist_Net.xml" /></dir></target></contents><dependencies><required><php><min>5.3.2</min><max>5.6.0</max></php></required></dependencies><authors><author><name>Dolist</name><user>Dolist</user><email>magento@dolist.net</email></author></authors><date>2015-06-02</date><compatibile /><channel>community</channel><description>&lt;p&gt;Take simultaneous advantage from both Magento's Community Edition or Enterprise
|
3 |
Edition and Dolist's e-mail marketing platforms power. Dolist-V8 for e-mail marketing campaigns and
|
4 |
Dolist-EMT for
|
5 |
transactional messages in order to optimize both your prospects and customers relationship.&lt;/p&gt;&#xD;
|
1 |
<?xml version='1.0' encoding='utf-8'?>
|
2 |
+
<package><name>Dolist_Net</name><license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license><notes>v2</notes><time>13:57:27</time><__packager>build_package.py v0.0.3</__packager><summary>Official extension for Dolist email marketing solution.</summary><stability>stable</stability><__commit_hash>e705dcaf98dc83be11b11be412f50a8d10ce7901</__commit_hash><version>2.0.0.7</version><extends /><contents><target name="mage"><dir name="shell"><file hash="9b10f919097a3abe18833961359449c4" name="dolist_export_segments.php" /></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="9116ca5966c127c3a065d3ccf991f6dd" name="dolist.xml" /></dir><dir name="template"><dir name="dolist"><file hash="05db7ca8032551aea167c573c06d0287" name="configuration.phtml" /><file hash="468f46da25ee4c840098e0754299a9a1" name="customerexport.phtml" /><dir name="store"><file hash="4100093e08cf4ce57c317ee017cba630" name="switcher.phtml" /></dir><dir name="system"><dir name="config"><dir name="dolistemt"><file hash="ba10b87cd51fef3d88a0dcf747d8b8dc" name="testconnection.phtml" /></dir><dir name="dolistv8"><file hash="a9b57b458cb1dfb83f0f5061be82f9f9" name="array.phtml" /><file hash="5c89a07ee29d11640870592c2edfc114" name="testconnection.phtml" /></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Dolist"><dir name="Net"><dir name="Block"><dir name="Adminhtml"><file hash="b5c65ae9b68d820870fb38e78e100265" name="Customerexport.php" /><file hash="fd8f4ad560d6777587a9ed90223c18c4" name="Edit.php" /><file hash="2e37abf70940f00b110279cef8b82280" name="Report.php" /><dir name="Customer"><file hash="8f6d9965be320c972d998f34171c4a5a" name="Edit.php" /></dir><dir name="Customersegment"><file hash="cf6a52e571dd475b96e93c00a8e2b5f0" name="Edit.php" /></dir><dir name="Edit"><file hash="057c9ee5853ea17801c990b42385fa5f" name="Form.php" /><file hash="45aba333e3e017601eff3a730e2991df" name="Tabs.php" /><dir name="Tab"><file hash="d93a56df1f7d60a8f4d275886f150ddf" name="Configuration.php" /><file hash="d1299519d583afd8b8afdad5ddafc326" name="Export.php" /><file hash="a55d01b5e4d114b20adef94f5dc503db" name="Report.php" /></dir></dir><dir name="System"><dir name="Config"><file hash="8393df0943d5575c31cb596c8d368ce6" name="Abstract.php" /><file hash="77b6b112b2492beb3dae124efe0b924a" name="Date.php" /><file hash="59fa9be3d71a648ab9d4dfe697d2e183" name="Enable.php" /><file hash="c62a40696ae0028b2908ed34768d8c2a" name="Switcher.php" /><file hash="883194919f569b7f49a12fd9d4f83082" name="Templatelist.php" /><dir name="Dolistemt"><file hash="9193591b22b093d9e5baaf83b0818ec8" name="Templatelist.php" /><file hash="4025ca1026614c48996c57112b25cf1c" name="Templatemapping.php" /><file hash="b95697d6fea9d16003f01b5a1f63db6a" name="Testconnection.php" /></dir><dir name="Dolistv8"><file hash="5be525c4398c036956d6489aa8fa582d" name="Attributelist.php" /><file hash="88336cf98961a1df4e23bf2de819c17d" name="Customdatefields.php" /><file hash="485252191fb609780609f7ec6b9d0fad" name="Customerattributelist.php" /><file hash="96a8428b3503291204d8922500e39210" name="Customintfields.php" /><file hash="2011749c69cae4968ded68dc4cce6945" name="Customstrfields.php" /><file hash="cb016b986834178808cad7dd9c8d96c2" name="Testconnection.php" /></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file hash="651fed35ece40312ac21e2fb8efd1dea" name="CustomerdolistController.php" /><dir name="System"><dir name="Config"><file hash="9c42cecb347d4ffb4db54ee901345359" name="TestconnectionController.php" /></dir></dir></dir></dir><dir name="etc"><file hash="1f9d77e2b9f8e4b86f54f272eb213218" name="adminhtml.xml" /><file hash="3a7b19a76b041fe1fecaf3e56c55dc63" name="config.xml" /><file hash="f0d6b4651431d1d11532fe9402fc5003" name="system.xml" /></dir><dir name="Helper"><file hash="d7058bb7a3ae89c7a586d8b42ad64062" name="Data.php" /><file hash="1d28b2acc7b47c17bb17af60e60c891d" name="Log.php" /><file hash="46b027b6f19b5a4ba72e1e992ac95269" name="Queue.php" /></dir><dir name="Model"><file hash="61da7cc29853bb9ce85b0bb587545c99" name="Customersegment.php" /><file hash="84647426508242e63f12912bd49ce3be" name="Observer.php" /><file hash="5a820cdad6554553ba9ecc189862397e" name="Reports.php" /><file hash="0b383f9c0be8903d28b11f45cc643e1b" name="Service.php" /><dir name="Adminhtml"><file hash="8ff835df0881b386870fe52a116e10bb" name="Observer.php" /><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Serialized"><file hash="ce8002b5ba1bd19901b5de4db7200672" name="Array.php" /></dir></dir><dir name="Source"><file hash="d594a5df0ec9c76ca0f55ac0c4422f56" name="Timeperiods.php" /></dir></dir></dir></dir><dir name="Dolistemt"><file hash="67917ea713604769bdc5e348d04830b4" name="Template.php" /><dir name="Email"><file hash="7e39b7cdc9a6f62c784937317d344d0b" name="Template.php" /></dir><dir name="Message"><file hash="3dd939ec132047606cc1f322677bcc1c" name="Queued.php" /></dir></dir><dir name="Dolistv8"><file hash="e627285fbd280f66ba8a286a666c289f" name="Calculatedfields.php" /><file hash="b1d4006ddf6c62b46bcadeb6a6b56fc0" name="Customfields.php" /><file hash="6a91b08ff749b635ffaff68a267cee53" name="Ftp.php" /></dir><dir name="Exporter"><file hash="35b7d1d7f6d5e49297be4e342c19d60a" name="Csv.php" /><dir name="Adapter"><file hash="c52f8d05c198b2ee691d25104aa191ca" name="Date.php" /><file hash="66b2ee18bdf3924011a068f936b8818a" name="Default.php" /><file hash="797f1a935a1f8e1a9ce213d6cf03c235" name="Int.php" /></dir></dir><dir name="Mysql4"><file hash="7a3a3de6ef2fd144c192ef60357e370f" name="Reports.php" /><dir name="Dolistemt"><file hash="f972ef82ba3003da8d849e60df044440" name="Template.php" /><dir name="Message"><file hash="466461ebec5e905d89659698a21ed0ed" name="Queued.php" /><dir name="Queued"><file hash="1b0ed0a91ecd7fb5941c694221d12578" name="Collection.php" /></dir></dir><dir name="Template"><file hash="7b845449076c1dfaee11a7b04cb50400" name="Collection.php" /></dir></dir><dir name="Dolistv8"><file hash="63e8d5f6589c8ffa587dbfdb6ad21027" name="Calculatedfields.php" /><file hash="0c66d48562faaa3641a190becc66f618" name="Customfields.php" /><dir name="Calculatedfields"><file hash="106dc6dd921c134378002992e4d94e08" name="Collection.php" /></dir><dir name="Customfields"><file hash="93a52bb46b05487e79471448b46ca51e" name="Collection.php" /></dir><dir name="Export"><dir name="Adapter"><file hash="08a870e9120893dfe74349313bbb0c75" name="Abstract.php" /><file hash="83d064b83909ac3a4421d474397b5029" name="Address1.php" /><file hash="b9dc124ff88ecbaa750e580f97b246f2" name="Address2.php" /><file hash="b87316bf23926e93485b6868323f88a4" name="Address3.php" /><file hash="75e243f2a3526955ea7d94cad4798ec2" name="City.php" /><file hash="b2372fe91c4a61bd81549fbee4722e85" name="Company.php" /><file hash="176e3a58ab1371ffd87a8dd41ff6231b" name="Country.php" /><file hash="a47e3ada99704b2cfebd7ed151d39762" name="Default.php" /><file hash="a96d9b7d0d6e810533df36901e0dc7ac" name="Fax.php" /><file hash="f044aed5b697abb4b5b7722307413fef" name="Phone.php" /><file hash="1a84be76756c8b6e550a683301bf455f" name="Postcode.php" /><dir name="Date"><file hash="c46a5408f7f314ff3a81c71af1fa15e2" name="Default.php" /><file hash="a48a0eed243297a43aa6461c1b5b6e03" name="Firstorder.php" /><file hash="05f3b71b731ef2705dbb6fa1368e896f" name="Lastorder.php" /><file hash="b05b9d4832f4d71b514cef3df5d2fffc" name="Lastquotenotordered.php" /></dir><dir name="Int"><file hash="ee37b3a560f78424f854a7b0ddfcb81a" name="Avgnbdifferentproductsperorder.php" /><file hash="99ed6713b29425a263f344605c30a92e" name="Avgnbdifferentproductsperorderline.php" /><file hash="4ced1dd88746fae3cc32d6c8f3305aec" name="Avgnbproductsperorder.php" /><file hash="cac637c6aa9c4e9b97c36727c9d7ecab" name="Avgorderamountexcltax.php" /><file hash="6573738e3dc12cbb2348633635c3f1fb" name="Avgorderamountincltax.php" /><file hash="89686b61f7e201bf64a26c91ff035a34" name="Firstorderamountexcltax.php" /><file hash="50f04945e8297134b6fde3c305ae4d0b" name="Firstorderamountincltax.php" /><file hash="93cd651cf1b246f8670604e1278b938d" name="Lastnotorderedcartamountexcltax.php" /><file hash="5ba8b21f31f42f72d017579313d7be02" name="Lastnotorderedcartamountincltax.php" /><file hash="60cb423f6ee43a558c6a1f376838701f" name="Lastorderamountexcltax.php" /><file hash="e59c163c0f82fe449ee6d4da5f3a02b9" name="Lastorderamountincltax.php" /><file hash="6adaf658e0cd36f0980344c727439d4c" name="Nbpromotionrulesused.php" /><file hash="f0c0d785e76069fd95095d33cd10f88f" name="Totalorderamountexcltax.php" /><file hash="0aca766b611a08ea57d01b8f8066e77f" name="Totalorderamountincltax.php" /><file hash="713e6a127000c24fa32edd98f3893e32" name="Totalorderedproducts.php" /><file hash="215bb7375fe16e53c4230659819c1e62" name="Totalorders.php" /></dir></dir></dir></dir><dir name="Reports"><file hash="3ec7cc4fd35c539db1411cbe0bf98a25" name="Collection.php" /></dir></dir><dir name="Service"><dir name="Dolistemt"><dir name="Request"><file hash="bfe76bef2f1301562f9003cacd82b5b1" name="Getauthenticationtoken.php" /><file hash="f08c835bbcb6ca69daf2bdeaaea28a4c" name="Gettemplatelist.php" /><file hash="06062e2ccf54c189874000d50d909de6" name="SendEmail.php" /></dir><dir name="Response"><file hash="387210c798ed818d410ac7a62a8f7a08" name="Getauthenticationtoken.php" /><file hash="ab3db8a6a1bc1e38dc163c28f64f9612" name="Gettemplatelist.php" /><file hash="45d3740fe05ecd90bf722b19725ad7d8" name="SendEmail.php" /></dir></dir><dir name="Dolistv8"><dir name="Request"><file hash="55a56a710b88398c99f1aaeb01816976" name="Createimport.php" /><file hash="af14961d044f007696452307b9f7a89e" name="Getauthenticationtoken.php" /><file hash="d085194dc5f599884969de6f5cc32f9d" name="Getcontact.php" /><file hash="d710c9e4d512a929e4aa2a0c32d1becc" name="Getfieldlist.php" /></dir><dir name="Response"><file hash="93e32967b4c1ba7ae0981023e49f9471" name="Createimport.php" /><file hash="5f14b532c12728495b6163092bce1003" name="Getauthenticationtoken.php" /><file hash="59c766c7fefe70fb1e18571f8904942a" name="Getcontact.php" /><file hash="1ab5aef6b09f671a382d5eef5a182bce" name="Getfieldlist.php" /></dir></dir><dir name="Message"><file hash="e10bee52c6cebf4ccd4c93a41afe5ae0" name="Abstract.php" /></dir></dir><dir name="System"><dir name="Config"><file hash="b64b291b560a8522094c203333cadae6" name="Check.php" /><dir name="Source"><file hash="3d7e993ac25b0ade883df78a9ef97b19" name="Group.php" /><dir name="Dolistemt"><file hash="de59edbfbae9db377ff561a49fcb8ff5" name="Defaulttemplate.php" /><file hash="6fe1abcf43f76468eaea0e3616584243" name="Errors.php" /><file hash="8debc19194b97203394b012b0258ac91" name="Template.php" /></dir><dir name="Dolistv8"><file hash="7bcd4cf17c51414df7c4633b6c89ddf2" name="Customerattributelist.php" /><file hash="10485fb8f6477d5a55c2b8ddcd4c9d02" name="Customfield.php" /></dir><dir name="Email"><file hash="e5af986543b65db2684e4a62a3967a89" name="Template.php" /></dir></dir></dir></dir></dir><dir name="sql"><dir name="dolist_setup"><file hash="dfd2ee346a310bb35daafbe68c4794a3" name="mysql4-install-0.0.1.0.php" /><file hash="f073c48493bc6a0b9a58faec608c870c" name="mysql4-upgrade-0.0.1.0-0.0.1.1.php" /><file hash="cd2920e566d6733b9688720416ed5211" name="mysql4-upgrade-0.0.1.1-0.0.2.0.php" /><file hash="33db9c1fa136d893692a73e1b670caff" name="mysql4-upgrade-0.0.2.0-0.0.3.0.php" /><file hash="8b8d0544161894ab0c9ae56a5d2cca8c" name="mysql4-upgrade-0.0.3.0-0.0.4.0.php" /><file hash="afc7e28dd865ab008376ab58453a3221" name="mysql4-upgrade-0.0.4.0-0.0.5.0.php" /><file hash="33f55ec12f8b0481320491bfb71da3b1" name="mysql4-upgrade-0.0.5.0-0.0.6.0.php" /><file hash="3b88e0c1e51137ebf1e3af199a4d59ab" name="mysql4-upgrade-2.0.0.6-2.0.0.7.php" /></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file hash="fb0e33fdd1a7018e9cd00cb7ec2f8e73" name="Dolist_Net.csv" /></dir></target><target name="magelocal"><dir name="modules"><file hash="73c963262d3cb6831bf1240a165b215e" name="Dolist_Net.xml" /></dir></target></contents><dependencies><required><php><min>5.3.2</min><max>5.6.0</max></php></required></dependencies><authors><author><name>Dolist</name><user>Dolist</user><email>magento@dolist.net</email></author></authors><date>2015-08-26</date><compatibile /><channel>community</channel><description>&lt;p&gt;Take simultaneous advantage from both Magento's Community Edition or Enterprise
|
3 |
Edition and Dolist's e-mail marketing platforms power. Dolist-V8 for e-mail marketing campaigns and
|
4 |
Dolist-EMT for
|
5 |
transactional messages in order to optimize both your prospects and customers relationship.&lt;/p&gt;&#xD;
|
shell/dolist_export_segments.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once 'abstract.php';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Dolist Segment Export Shell Script
|
6 |
+
*
|
7 |
+
* @category Mage
|
8 |
+
* @package Mage_Shell
|
9 |
+
*/
|
10 |
+
class Mage_Shell_Segments_Export extends Mage_Shell_Abstract
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Run script
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
public function run()
|
18 |
+
{
|
19 |
+
if ($ids = $this->getArg('ids')) {
|
20 |
+
$this->_getHelper()->logDebug('Starting Segments export');
|
21 |
+
$process = new Mage_Index_Model_Process();
|
22 |
+
$process->setId("segment_export");
|
23 |
+
if($process->isLocked()){
|
24 |
+
$this->_getHelper()->logDebug('segment_export process is already locked');
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
$process->lockAndBlock();
|
28 |
+
$this->_getHelper()->logDebug('segment_export was not locked, but now it is');
|
29 |
+
|
30 |
+
//Récuperation des ids des segments
|
31 |
+
$idList = explode(',',$ids);
|
32 |
+
$idList = array_filter($idList, 'is_numeric');
|
33 |
+
|
34 |
+
$existingSegmentIds = Mage::getModel('enterprise_customersegment/segment')->getCollection()->getAllIds();
|
35 |
+
$exportSegments = TRUE;
|
36 |
+
|
37 |
+
if (!is_array($existingSegmentIds)) {
|
38 |
+
$exportSegments = FALSE;
|
39 |
+
$msg = 'No segments defined yet.';
|
40 |
+
$this->_getHelper()->logError($msg);
|
41 |
+
} else {
|
42 |
+
foreach($idList as $segmentId) {
|
43 |
+
if (!in_array($segmentId, $existingSegmentIds)) {
|
44 |
+
$exportSegments = FALSE;
|
45 |
+
$msg = sprintf('Segment Id %s does not exist.',$segmentId);
|
46 |
+
$this->_getHelper()->logError($msg);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
if ($exportSegments) {
|
52 |
+
foreach($idList as $segmentId) {
|
53 |
+
$this->_getHelper()->exportSegment($segmentId);
|
54 |
+
}
|
55 |
+
} else {
|
56 |
+
$msg = 'No segment were exported, please check segment ids provided';
|
57 |
+
$this->_getHelper()->logError($msg);
|
58 |
+
}
|
59 |
+
$process->unlock();
|
60 |
+
$this->_getHelper()->logDebug('Ending Segments export');
|
61 |
+
|
62 |
+
} else {
|
63 |
+
echo $this->usageHelp();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Retrieve Usage Help Message
|
69 |
+
*
|
70 |
+
*/
|
71 |
+
public function usageHelp()
|
72 |
+
{
|
73 |
+
return <<<USAGE
|
74 |
+
Usage: php -f dolist_export_segments.php -- [options]
|
75 |
+
|
76 |
+
--ids segmentId1,segmentId2 exports the list of segments defined by their id (comma separated)
|
77 |
+
help This help
|
78 |
+
|
79 |
+
USAGE;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Retrieve model helper
|
85 |
+
*
|
86 |
+
* @return Dolist_Net_Helper_Data
|
87 |
+
*/
|
88 |
+
protected function _getHelper()
|
89 |
+
{
|
90 |
+
return Mage::helper('dolist');
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
$shell = new Mage_Shell_Segments_Export();
|
95 |
+
$shell->run();
|