Version Notes
Works with the latest version of Freestyle
Download this release
Release Info
Developer | John Canare |
Extension | FreestyleMagento |
Version | 1.4.1 |
Comparing to | |
See all releases |
Version 1.4.1
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Builddate.php +23 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit.php +31 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Form.php +36 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/ErrorsRender.php +30 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/FilesPassiveRender.php +51 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/FilesRender.php +44 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/General.php +146 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/History.php +123 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/Passive.php +112 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/Queue.php +154 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/UpdatetimeRender.php +37 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tabs.php +126 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Notes.php +25 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/System/Config/Date.php +32 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/System/Config/Form/Button.php +67 -0
- app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Version.php +23 -0
- app/code/community/Freestyle/Advancedexport/Helper/Curl.php +198 -0
- app/code/community/Freestyle/Advancedexport/Helper/Data.php +550 -0
- app/code/community/Freestyle/Advancedexport/Helper/Debug.php +52 -0
- app/code/community/Freestyle/Advancedexport/Helper/NotificationSender.php +538 -0
- app/code/community/Freestyle/Advancedexport/Helper/Queue.php +51 -0
- app/code/community/Freestyle/Advancedexport/Helper/Website.php +76 -0
- app/code/community/Freestyle/Advancedexport/Model/Api.php +250 -0
- app/code/community/Freestyle/Advancedexport/Model/Configuration.php +19 -0
- app/code/community/Freestyle/Advancedexport/Model/Cronjob.php +77 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Abstract.php +754 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Category.php +98 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Customer.php +145 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Customergroup.php +66 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Order.php +107 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Product.php +317 -0
- app/code/community/Freestyle/Advancedexport/Model/Exportmodels/SimpleXMLExtended.php +20 -0
- app/code/community/Freestyle/Advancedexport/Model/History.php +26 -0
- app/code/community/Freestyle/Advancedexport/Model/Import/Entity/Customer.php +82 -0
- app/code/community/Freestyle/Advancedexport/Model/Import/Entity/Product.php +92 -0
- app/code/community/Freestyle/Advancedexport/Model/Invoice/Api.php +32 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/Configuration.php +18 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/Configuration/Collection.php +19 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/History.php +18 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/History/Collection.php +19 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/Passivemode.php +18 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/Passivemode/Collection.php +19 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/Queue.php +18 -0
- app/code/community/Freestyle/Advancedexport/Model/Mysql4/Queue/Collection.php +19 -0
- app/code/community/Freestyle/Advancedexport/Model/Observer.php +741 -0
- app/code/community/Freestyle/Advancedexport/Model/Order.php +66 -0
- app/code/community/Freestyle/Advancedexport/Model/Order/Api.php +87 -0
- app/code/community/Freestyle/Advancedexport/Model/Order/V2.php +15 -0
- app/code/community/Freestyle/Advancedexport/Model/Passivemode.php +213 -0
- app/code/community/Freestyle/Advancedexport/Model/Queue.php +755 -0
- app/code/community/Freestyle/Advancedexport/Model/Queuebatchsize.php +36 -0
- app/code/community/Freestyle/Advancedexport/Model/Resend.php +191 -0
- app/code/community/Freestyle/Advancedexport/Model/Website.php +31 -0
- app/code/community/Freestyle/Advancedexport/controllers/Adminhtml/AdvancedexportController.php +559 -0
- app/code/community/Freestyle/Advancedexport/controllers/FrontprocessController.php +324 -0
- app/code/community/Freestyle/Advancedexport/controllers/IndexController.php +164 -0
- app/code/community/Freestyle/Advancedexport/controllers/StatusController.php +436 -0
- app/code/community/Freestyle/Advancedexport/controllers/WebsiteController.php +67 -0
- app/code/community/Freestyle/Advancedexport/etc/adminhtml.xml +61 -0
- app/code/community/Freestyle/Advancedexport/etc/api.xml +166 -0
- app/code/community/Freestyle/Advancedexport/etc/config.xml +335 -0
- app/code/community/Freestyle/Advancedexport/etc/system.xml +354 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-install-0.0.1.php +40 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.0-1.2.1.php +163 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.1-1.2.2.php +57 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.11-1.3.0.php +73 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.2-1.2.3.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.3-1.2.4.php +56 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.4-1.2.6.php +32 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.6-1.2.8.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.8-1.2.11.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.8-1.2.9.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.9-1.2.10.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.0-1.3.1.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.1-1.3.2.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.2-1.3.3.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.3-1.3.4.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.4-1.3.5.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.5-1.3.6.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.6-1.3.7.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.7-1.3.8.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.8-1.4.0.php +29 -0
- app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.4.0-1.4.1.php +29 -0
- app/design/adminhtml/default/default/layout/advancedexport.xml +22 -0
- app/design/adminhtml/default/default/template/advancedexport/export_tab_content.phtml +188 -0
- app/design/adminhtml/default/default/template/advancedexport/system/config/button.phtml +27 -0
- app/etc/modules/Freestyle_Advancedexport.xml +9 -0
- freestyleexport/.htaccess +187 -0
- freestyleexport/delete.me +0 -0
- freestyleexport/tempFiles/delete.me +0 -0
- package.xml +18 -0
- skin/adminhtml/default/default/advancedexport/wait.gif +0 -0
- skin/adminhtml/default/enterprise/advancedexport/wait.gif +0 -0
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Builddate.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Builddate
|
14 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _getElementHtml(
|
18 |
+
Varien_Data_Form_Element_Abstract $element
|
19 |
+
)
|
20 |
+
{
|
21 |
+
return (string) Mage::helper('advancedexport')->getBuildDate() . "+";
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit
|
12 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
13 |
+
{
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
|
19 |
+
$this->_objectId = 'export_id';
|
20 |
+
$this->_blockGroup = 'advancedexport';
|
21 |
+
$this->_controller = 'adminhtml_form';
|
22 |
+
$this->_removeButton('save');
|
23 |
+
$this->_removeButton('reset');
|
24 |
+
$this->_removeButton('back');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getHeaderText()
|
28 |
+
{
|
29 |
+
return Mage::helper('advancedexport')->__('Export');
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Form.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Form
|
14 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _prepareForm()
|
18 |
+
{
|
19 |
+
$form = new Varien_Data_Form(
|
20 |
+
array(
|
21 |
+
'id' => 'edit_form',
|
22 |
+
'action' => $this->getUrl(
|
23 |
+
'*/*/processdata',
|
24 |
+
array(
|
25 |
+
'id' => $this->getRequest()->getParam('id'))
|
26 |
+
),
|
27 |
+
'method' => 'post',
|
28 |
+
'enctype' => 'multipart/form-data'
|
29 |
+
)
|
30 |
+
);
|
31 |
+
|
32 |
+
$form->setUseContainer(true);
|
33 |
+
$this->setForm($form);
|
34 |
+
return parent::_prepareForm();
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/ErrorsRender.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_ErrorsRender
|
14 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
15 |
+
{
|
16 |
+
|
17 |
+
public function render(Varien_Object $row)
|
18 |
+
{
|
19 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
20 |
+
$arr = unserialize($value);
|
21 |
+
$str = '';
|
22 |
+
if ($arr) {
|
23 |
+
foreach ($arr as $key => $one) {
|
24 |
+
unset($key);
|
25 |
+
$str.='<span>' . $one . '</span><br>';
|
26 |
+
}
|
27 |
+
}
|
28 |
+
return $str;
|
29 |
+
}
|
30 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/FilesPassiveRender.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_FilesPassiveRender
|
12 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function render(Varien_Object $row)
|
16 |
+
{
|
17 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
18 |
+
$arr = unserialize($value);
|
19 |
+
$str = '';
|
20 |
+
$counter = 1;
|
21 |
+
$baseUrl = Mage::getStoreConfig('web/secure/base_url');
|
22 |
+
$helper = Mage::helper('advancedexport');
|
23 |
+
if ($arr) {
|
24 |
+
foreach ($arr as $key => $one) {
|
25 |
+
unset($key);
|
26 |
+
if (isset($one['fileName'])) {
|
27 |
+
$fileName = trim($one['fileName']);
|
28 |
+
if ($helper->getIsFileExist($fileName)) {
|
29 |
+
$str.='<span>' . $counter++ . '. <a href="' . $baseUrl
|
30 |
+
. $helper->getExportfolder() . DS . $fileName .
|
31 |
+
'" target="_blank">' . $fileName .
|
32 |
+
'</a></span><br>';
|
33 |
+
} else {
|
34 |
+
$str.='<span>' . $counter++ . '. ' . $fileName .
|
35 |
+
' - <span style="font-weight:bold; color:red;">'
|
36 |
+
. 'deleted</span>' . '</span><br>';
|
37 |
+
}
|
38 |
+
if ($counter > 15) {
|
39 |
+
$str.='<span>...</span>';
|
40 |
+
break;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
} else {
|
45 |
+
return 'No files were created during this period';
|
46 |
+
}
|
47 |
+
unset($baseUrl);
|
48 |
+
unset($fileName);
|
49 |
+
return $str;
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/FilesRender.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_FilesRender
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
public function render(Varien_Object $row)
|
17 |
+
{
|
18 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
19 |
+
$arr = unserialize($value);
|
20 |
+
$str = '';
|
21 |
+
$helper = Mage::Helper('advancedexport');
|
22 |
+
|
23 |
+
$baseUrl = Mage::getStoreConfig('web/secure/base_url');
|
24 |
+
if ($arr) {
|
25 |
+
foreach ($arr as $key => $one) {
|
26 |
+
unset($key);
|
27 |
+
$fileName = trim($one);
|
28 |
+
if ($helper->getIsFileExist($fileName)) {
|
29 |
+
$str.='<span><a href="' . $baseUrl .
|
30 |
+
$helper->getExportfolder() . DS . $fileName . '">' .
|
31 |
+
$fileName . '</a></span><br>';
|
32 |
+
} else {
|
33 |
+
$str.='<span>' . $fileName . ' - <span style="font-weight'
|
34 |
+
. ':bold; color:red;">deleted</span>' . '</span><br>';
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
unset($fileName);
|
40 |
+
unset($baseUrl);
|
41 |
+
|
42 |
+
return $str;
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/General.php
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_General
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
14 |
+
{
|
15 |
+
|
16 |
+
public function getLastExportData()
|
17 |
+
{
|
18 |
+
$data = Mage::getModel('advancedexport/history')->getLastExportData();
|
19 |
+
if ($data->getCreatedFiles()) {
|
20 |
+
$data->setCreatedFiles(unserialize($data->getCreatedFiles()));
|
21 |
+
} else {
|
22 |
+
$data->setCreatedFiles(array());
|
23 |
+
}
|
24 |
+
return $data;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getIsPassiveEnabled()
|
28 |
+
{
|
29 |
+
$passiveEnabled = Mage::getModel('advancedexport/passivemode')
|
30 |
+
->getCollection()
|
31 |
+
->addFieldToFilter('passivemod_enabled', array('eq' => '1'));
|
32 |
+
if ($passiveEnabled->count()) {
|
33 |
+
return true;
|
34 |
+
}
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _prepareForm()
|
39 |
+
{
|
40 |
+
$form = new Varien_Data_Form();
|
41 |
+
$this->setForm($form);
|
42 |
+
$fieldset = $form->addFieldset(
|
43 |
+
'exportparams_form',
|
44 |
+
array('legend' => Mage::helper('advancedexport')
|
45 |
+
->__('Create Export Process'))
|
46 |
+
);
|
47 |
+
|
48 |
+
$fieldset->addField(
|
49 |
+
'export_entity', 'select', array(
|
50 |
+
'label' => Mage::helper('advancedexport')
|
51 |
+
->__('Entity To Export'),
|
52 |
+
'class' => 'required-entry',
|
53 |
+
'required' => true,
|
54 |
+
'name' => 'export_entity',
|
55 |
+
'values' => array(
|
56 |
+
'' => '',
|
57 |
+
'customergroup' => 'Customer Groups',
|
58 |
+
'customer' => 'Customers',
|
59 |
+
'product' => 'Products',
|
60 |
+
'category' => 'Categories',
|
61 |
+
'order' => 'Orders'
|
62 |
+
),
|
63 |
+
)
|
64 |
+
);
|
65 |
+
|
66 |
+
$fieldset->addField(
|
67 |
+
'batch_size', 'text', array(
|
68 |
+
'label' => Mage::helper('advancedexport')->__('Batch size'),
|
69 |
+
'class' => 'required-entry',
|
70 |
+
'required' => true,
|
71 |
+
'name' => 'batch_size',
|
72 |
+
'value' => '1000',
|
73 |
+
'class' => 'validate-digits',
|
74 |
+
)
|
75 |
+
);
|
76 |
+
|
77 |
+
$fieldset->addField(
|
78 |
+
'website_id', 'select', array(
|
79 |
+
'label' => Mage::helper('advancedexport')->__('Website ID'),
|
80 |
+
'class' => 'required-entry',
|
81 |
+
'required' => true,
|
82 |
+
'name' => 'website_id',
|
83 |
+
'values' => Mage::getModel('advancedexport/website')
|
84 |
+
->toOptionArray()
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$fieldset->addField(
|
89 |
+
'date_start',
|
90 |
+
'date', array(
|
91 |
+
'label' => Mage::helper('advancedexport')->__('Start Date'),
|
92 |
+
//'after_element_html' => '<small>Comments</small>',
|
93 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
94 |
+
'name' => 'date_start',
|
95 |
+
'format' => Mage::app()->getLocale()
|
96 |
+
->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
97 |
+
'class' => 'validate-date'
|
98 |
+
)
|
99 |
+
);
|
100 |
+
|
101 |
+
$fieldset->addField(
|
102 |
+
'date_end',
|
103 |
+
'date', array(
|
104 |
+
'label' => Mage::helper('advancedexport')->__('End Date'),
|
105 |
+
//'after_element_html' => '<small>Comments</small>',
|
106 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
107 |
+
'name' => 'date_end',
|
108 |
+
'format' => Mage::app()->getLocale()
|
109 |
+
->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
110 |
+
//'format' => 'M/d/y',
|
111 |
+
'class' => 'validate-date'
|
112 |
+
)
|
113 |
+
);
|
114 |
+
|
115 |
+
$fieldset->addField(
|
116 |
+
'ids_to_export', 'text', array(
|
117 |
+
'label' => Mage::helper('advancedexport')
|
118 |
+
->__('Enter ID\'s Separated By Comma'),
|
119 |
+
'name' => 'ids_to_export',
|
120 |
+
'after_element_html' => '<small><br>If both "Enter Dates" and '
|
121 |
+
. '"Entity IDs" are entered, files will be '
|
122 |
+
. 'generated by IDs</small>',
|
123 |
+
)
|
124 |
+
);
|
125 |
+
|
126 |
+
$this->setTemplate('advancedexport/export_tab_content.phtml');
|
127 |
+
|
128 |
+
$sessionData = Mage::getSingleton('adminhtml/session')
|
129 |
+
->getData('advancedExportValues');
|
130 |
+
//print_r($sessionData);
|
131 |
+
$hasDate = isset($sessionData['date_start'])
|
132 |
+
&& isset($sessionData['date_end']);
|
133 |
+
if ($hasDate) {
|
134 |
+
$sessionData['date_start'] = strtotime($sessionData['date_start']);
|
135 |
+
$sessionData['date_end'] = strtotime($sessionData['date_end']);
|
136 |
+
}
|
137 |
+
$form->setValues($sessionData);
|
138 |
+
|
139 |
+
return parent::_prepareForm();
|
140 |
+
}
|
141 |
+
|
142 |
+
public function getDeleteUrl()
|
143 |
+
{
|
144 |
+
return $this->getUrl('*/*/deleteexportfiles');
|
145 |
+
}
|
146 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/History.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_History
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
+
{
|
15 |
+
|
16 |
+
public $storeId;
|
17 |
+
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
parent::__construct();
|
21 |
+
$this->setId('historyGrid');
|
22 |
+
$this->setDefaultSort('id');
|
23 |
+
$this->setDefaultDir('desc');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
$this->setVarNameFilter('history_filter');
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareCollection()
|
30 |
+
{
|
31 |
+
$collection = Mage::getModel('advancedexport/history')->getCollection();
|
32 |
+
|
33 |
+
$this->setCollection($collection);
|
34 |
+
|
35 |
+
parent::_prepareCollection();
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function _prepareColumns()
|
41 |
+
{
|
42 |
+
$this->addColumn(
|
43 |
+
'id', array(
|
44 |
+
'header' => Mage::helper('advancedexport')->__('ID'),
|
45 |
+
'width' => '50px',
|
46 |
+
'type' => 'number',
|
47 |
+
'index' => 'id',
|
48 |
+
)
|
49 |
+
);
|
50 |
+
|
51 |
+
$this->addColumn(
|
52 |
+
'export_date', array(
|
53 |
+
'header' => Mage::helper('advancedexport')->__('Export Date'),
|
54 |
+
'index' => 'export_date',
|
55 |
+
'type' => 'datetime',
|
56 |
+
)
|
57 |
+
);
|
58 |
+
|
59 |
+
$this->addColumn(
|
60 |
+
'export_date_time_start', array(
|
61 |
+
'header' => Mage::helper('advancedexport')->__('Export Start Time'),
|
62 |
+
'index' => 'export_date_time_start',
|
63 |
+
'type' => 'datetime',
|
64 |
+
)
|
65 |
+
);
|
66 |
+
|
67 |
+
$this->addColumn(
|
68 |
+
'export_date_time_end', array(
|
69 |
+
'header' => Mage::helper('advancedexport')->__('Export End Time'),
|
70 |
+
'index' => 'export_date_time_end',
|
71 |
+
'type' => 'datetime',
|
72 |
+
)
|
73 |
+
);
|
74 |
+
|
75 |
+
$this->addColumn(
|
76 |
+
'created_files', array(
|
77 |
+
'header' => Mage::helper('advancedexport')->__('Created Files'),
|
78 |
+
'index' => 'created_files',
|
79 |
+
'renderer' => 'Freestyle_Advancedexport_Block_Adminhtml_'
|
80 |
+
. 'Form_Edit_Tab_FilesRender',
|
81 |
+
'filter' => false,
|
82 |
+
'sortable' => false,
|
83 |
+
)
|
84 |
+
);
|
85 |
+
|
86 |
+
$this->addColumn(
|
87 |
+
'init_from', array(
|
88 |
+
'header' => Mage::helper('advancedexport')->__('Init From'),
|
89 |
+
'index' => 'init_from',
|
90 |
+
'filter' => false,
|
91 |
+
'sortable' => false,
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
$this->addColumn(
|
96 |
+
'export_entity', array(
|
97 |
+
'header' => Mage::helper('advancedexport')->__('Exported Entity'),
|
98 |
+
'index' => 'export_entity',
|
99 |
+
'filter' => false,
|
100 |
+
'sortable' => false,
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
+
$this->addColumn(
|
105 |
+
'errors', array(
|
106 |
+
'header' => Mage::helper('advancedexport')->__('Errors'),
|
107 |
+
'index' => 'errors',
|
108 |
+
'renderer' => 'Freestyle_Advancedexport_Block_Adminhtml_'
|
109 |
+
. 'Form_Edit_Tab_ErrorsRender',
|
110 |
+
'filter' => false,
|
111 |
+
'sortable' => false,
|
112 |
+
)
|
113 |
+
);
|
114 |
+
|
115 |
+
|
116 |
+
return parent::_prepareColumns();
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getGridUrl()
|
120 |
+
{
|
121 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
122 |
+
}
|
123 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/Passive.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_Passive
|
12 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
13 |
+
{
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
parent::__construct();
|
18 |
+
$this->setId('passiveGrid');
|
19 |
+
$this->setDefaultSort('id');
|
20 |
+
$this->setDefaultDir('desc');
|
21 |
+
$this->setSaveParametersInSession(true);
|
22 |
+
$this->setUseAjax(true);
|
23 |
+
$this->setVarNameFilter('passive_filter');
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _prepareCollection()
|
27 |
+
{
|
28 |
+
$collection = Mage::getModel('advancedexport/passivemode')
|
29 |
+
->getCollection();
|
30 |
+
$this->setCollection($collection);
|
31 |
+
|
32 |
+
parent::_prepareCollection();
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function _prepareColumns()
|
38 |
+
{
|
39 |
+
$this->addColumn(
|
40 |
+
'id',
|
41 |
+
array(
|
42 |
+
'header'=> Mage::helper('advancedexport')->__('Mode ID'),
|
43 |
+
'width' => '50px',
|
44 |
+
'type' => 'number',
|
45 |
+
'index' => 'id',
|
46 |
+
)
|
47 |
+
);
|
48 |
+
|
49 |
+
$this->addColumn(
|
50 |
+
'passivemod_enabled',
|
51 |
+
array(
|
52 |
+
'header'=> Mage::helper('advancedexport')->__('Is Enabled'),
|
53 |
+
'index' => 'passivemod_enabled',
|
54 |
+
'type' => 'options',
|
55 |
+
'options' => array('0' => 'No', '1' => 'Yes')
|
56 |
+
)
|
57 |
+
);
|
58 |
+
|
59 |
+
$this->addColumn(
|
60 |
+
'passivemod_start',
|
61 |
+
array(
|
62 |
+
'header'=> Mage::helper('advancedexport')->__('Start Date'),
|
63 |
+
'index' => 'passivemod_start',
|
64 |
+
'type' => 'datetime',
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->addColumn(
|
69 |
+
'passivemod_end',
|
70 |
+
array(
|
71 |
+
'header'=> Mage::helper('advancedexport')->__('End Date'),
|
72 |
+
'index' => 'passivemod_end',
|
73 |
+
'type' => 'datetime',
|
74 |
+
)
|
75 |
+
);
|
76 |
+
|
77 |
+
$this->addColumn(
|
78 |
+
'created_files',
|
79 |
+
array(
|
80 |
+
'header'=> Mage::helper('advancedexport')->__(
|
81 |
+
'Created Files List'
|
82 |
+
),
|
83 |
+
'index' => 'created_files',
|
84 |
+
'type' => 'text',
|
85 |
+
'filter' =>false,
|
86 |
+
'sortable' =>false,
|
87 |
+
'renderer' => 'Freestyle_Advancedexport_Block_'
|
88 |
+
. 'Adminhtml_Form_Edit_Tab_FilesPassiveRender',
|
89 |
+
)
|
90 |
+
);
|
91 |
+
|
92 |
+
$this->addColumn(
|
93 |
+
'is_notification_sent',
|
94 |
+
array(
|
95 |
+
'header'=> Mage::helper('advancedexport')->__(
|
96 |
+
'Is Notification Sent'
|
97 |
+
),
|
98 |
+
'index' => 'is_notification_sent',
|
99 |
+
'type' => 'options',
|
100 |
+
'options' => array('0' => 'No', '1' => 'Yes')
|
101 |
+
)
|
102 |
+
);
|
103 |
+
|
104 |
+
return parent::_prepareColumns();
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
public function getGridUrl()
|
109 |
+
{
|
110 |
+
return $this->getUrl('*/*/gridpassive', array('_current'=>true));
|
111 |
+
}
|
112 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/Queue.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_Queue
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
14 |
+
{
|
15 |
+
|
16 |
+
public $storeId;
|
17 |
+
|
18 |
+
public function __construct()
|
19 |
+
{
|
20 |
+
parent::__construct();
|
21 |
+
$this->setId('queueGrid');
|
22 |
+
$this->setDefaultSort('id');
|
23 |
+
$this->setDefaultDir('desc');
|
24 |
+
$this->setSaveParametersInSession(true);
|
25 |
+
$this->setUseAjax(true);
|
26 |
+
$this->setVarNameFilter('queue_filter');
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareCollection()
|
30 |
+
{
|
31 |
+
$collection = Mage::getModel('advancedexport/queue')->getCollection();
|
32 |
+
|
33 |
+
$this->setCollection($collection);
|
34 |
+
|
35 |
+
parent::_prepareCollection();
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function _prepareMassaction()
|
41 |
+
{
|
42 |
+
$this->setMassactionIdField('queue_id');
|
43 |
+
$this->getMassactionBlock()->setFormFieldName('queue');
|
44 |
+
$this->getMassactionBlock()->addItem(
|
45 |
+
'send', array(
|
46 |
+
'label'=> Mage::helper('advancedexport')->__('Send Now'),
|
47 |
+
'url' => $this->getUrl('*/*/batchSend', array('' => '')),
|
48 |
+
'confirm' => Mage::helper('advancedexport')->__('Are you sure?')
|
49 |
+
)
|
50 |
+
);
|
51 |
+
//DE-11662
|
52 |
+
$this->getMassactionBlock()->addItem(
|
53 |
+
'update', array(
|
54 |
+
'label'=> Mage::helper('advancedexport')->__('Mark as Sent'),
|
55 |
+
'url' => $this->getUrl('*/*/batchUpdate', array('' => '')),
|
56 |
+
'confirm' => Mage::helper('advancedexport')->__('Are you sure?')
|
57 |
+
)
|
58 |
+
);
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
protected function _prepareColumns()
|
63 |
+
{
|
64 |
+
$this->addColumn(
|
65 |
+
'id', array(
|
66 |
+
'header' => Mage::helper('advancedexport')->__('ID'),
|
67 |
+
'width' => '50px',
|
68 |
+
'type' => 'number',
|
69 |
+
'index' => 'id',
|
70 |
+
)
|
71 |
+
);
|
72 |
+
|
73 |
+
$this->addColumn(
|
74 |
+
'entity_id', array(
|
75 |
+
'header' => Mage::helper('advancedexport')->__('Entity ID'),
|
76 |
+
'index' => 'entity_id',
|
77 |
+
'type' => 'number',
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->addColumn(
|
82 |
+
'entity_type', array(
|
83 |
+
'header' => Mage::helper('advancedexport')->__('Entity Type'),
|
84 |
+
'index' => 'entity_type',
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$this->addColumn(
|
89 |
+
'entity_value', array(
|
90 |
+
'header' => Mage::helper('advancedexport')->__('Entity Value'),
|
91 |
+
'index' => 'entity_value',
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
/*
|
96 |
+
*
|
97 |
+
// doesn't need to be shown why it was added to the queue
|
98 |
+
$this->addColumn('action', array(
|
99 |
+
'header' => Mage::helper('advancedexport')->__('Event Type'),
|
100 |
+
'index' => 'action',
|
101 |
+
));
|
102 |
+
*
|
103 |
+
*/
|
104 |
+
|
105 |
+
$this->addColumn(
|
106 |
+
'create_time', array(
|
107 |
+
'header' => Mage::helper('advancedexport')->__('Creation Time'),
|
108 |
+
'index' => 'create_time',
|
109 |
+
'type' => 'datetime',
|
110 |
+
)
|
111 |
+
);
|
112 |
+
|
113 |
+
$this->addColumn(
|
114 |
+
'update_time', array(
|
115 |
+
'header' => Mage::helper('advancedexport')->__('Update Time'),
|
116 |
+
'index' => 'update_time',
|
117 |
+
'type' => 'datetime',
|
118 |
+
'renderer' => 'Freestyle_Advancedexport_Block_Adminhtml'
|
119 |
+
. '_Form_Edit_Tab_UpdatetimeRender',
|
120 |
+
)
|
121 |
+
);
|
122 |
+
|
123 |
+
$this->addColumn(
|
124 |
+
'status', array(
|
125 |
+
'header' => Mage::helper('advancedexport')->__('Status'),
|
126 |
+
'index' => 'status',
|
127 |
+
)
|
128 |
+
);
|
129 |
+
|
130 |
+
|
131 |
+
$this->addColumn(
|
132 |
+
'error_msg', array(
|
133 |
+
'header' => Mage::helper('advancedexport')->__('Error Message'),
|
134 |
+
'sortable' => false,
|
135 |
+
'filter' => false,
|
136 |
+
'index' => 'error_msg',
|
137 |
+
)
|
138 |
+
);
|
139 |
+
|
140 |
+
$this->addColumn(
|
141 |
+
'scope_value', array(
|
142 |
+
'header' => Mage::helper('advancedexport')->__('Website Id'),
|
143 |
+
'index' => 'scope_value',
|
144 |
+
)
|
145 |
+
);
|
146 |
+
|
147 |
+
return parent::_prepareColumns();
|
148 |
+
}
|
149 |
+
|
150 |
+
public function getGridUrl()
|
151 |
+
{
|
152 |
+
return $this->getUrl('*/*/gridqueue', array('_current' => true));
|
153 |
+
}
|
154 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tab/UpdatetimeRender.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tab_UpdatetimeRender
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
//put your code here
|
17 |
+
public function render(Varien_Object $row)
|
18 |
+
{
|
19 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
20 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(
|
21 |
+
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM
|
22 |
+
);
|
23 |
+
//$arr = unserialize($value);
|
24 |
+
//Mage::log($value, 1, "updatetime.log");
|
25 |
+
if ($value == "0000-00-00 00:00:00") {
|
26 |
+
$str = ' ';
|
27 |
+
} else {
|
28 |
+
$str = Mage::app()->getLocale()
|
29 |
+
->date(
|
30 |
+
$value,
|
31 |
+
Varien_Date::DATETIME_INTERNAL_FORMAT
|
32 |
+
)
|
33 |
+
->toString($format);
|
34 |
+
}
|
35 |
+
return $str;
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Form/Edit/Tabs.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Form_Edit_Tabs
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
14 |
+
{
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
$this->setId('form_tabs');
|
20 |
+
$this->setDestElementId('edit_form');
|
21 |
+
$this->setTitle(Mage::helper('core')->__('Params'));
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
$this->addTab(
|
27 |
+
'general', array(
|
28 |
+
'label' => Mage::helper('core')->__('Manual Export'),
|
29 |
+
'content' => $this->getLayout()->createBlock(
|
30 |
+
'advancedexport/adminhtml_form_edit_tab_general'
|
31 |
+
)->toHtml(),
|
32 |
+
)
|
33 |
+
);
|
34 |
+
|
35 |
+
//Add Serializer for Product Grid and Creating Product Tab
|
36 |
+
|
37 |
+
$productsGrid = $this->getLayout()->createBlock(
|
38 |
+
'advancedexport/adminhtml_form_edit_tab_history',
|
39 |
+
'export_edit_tab_history'
|
40 |
+
);
|
41 |
+
$gridSerializer = $this->getLayout()->createBlock(
|
42 |
+
'adminhtml/widget_grid_serializer'
|
43 |
+
);
|
44 |
+
$gridSerializer->initSerializerBlock(
|
45 |
+
'export_edit_tab_history',
|
46 |
+
'getRelatedhistory',
|
47 |
+
'export_assigned_history',
|
48 |
+
'export_assigned_history'
|
49 |
+
);
|
50 |
+
|
51 |
+
|
52 |
+
$this->addTab(
|
53 |
+
'form_history', array(
|
54 |
+
'label' => Mage::helper('advancedexport')->__('Export History'),
|
55 |
+
'content' => $productsGrid->toHtml() . $gridSerializer->toHtml(),
|
56 |
+
)
|
57 |
+
);
|
58 |
+
|
59 |
+
//queue Grid
|
60 |
+
$queueGrid = $this->getLayout()->createBlock(
|
61 |
+
'advancedexport/adminhtml_form_edit_tab_queue',
|
62 |
+
'export_edit_tab_queue'
|
63 |
+
);
|
64 |
+
$queueSerializer = $this->getLayout()->createBlock(
|
65 |
+
'adminhtml/widget_grid_serializer'
|
66 |
+
);
|
67 |
+
$queueSerializer->initSerializerBlock(
|
68 |
+
'export_edit_tab_queue',
|
69 |
+
'getRelatedhistory',
|
70 |
+
'export_assigned_queue',
|
71 |
+
'export_assigned_queue'
|
72 |
+
);
|
73 |
+
|
74 |
+
$this->addTab(
|
75 |
+
'queue_history', array(
|
76 |
+
'label' => Mage::helper('advancedexport')->__('Queue History'),
|
77 |
+
'content' => $queueGrid->toHtml() . $queueSerializer->toHtml(),
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
if (Mage::Helper('advancedexport')->getEnablePassiveGui()=='1') {
|
82 |
+
$passiveGrid = $this->getLayout()->createBlock(
|
83 |
+
'advancedexport/adminhtml_form_edit_tab_passive',
|
84 |
+
'export_edit_tab_passive'
|
85 |
+
);
|
86 |
+
$passGridSerializer = $this->getLayout()->createBlock(
|
87 |
+
'adminhtml/widget_grid_serializer'
|
88 |
+
);
|
89 |
+
$passGridSerializer->initSerializerBlock(
|
90 |
+
'export_edit_tab_passive',
|
91 |
+
'getRelatedhistory',
|
92 |
+
'export_assigned_passive',
|
93 |
+
'export_assigned_passive'
|
94 |
+
);
|
95 |
+
|
96 |
+
$this->addTab(
|
97 |
+
'passive_history', array(
|
98 |
+
'label' => Mage::helper('advancedexport')
|
99 |
+
->__('Passive Mode History'),
|
100 |
+
'content' => $passiveGrid->toHtml()
|
101 |
+
. $passGridSerializer->toHtml(),
|
102 |
+
)
|
103 |
+
);
|
104 |
+
}
|
105 |
+
|
106 |
+
return parent::_prepareLayout();
|
107 |
+
}
|
108 |
+
/**
|
109 |
+
* Return ajax url for button
|
110 |
+
*
|
111 |
+
* @return string
|
112 |
+
*/
|
113 |
+
public function getAjaxCheckUrl()
|
114 |
+
{
|
115 |
+
return Mage::helper('adminhtml')
|
116 |
+
->getUrl('adminhtml/advancedexport/processdata');
|
117 |
+
}
|
118 |
+
|
119 |
+
/*
|
120 |
+
public function getLogFile()
|
121 |
+
{
|
122 |
+
return Mage::helper('advancedexport')->readLogFile();
|
123 |
+
}
|
124 |
+
*
|
125 |
+
*/
|
126 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Notes.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Notes
|
14 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _getElementHtml(
|
18 |
+
Varien_Data_Form_Element_Abstract $element
|
19 |
+
)
|
20 |
+
{
|
21 |
+
$returnMessage = "Please save all configuration "
|
22 |
+
. "changes prior to testing connection.";
|
23 |
+
return $returnMessage;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/System/Config/Date.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Block_Adminhtml_System_Config_Date
|
12 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
13 |
+
{
|
14 |
+
protected function _getElementHtml(
|
15 |
+
Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
+
{
|
18 |
+
$date = new Varien_Data_Form_Element_Date;
|
19 |
+
$data = array(
|
20 |
+
'name' => $element->getName(),
|
21 |
+
'html_id' => $element->getId(),
|
22 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
23 |
+
'time' => true
|
24 |
+
);
|
25 |
+
$date->setData($data);
|
26 |
+
$date->setValue($element->getValue()); //, $format);
|
27 |
+
$date->setFormat('MM/dd/yyyy HH:mm'); //add hour:minute to format
|
28 |
+
$date->setForm($element->getForm());
|
29 |
+
|
30 |
+
return $date->getElementHtml();
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/System/Config/Form/Button.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Block_Adminhtml_System_Config_Form_Button
|
13 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
14 |
+
{
|
15 |
+
/*
|
16 |
+
* Set template
|
17 |
+
*/
|
18 |
+
protected function _construct()
|
19 |
+
{
|
20 |
+
parent::_construct();
|
21 |
+
$this->setTemplate('advancedexport/system/config/button.phtml');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return element html
|
26 |
+
*
|
27 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
protected function _getElementHtml(
|
31 |
+
Varien_Data_Form_Element_Abstract $element
|
32 |
+
)
|
33 |
+
{
|
34 |
+
return $this->_toHtml();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Return ajax url for button
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getAjaxCheckUrl()
|
43 |
+
{
|
44 |
+
return Mage::helper('adminhtml')->getUrl(
|
45 |
+
'adminhtml/advancedexport/testconnection'
|
46 |
+
);
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Generate button html
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function getButtonHtml()
|
55 |
+
{
|
56 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
57 |
+
->setData(
|
58 |
+
array(
|
59 |
+
'id' => 'advancedexport_button',
|
60 |
+
'label' => $this->helper('adminhtml')->__('Test'),
|
61 |
+
'onclick' => 'javascript:check(); return false;'
|
62 |
+
)
|
63 |
+
);
|
64 |
+
|
65 |
+
return $button->toHtml();
|
66 |
+
}
|
67 |
+
}
|
app/code/community/Freestyle/Advancedexport/Block/Adminhtml/Version.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Block_Adminhtml_Version
|
14 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _getElementHtml(
|
18 |
+
Varien_Data_Form_Element_Abstract $element
|
19 |
+
)
|
20 |
+
{
|
21 |
+
return (string) Mage::helper('advancedexport')->getExtensionVersion();
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Freestyle/Advancedexport/Helper/Curl.php
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Helper_Curl{
|
14 |
+
public $sendErrorMessage = array();
|
15 |
+
public $exceptionMessage = array();
|
16 |
+
public $isSuccess = true;
|
17 |
+
public $curlResult = '';
|
18 |
+
|
19 |
+
public $useProxy = false;
|
20 |
+
public $proxyIp = '127.0.0.1';
|
21 |
+
public $proxyPort = 8080;
|
22 |
+
public $proxyType = 'HTTP';
|
23 |
+
public $loginUser = '';
|
24 |
+
public $loginPass = '';
|
25 |
+
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
//fill in the proxy info
|
29 |
+
$helper = Mage::Helper('advancedexport/debug');
|
30 |
+
$this->useProxy = true === (bool)$helper->getDebugUseProxy();
|
31 |
+
$this->verifyPeer = true === (bool)$helper->getDebugVerifyPeer();
|
32 |
+
if($this->useProxy)
|
33 |
+
{
|
34 |
+
$this->proxyIp = $helper->getDebugProxyIp();
|
35 |
+
$this->proxyPort = $helper->getDebugProxyPort();
|
36 |
+
$this->loginUser = $helper->getDebugLoginUser();
|
37 |
+
$this->loginPass = $helper->getDebugLoginPass();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function resetProperties()
|
42 |
+
{
|
43 |
+
$this->sendErrorMessage = array();
|
44 |
+
$this->exceptionMessage = array();
|
45 |
+
$this->isSuccess = true;
|
46 |
+
$this->curlResult = '';
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getHttpCodes()
|
50 |
+
{
|
51 |
+
//[Informational 1xx]
|
52 |
+
$httpCodes[100] = "Continue";
|
53 |
+
$httpCodes[101] = "Switching Protocols";
|
54 |
+
|
55 |
+
//[Successful 2xx]
|
56 |
+
$httpCodes[200] = "OK";
|
57 |
+
$httpCodes[201] = "Created";
|
58 |
+
$httpCodes[202] = "Accepted";
|
59 |
+
$httpCodes[203] = "Non-Authoritative Information";
|
60 |
+
$httpCodes[204] = "No Content";
|
61 |
+
$httpCodes[205] = "Reset Content";
|
62 |
+
$httpCodes[206] = "Partial Content";
|
63 |
+
|
64 |
+
//[Redirection 3xx]
|
65 |
+
$httpCodes[300] = "Multiple Choices";
|
66 |
+
$httpCodes[301] = "Moved Permanently";
|
67 |
+
$httpCodes[302] = "Found";
|
68 |
+
$httpCodes[303] = "See Other";
|
69 |
+
$httpCodes[304] = "Not Modified";
|
70 |
+
$httpCodes[305] = "Use Proxy";
|
71 |
+
$httpCodes[306] = "(Unused)";
|
72 |
+
$httpCodes[307] = "Temporary Redirect";
|
73 |
+
|
74 |
+
//[Client Error 4xx]
|
75 |
+
$httpCodes[400] = "Bad Request";
|
76 |
+
$httpCodes[401] = "Unauthorized";
|
77 |
+
$httpCodes[402] = "Payment Required";
|
78 |
+
$httpCodes[403] = "Forbidden";
|
79 |
+
$httpCodes[404] = "Not Found";
|
80 |
+
$httpCodes[405] = "Method Not Allowed";
|
81 |
+
$httpCodes[406] = "Not Acceptable";
|
82 |
+
$httpCodes[407] = "Proxy Authentication Required";
|
83 |
+
$httpCodes[408] = "Request Timeout";
|
84 |
+
$httpCodes[409] = "Conflict";
|
85 |
+
$httpCodes[410] = "Gone";
|
86 |
+
$httpCodes[411] = "Length Required";
|
87 |
+
$httpCodes[412] = "Precondition Failed";
|
88 |
+
$httpCodes[413] = "Request Entity Too Large";
|
89 |
+
$httpCodes[414] = "Request-URI Too Long";
|
90 |
+
$httpCodes[415] = "Unsupported Media Type";
|
91 |
+
$httpCodes[416] = "Requested Range Not Satisfiable";
|
92 |
+
$httpCodes[417] = "Expectation Failed";
|
93 |
+
|
94 |
+
//[Server Error 5xx]
|
95 |
+
$httpCodes[500] = "Internal Server Error";
|
96 |
+
$httpCodes[501] = "Not Implemented";
|
97 |
+
$httpCodes[502] = "Bad Gateway";
|
98 |
+
$httpCodes[503] = "Service Unavailable";
|
99 |
+
$httpCodes[504] = "Gateway Timeout";
|
100 |
+
$httpCodes[505] = "HTTP Version Not Supported";
|
101 |
+
|
102 |
+
return $httpCodes;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Instantiates curl and POSTS
|
107 |
+
*
|
108 |
+
* @param string $endPointUrl - url to post
|
109 |
+
* @param string $jsonData - data to post
|
110 |
+
* @return boolean
|
111 |
+
*/
|
112 |
+
public function curlSend($endPointUrl, $jsonData)
|
113 |
+
{
|
114 |
+
try {
|
115 |
+
$curl = curl_init();
|
116 |
+
if ($curl) {
|
117 |
+
curl_setopt($curl, CURLOPT_URL, $endPointUrl);
|
118 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
119 |
+
curl_setopt($curl, CURLOPT_POST, true);
|
120 |
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifyPeer);
|
121 |
+
if($this->useProxy)
|
122 |
+
{
|
123 |
+
$loginPassWord = trim($this->loginUser) . ':' . trim($this->loginPass);
|
124 |
+
curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxyPort);
|
125 |
+
curl_setopt($curl, CURLOPT_PROXYTYPE, $this->proxyType);
|
126 |
+
curl_setopt($curl, CURLOPT_PROXY, $this->proxyIp);
|
127 |
+
if (!empty($loginPassWord))
|
128 |
+
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $loginPassWord);
|
129 |
+
}
|
130 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonData);
|
131 |
+
curl_setopt(
|
132 |
+
$curl,
|
133 |
+
CURLOPT_HTTPHEADER,
|
134 |
+
array(
|
135 |
+
'Content-Type: application/json',
|
136 |
+
'Content-Length: ' . strlen($jsonData)
|
137 |
+
)
|
138 |
+
);
|
139 |
+
|
140 |
+
$this->curlResult = curl_exec($curl);
|
141 |
+
} else {
|
142 |
+
//unable to create curl
|
143 |
+
Mage::log(
|
144 |
+
'[WARNING] - Unable to initialize cURL handle',
|
145 |
+
1,
|
146 |
+
'freestyle.log'
|
147 |
+
);
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
} catch (Exception $ex) {
|
151 |
+
$this->exceptionMessage = $ex->getMessage();
|
152 |
+
Mage::log(
|
153 |
+
'[EXCEPTION] - An exception occurred during this operation. '
|
154 |
+
. 'Exception Message: ' . $this->exceptionMessage . ' '
|
155 |
+
. $ex->getFile() . '::' . (string) $ex->getLine(),
|
156 |
+
1,
|
157 |
+
'freestyle.log'
|
158 |
+
);
|
159 |
+
curl_close($curl);
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
|
163 |
+
if (empty($this->curlResult)) {
|
164 |
+
//some kind of error happened
|
165 |
+
$this->sendErrorMessage = curl_error($curl);
|
166 |
+
Mage::log(
|
167 |
+
"[WARNING] - No response was provided connecting to " .
|
168 |
+
$endPointUrl . " " . $this->sendErrorMessage,
|
169 |
+
1,
|
170 |
+
'freestyle.log'
|
171 |
+
);
|
172 |
+
curl_close($curl);
|
173 |
+
return false;
|
174 |
+
} else {
|
175 |
+
$info = curl_getinfo($curl);
|
176 |
+
curl_close($curl);
|
177 |
+
if (empty($info['http_code'])) {
|
178 |
+
$this->sendErrorMessage =
|
179 |
+
"[WARNING] - No HTTP code was returned connecting to "
|
180 |
+
. $endPointUrl;
|
181 |
+
Mage::log($this->sendErrorMessage, 1, 'freestyle.log');
|
182 |
+
return false;
|
183 |
+
} else {
|
184 |
+
$httpCodes = $this->getHttpCodes();
|
185 |
+
$okResponses = array(200, 201, 202, 203, 204, 205, 206);
|
186 |
+
if (!in_array($info['http_code'], $okResponses)) {
|
187 |
+
$this->sendErrorMessage = "[WARNING] - Server responded "
|
188 |
+
. $info['http_code'] . " "
|
189 |
+
. $httpCodes[$info['http_code']] . "connecting to "
|
190 |
+
. $endPointUrl;
|
191 |
+
Mage::log($this->sendErrorMessage, 1, 'freestyle.log');
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
return true;
|
197 |
+
}
|
198 |
+
}
|
app/code/community/Freestyle/Advancedexport/Helper/Data.php
ADDED
@@ -0,0 +1,550 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Helper_Data extends Mage_Core_Helper_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
const ADVANCED_EXPORT_FOLDER = 'freestyleexport';
|
17 |
+
|
18 |
+
public function getIsExtEnabledForApi()
|
19 |
+
{
|
20 |
+
$classDesc = 'freestyle_advancedexport/settings/is_enabled';
|
21 |
+
return Mage::getStoreConfig($classDesc);
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getExportfolder()
|
25 |
+
{
|
26 |
+
return self::ADVANCED_EXPORT_FOLDER;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getChanelId($websiteId = 1)
|
30 |
+
{
|
31 |
+
$classDesc = 'freestyle_advancedexport/settings/chanel_id';
|
32 |
+
return trim(Mage::app()->getWebsite($websiteId)->getConfig($classDesc));
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getChanelName()
|
36 |
+
{
|
37 |
+
$classDesc = 'freestyle_advancedexport/settings/chanel_name';
|
38 |
+
return Mage::getStoreConfig($classDesc);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getMemoryLimit()
|
42 |
+
{
|
43 |
+
$classDesc = 'freestyle_advancedexport/settings/memory_limit';
|
44 |
+
return Mage::getStoreConfig($classDesc);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getApiUserName()
|
48 |
+
{
|
49 |
+
$classDesc = 'freestyle_advancedexport/api/api_username';
|
50 |
+
return Mage::getStoreConfig($classDesc);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getIsFileExist($fileName)
|
54 |
+
{
|
55 |
+
$fileFullPath = Mage::getBaseDir() . DS . $this->getExportfolder()
|
56 |
+
. '/' . $fileName;
|
57 |
+
if (file_exists($fileFullPath)) {
|
58 |
+
return true;
|
59 |
+
}
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getApiUserPassword()
|
64 |
+
{
|
65 |
+
$classDesc = 'freestyle_advancedexport/api/api_password';
|
66 |
+
$value = Mage::getStoreConfig($classDesc);
|
67 |
+
$decrypt = Mage::helper('core')->decrypt($value);
|
68 |
+
return $decrypt;
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getApiAuthenticationUrl()
|
72 |
+
{
|
73 |
+
$classDesc = 'freestyle_advancedexport/api/api_authorization_url';
|
74 |
+
return Mage::getStoreConfig($classDesc);
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getApiNotificationUrl()
|
78 |
+
{
|
79 |
+
$classDesc = 'freestyle_advancedexport/api/api_service_url';
|
80 |
+
return Mage::getStoreConfig($classDesc);
|
81 |
+
}
|
82 |
+
|
83 |
+
//DE-10071
|
84 |
+
public function getOrderCutOffDate()
|
85 |
+
{
|
86 |
+
$classDesc = 'freestyle_advancedexport/settings/cutoff_date';
|
87 |
+
$dateString = Mage::getStoreConfig($classDesc);
|
88 |
+
if (is_null($dateString) || empty($dateString)) {
|
89 |
+
return "1980-01-01 23:59:59";
|
90 |
+
} else {
|
91 |
+
$configDate = trim($dateString) . ":00"; //add millliseconds.
|
92 |
+
//all times in UTC
|
93 |
+
return $configDate;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
public function putFile($entityToExport, $outxml, $batchNumber, $date)
|
98 |
+
{
|
99 |
+
$fileName = $this->getChanelId() . '_' . $entityToExport . '_'
|
100 |
+
. $date . '_' . 'batch-' . $batchNumber . '.xml';
|
101 |
+
|
102 |
+
$uploadFolder = Mage::getBaseDir() . DS . $this->getExportfolder();
|
103 |
+
$fullPath = $uploadFolder . DS . $fileName;
|
104 |
+
|
105 |
+
if (!is_dir($uploadFolder)) {
|
106 |
+
mkdir($uploadFolder, 0777);
|
107 |
+
}
|
108 |
+
$fileResult = file_put_contents($fullPath, $outxml);
|
109 |
+
|
110 |
+
if ($fileResult) {
|
111 |
+
$zip = new ZipArchive();
|
112 |
+
$zip->open($fullPath . '.zip', ZIPARCHIVE::CREATE);
|
113 |
+
$zip->addFile($fullPath, $fullPath);
|
114 |
+
$zip->close();
|
115 |
+
|
116 |
+
//Remove XML FILE AFTER ZIP CREATING
|
117 |
+
//----------------------------------
|
118 |
+
}
|
119 |
+
if ($fileResult) {
|
120 |
+
return $fileName;
|
121 |
+
} else {
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
public function isEnterprise()
|
127 |
+
{
|
128 |
+
$enterpriseFolder =
|
129 |
+
Mage::getBaseDir('code') . DS . 'core' . DS . 'Enterprise';
|
130 |
+
return is_dir($enterpriseFolder) ? "Enterprise" : "Community";
|
131 |
+
}
|
132 |
+
|
133 |
+
public function getXmlVersionHeader()
|
134 |
+
{
|
135 |
+
return '<?xml version="1.0"?>';
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getMainXmlTagWithParams()
|
139 |
+
{
|
140 |
+
$xmlString = 'data xmlns:xsi='
|
141 |
+
. '"http://www.w3.org/2001/XMLSchema-instance"'
|
142 |
+
. ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"';
|
143 |
+
return $xmlString;
|
144 |
+
}
|
145 |
+
|
146 |
+
public function getMainXmlTagEnd()
|
147 |
+
{
|
148 |
+
return 'data';
|
149 |
+
}
|
150 |
+
|
151 |
+
public function addToOutCollector($entityToExport, $outXml, $fileFullPath)
|
152 |
+
{
|
153 |
+
unset($entityToExport);
|
154 |
+
if (!is_file($fileFullPath)) {
|
155 |
+
//$this->openXmlHeaderTag($entityToExport, $fileFullPath);
|
156 |
+
$this->openXmlHeaderTag($fileFullPath);
|
157 |
+
$fileResult =
|
158 |
+
file_put_contents($fileFullPath, $outXml, FILE_APPEND);
|
159 |
+
} else {
|
160 |
+
$fileResult =
|
161 |
+
file_put_contents($fileFullPath, $outXml, FILE_APPEND);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
//public function openXmlHeaderTag($entityToExport, $fileFullPath) {
|
166 |
+
public function openXmlHeaderTag($fileFullPath)
|
167 |
+
{
|
168 |
+
$entityToExport = $this->getMainXmlTagWithParams();
|
169 |
+
file_put_contents($fileFullPath, $this->getXmlVersionHeader());
|
170 |
+
file_put_contents($fileFullPath, "<$entityToExport>", FILE_APPEND);
|
171 |
+
}
|
172 |
+
|
173 |
+
//public function closeXmlHeaderTag($entityToExport, $fileFullPath) {
|
174 |
+
public function closeXmlHeaderTag($fileFullPath)
|
175 |
+
{
|
176 |
+
$entityToExport = $this->getMainXmlTagEnd();
|
177 |
+
file_put_contents($fileFullPath, "</$entityToExport>", FILE_APPEND);
|
178 |
+
}
|
179 |
+
|
180 |
+
public function getParamsPriority($dateS, $dateE, $ids)
|
181 |
+
{
|
182 |
+
$tempDateEnd = $dateE . ' ' . '23:59:59';
|
183 |
+
//$tempDateEnd = $dateE;
|
184 |
+
if (strlen(trim($ids))) {
|
185 |
+
return array('param' => 'ids', 'values' => $ids);
|
186 |
+
}
|
187 |
+
if ($dateS || $dateE) {
|
188 |
+
return array(
|
189 |
+
'param' => 'date',
|
190 |
+
'startDate' => $dateS,
|
191 |
+
'endDate' => $tempDateEnd
|
192 |
+
);
|
193 |
+
}
|
194 |
+
|
195 |
+
return array('param' => 'all');
|
196 |
+
}
|
197 |
+
|
198 |
+
public function getEntityModel($entityToExport)
|
199 |
+
{
|
200 |
+
switch ($entityToExport) {
|
201 |
+
|
202 |
+
case 'customer':
|
203 |
+
$model = Mage::getModel('advancedexport/exportmodels_customer');
|
204 |
+
break;
|
205 |
+
case 'category':
|
206 |
+
$model = Mage::getModel('advancedexport/exportmodels_category');
|
207 |
+
break;
|
208 |
+
case 'order':
|
209 |
+
$model = Mage::getModel('advancedexport/exportmodels_order');
|
210 |
+
break;
|
211 |
+
case 'product':
|
212 |
+
$model = Mage::getModel('advancedexport/exportmodels_product');
|
213 |
+
break;
|
214 |
+
case 'customergroup':
|
215 |
+
$classDesc = 'advancedexport/exportmodels_customergroup';
|
216 |
+
$model = Mage::getModel($classDesc);
|
217 |
+
break;
|
218 |
+
|
219 |
+
default:
|
220 |
+
$model = false;
|
221 |
+
break;
|
222 |
+
}
|
223 |
+
|
224 |
+
return $model;
|
225 |
+
}
|
226 |
+
|
227 |
+
public function processPassiveMode($action)
|
228 |
+
{
|
229 |
+
$errors = array();
|
230 |
+
$status = 'success';
|
231 |
+
$ids = 0;
|
232 |
+
switch ($action) {
|
233 |
+
|
234 |
+
case 'set_to_passive' : {
|
235 |
+
|
236 |
+
$passiveEnabled =
|
237 |
+
Mage::getModel('advancedexport/passivemode')
|
238 |
+
->getCollection()
|
239 |
+
->addFieldToFilter(
|
240 |
+
'passivemod_enabled', array('eq' => '1')
|
241 |
+
);
|
242 |
+
if ($passiveEnabled->count()) {
|
243 |
+
$outStrErr = '';
|
244 |
+
foreach ($passiveEnabled as $one) {
|
245 |
+
$outStrErr .= $one->getId() . '; ';
|
246 |
+
}
|
247 |
+
$errors[] = 'Not all of the previously enabled passive'
|
248 |
+
. ' modes have been disabled. Identifiers: '
|
249 |
+
. $outStrErr;
|
250 |
+
Mage::log(
|
251 |
+
'[WARNING] - Not all of the previously '
|
252 |
+
. 'enabled passive modes have been disabled. '
|
253 |
+
. 'Identifiers: ' . $outStrErr,
|
254 |
+
1,
|
255 |
+
'freestyle.log'
|
256 |
+
);
|
257 |
+
break;
|
258 |
+
}
|
259 |
+
|
260 |
+
$dateTimeStart = new DateTime();
|
261 |
+
$classDesc ='advancedexport/passivemode';
|
262 |
+
$passiveModel = Mage::getModel($classDesc);
|
263 |
+
$data = array();
|
264 |
+
$data['passivemod_enabled'] = 1;
|
265 |
+
$data['passivemod_start'] =
|
266 |
+
$dateTimeStart->format('Y-m-d H:i:s');
|
267 |
+
$data['passivemod_end'] = null;
|
268 |
+
$data['created_files'] = serialize(array());
|
269 |
+
$data['is_notification_sent'] = 0;
|
270 |
+
|
271 |
+
$passiveModel->setData($data);
|
272 |
+
$passiveModel->save();
|
273 |
+
|
274 |
+
break;
|
275 |
+
}
|
276 |
+
|
277 |
+
case 'disable_passive' : {
|
278 |
+
|
279 |
+
$passiveEnabled =
|
280 |
+
Mage::getModel('advancedexport/passivemode')
|
281 |
+
->getCollection()
|
282 |
+
->addFieldToFilter(
|
283 |
+
'passivemod_enabled', array('eq' => '1')
|
284 |
+
);
|
285 |
+
$dateTimeEnd = new DateTime();
|
286 |
+
|
287 |
+
if ($passiveEnabled->count()) {
|
288 |
+
foreach ($passiveEnabled as $one) {
|
289 |
+
$current =
|
290 |
+
Mage::getModel('advancedexport/passivemode')
|
291 |
+
->load($one->getId());
|
292 |
+
$data = $current->getData();
|
293 |
+
|
294 |
+
$data['passivemod_enabled'] = 0;
|
295 |
+
$data['passivemod_end'] =
|
296 |
+
$dateTimeEnd->format('Y-m-d H:i:s');
|
297 |
+
$ids = $data['id'];
|
298 |
+
$current->setData($data);
|
299 |
+
$current->save();
|
300 |
+
}
|
301 |
+
}
|
302 |
+
break;
|
303 |
+
}
|
304 |
+
default: {
|
305 |
+
break;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
$result['errors'] = $errors;
|
310 |
+
$result['status'] = $status;
|
311 |
+
$result['id'] = $ids;
|
312 |
+
|
313 |
+
return $result;
|
314 |
+
}
|
315 |
+
|
316 |
+
public function checkFoldersPremissions()
|
317 |
+
{
|
318 |
+
$exportFolder = Mage::Helper('advancedexport')->getExportfolder();
|
319 |
+
|
320 |
+
try {
|
321 |
+
if (!is_dir(Mage::getBaseDir() . DS . $exportFolder)) {
|
322 |
+
$result = mkdir(Mage::getBaseDir() . DS . $exportFolder, 0777);
|
323 |
+
if (!$result) {
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
$dirPath = Mage::getBaseDir() . DS .
|
329 |
+
$exportFolder . DS . 'tempFiles';
|
330 |
+
if (!is_dir($dirPath)) {
|
331 |
+
$result = mkdir($dirPath, 0777);
|
332 |
+
if (!$result) {
|
333 |
+
return false;
|
334 |
+
}
|
335 |
+
}
|
336 |
+
} catch (Exception $e) {
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
|
340 |
+
return true;
|
341 |
+
}
|
342 |
+
|
343 |
+
public function getCurrentTime()
|
344 |
+
{
|
345 |
+
|
346 |
+
//return $date = date("m-d-Y_H-i-s") . '_' . $this->getMilliseconds();
|
347 |
+
return date("m-d-Y_H-i-s") . '_' . $this->getMilliseconds();
|
348 |
+
}
|
349 |
+
|
350 |
+
public function getTimeByStamp($datetime)
|
351 |
+
{
|
352 |
+
$formattedDateTime = date("m-d-Y_H-i-s", strtotime($datetime));
|
353 |
+
|
354 |
+
//return $date = $formattedDateTime . '_' . $this->getMilliseconds();
|
355 |
+
return $formattedDateTime . '_' . $this->getMilliseconds();
|
356 |
+
}
|
357 |
+
|
358 |
+
public function getMilliseconds()
|
359 |
+
{
|
360 |
+
try {
|
361 |
+
$tme = explode(' ', microtime(false));
|
362 |
+
$millisecondsTm = explode('.', $tme[0]);
|
363 |
+
$milliseconds = substr($millisecondsTm[1], 0, 3);
|
364 |
+
} catch (Exception $e) {
|
365 |
+
Mage::log($e->getMessage(), 1, 'freestyle.log');
|
366 |
+
$milliseconds = 100;
|
367 |
+
}
|
368 |
+
|
369 |
+
return $milliseconds;
|
370 |
+
}
|
371 |
+
|
372 |
+
//custom functions
|
373 |
+
public function getExtensionVersion()
|
374 |
+
{
|
375 |
+
return (string) Mage::getConfig()
|
376 |
+
->loadModulesConfiguration('config.xml')
|
377 |
+
->getNode()->modules->Freestyle_Advancedexport->version;
|
378 |
+
}
|
379 |
+
|
380 |
+
public function getBuildDate()
|
381 |
+
{
|
382 |
+
$classDesc = 'freestyle_advancedexport/settings/build_date';
|
383 |
+
return Mage::getStoreConfig($classDesc);
|
384 |
+
}
|
385 |
+
|
386 |
+
public function getEnablePassiveGui()
|
387 |
+
{
|
388 |
+
$classDesc = 'freestyle_advancedexport/settings/enable_passive_gui';
|
389 |
+
return Mage::getStoreConfig($classDesc);
|
390 |
+
}
|
391 |
+
|
392 |
+
//DE-10150 - refactor.. copied from observer.php
|
393 |
+
public function generateAndSaveExportFile(
|
394 |
+
$entityToExport,
|
395 |
+
$entityId,
|
396 |
+
$action,
|
397 |
+
$order = null,
|
398 |
+
$scopeValue = 1
|
399 |
+
)
|
400 |
+
{
|
401 |
+
if (!$this->getIsExtEnabledForApi()) {
|
402 |
+
return false;
|
403 |
+
}
|
404 |
+
|
405 |
+
$this->checkFoldersPremissions();
|
406 |
+
|
407 |
+
$model = $this->getEntityModel($entityToExport);
|
408 |
+
|
409 |
+
if ($order === null) {
|
410 |
+
if ($entityToExport == 'product') {
|
411 |
+
$entityData = $model->info($entityId, $scopeValue);
|
412 |
+
} else {
|
413 |
+
$entityData = $model->info($entityId);
|
414 |
+
}
|
415 |
+
} else {
|
416 |
+
$entityData = $order;
|
417 |
+
}
|
418 |
+
|
419 |
+
if (!$entityData) {
|
420 |
+
Mage::log(
|
421 |
+
"[WARNING] - Cannot [EXPORT] $entityToExport = $entityId",
|
422 |
+
1,
|
423 |
+
'freestyle.log'
|
424 |
+
);
|
425 |
+
return false;
|
426 |
+
}
|
427 |
+
|
428 |
+
$data = array($entityToExport => $entityData);
|
429 |
+
$outXml = Mage::getModel('advancedexport/exportmodels_abstract')
|
430 |
+
->arrayToXml($entityToExport, $data);
|
431 |
+
|
432 |
+
//$dateTimeInit = $helper->getCurrentTime();
|
433 |
+
$dateTimeInit = $this->getCurrentTime();
|
434 |
+
$files =
|
435 |
+
$this->getFilesNames($entityToExport, $dateTimeInit, $scopeValue);
|
436 |
+
|
437 |
+
$files['entity'] = $entityToExport;
|
438 |
+
$files['action'] = $action;
|
439 |
+
|
440 |
+
$this->addToOutCollector($entityToExport, $outXml, $files['filePath']);
|
441 |
+
//$this->closeXmlHeaderTag($entityToExport, $files['filePath']);
|
442 |
+
$this->closeXmlHeaderTag($files['filePath']);
|
443 |
+
|
444 |
+
$zipTest = !Mage::getModel('advancedexport/passivemode')
|
445 |
+
->getIsPassiveEnabled()
|
446 |
+
|| $entityToExport == 'order';
|
447 |
+
if ($zipTest) {
|
448 |
+
$zip = new ZipArchive();
|
449 |
+
try {
|
450 |
+
$zip->open($files['zipFilePath'] . '.zip', ZIPARCHIVE::CREATE);
|
451 |
+
$zip->addFile($files['filePath'], $files['fileName']);
|
452 |
+
$zip->close();
|
453 |
+
} catch (Exception $e) {
|
454 |
+
$this->stepErrors[] = 'Can not create Zip Archive';
|
455 |
+
Mage::log(
|
456 |
+
'[EXCEPTION] - Can not [CREATE] Zip Archive ' .
|
457 |
+
$e->getMessage() . ' ' . $e->getFile() . '::' .
|
458 |
+
$e->getLine(),
|
459 |
+
1,
|
460 |
+
'freestyle.log'
|
461 |
+
);
|
462 |
+
}
|
463 |
+
|
464 |
+
return $files['zipFileName'] . '.zip';
|
465 |
+
} else {
|
466 |
+
Mage::getModel('advancedexport/passivemode')
|
467 |
+
->addFileDataToCollector($files);
|
468 |
+
}
|
469 |
+
}
|
470 |
+
|
471 |
+
public function getFilesNames(
|
472 |
+
$entityToExport,
|
473 |
+
$dateTimeInit,
|
474 |
+
$websiteId = 1
|
475 |
+
)
|
476 |
+
{
|
477 |
+
$currentBatchNumber = '1';
|
478 |
+
|
479 |
+
$tempfile = '[' . $this->getChanelName() . ']_[' .
|
480 |
+
$this->getChanelId($websiteId) . ']_[' . $entityToExport . ']_[' .
|
481 |
+
$dateTimeInit . ']_[batch-' . $currentBatchNumber . '].xml';
|
482 |
+
$fileFullPath = Mage::getBaseDir() . DS .
|
483 |
+
Mage::Helper('advancedexport')->getExportfolder() . DS . $tempfile;
|
484 |
+
|
485 |
+
$zipFile = '[' . $this->getChanelName() . ']_[' .
|
486 |
+
$this->getChanelId($websiteId) . ']_[' . $entityToExport . ']_[' .
|
487 |
+
$dateTimeInit . ']';
|
488 |
+
$zipFileFullPath = Mage::getBaseDir() . DS .
|
489 |
+
Mage::Helper('advancedexport')->getExportfolder() . DS . $zipFile;
|
490 |
+
|
491 |
+
return array(
|
492 |
+
'fileName' => $tempfile,
|
493 |
+
'filePath' => $fileFullPath,
|
494 |
+
'zipFileName' => $zipFile,
|
495 |
+
'zipFilePath' => $zipFileFullPath
|
496 |
+
);
|
497 |
+
}
|
498 |
+
|
499 |
+
public function readLogFile($bypass = false)
|
500 |
+
{
|
501 |
+
if ((int) $this->getEnablePassiveGui() == 1 && $bypass == false) {
|
502 |
+
return " "; //no need to read the log file if this is disabled
|
503 |
+
}
|
504 |
+
|
505 |
+
$baseDir = Mage::getBaseDir();
|
506 |
+
$varDir = $baseDir . DS . 'var' . DS . 'log';
|
507 |
+
//$logPath = $varDir . DS . 'freestyle.log';
|
508 |
+
$logdata = '';
|
509 |
+
try {
|
510 |
+
$file = new Varien_Io_File();
|
511 |
+
$file->open(array('path' => $varDir));
|
512 |
+
$file->streamOpen('freestyle.log', 'r');
|
513 |
+
|
514 |
+
while (false !== ($data = $file->streamRead())) {
|
515 |
+
$logdata = $logdata . $data;
|
516 |
+
}
|
517 |
+
} catch (Exception $e) {
|
518 |
+
Mage::log(
|
519 |
+
"[EXCEPTION] - Failed to read log data: " . $e->getMessage()
|
520 |
+
. $e->getFile() . '::'
|
521 |
+
. $e->getLine(), 1, 'exception.log'
|
522 |
+
);
|
523 |
+
}
|
524 |
+
|
525 |
+
if (empty($logdata)) {
|
526 |
+
$logdata = "No data to display. "
|
527 |
+
. "Please enable logging if you haven't already done so.";
|
528 |
+
}
|
529 |
+
|
530 |
+
return $logdata;
|
531 |
+
}
|
532 |
+
|
533 |
+
public function getAjaxSendUrl()
|
534 |
+
{
|
535 |
+
return Mage::helper('adminhtml')
|
536 |
+
->getUrl('adminhtml/advancedexport/sendjustone/');
|
537 |
+
}
|
538 |
+
|
539 |
+
public function getProductSendImages()
|
540 |
+
{
|
541 |
+
$classDesc = 'freestyle_advancedexport/settings/product_send_images';
|
542 |
+
return Mage::getStoreConfig($classDesc);
|
543 |
+
}
|
544 |
+
|
545 |
+
public function apiAuthenticate($username, $password)
|
546 |
+
{
|
547 |
+
$apiModel = Mage::getModel('api/user');
|
548 |
+
return $apiModel->authenticate($username, $password);
|
549 |
+
}
|
550 |
+
}
|
app/code/community/Freestyle/Advancedexport/Helper/Debug.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
class Freestyle_Advancedexport_Helper_Debug extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
public function getDebugUseProxy()
|
16 |
+
{
|
17 |
+
$classDesc = 'freestyle_advancedexport/debug/curl_use_proxy';
|
18 |
+
return Mage::getStoreConfig($classDesc);
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getDebugLoginUser()
|
22 |
+
{
|
23 |
+
$classDesc = 'freestyle_advancedexport/debug/curl_proxy_login';
|
24 |
+
return Mage::getStoreConfig($classDesc);
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getDebugLoginPass()
|
28 |
+
{
|
29 |
+
$classDesc = 'freestyle_advancedexport/debug/curl_proxy_pass';
|
30 |
+
$value = Mage::getStoreConfig($classDesc);
|
31 |
+
$decrypt = Mage::helper('core')->decrypt($value);
|
32 |
+
return $decrypt;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getDebugProxyIp()
|
36 |
+
{
|
37 |
+
$classDesc ='freestyle_advancedexport/debug/curl_proxy_ip';
|
38 |
+
return Mage::getStoreConfig($classDesc);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getDebugProxyPort()
|
42 |
+
{
|
43 |
+
$classDesc = 'freestyle_advancedexport/debug/curl_proxy_ip';
|
44 |
+
return Mage::getStoreConfig($classDesc);
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getDebugVerifypeer()
|
48 |
+
{
|
49 |
+
$classDesc = 'freestyle_advancedexport/debug/curl_verify_peer';
|
50 |
+
return Mage::getStoreConfig($classDesc);
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Freestyle/Advancedexport/Helper/NotificationSender.php
ADDED
@@ -0,0 +1,538 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Helper_NotificationSender
|
14 |
+
extends Mage_Core_Helper_Abstract
|
15 |
+
{
|
16 |
+
|
17 |
+
public $isApiCall;
|
18 |
+
public $isSendButton;
|
19 |
+
public $sendErrorMessage;
|
20 |
+
|
21 |
+
public function setIsApiCall($value)
|
22 |
+
{
|
23 |
+
$this->isApiCall = $value;
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function setIsSendButton($value)
|
28 |
+
{
|
29 |
+
$this->isSendButton = $value;
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getIsApiCall()
|
34 |
+
{
|
35 |
+
return $this->isApiCall;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getIsSendButton()
|
39 |
+
{
|
40 |
+
return $this->isSendButton;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getNotificationType()
|
44 |
+
{
|
45 |
+
if ($this->getIsApiCall()) {
|
46 |
+
return 1;
|
47 |
+
}
|
48 |
+
|
49 |
+
if ($this->getIsSendButton()) {
|
50 |
+
return 2;
|
51 |
+
}
|
52 |
+
|
53 |
+
return 0;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getChanelId()
|
57 |
+
{
|
58 |
+
return Mage::Helper('advancedexport')->getChanelId();
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getEntityType($entity)
|
62 |
+
{
|
63 |
+
$types = array(
|
64 |
+
'order' => 0,
|
65 |
+
'customer' => 1,
|
66 |
+
'product' => 2,
|
67 |
+
'category' => 3,
|
68 |
+
'customergroup' => 4
|
69 |
+
);
|
70 |
+
|
71 |
+
if (isset($types[$entity])) {
|
72 |
+
return $types[$entity];
|
73 |
+
}
|
74 |
+
|
75 |
+
return 'not_defined';
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getEntityEventType($event)
|
79 |
+
{
|
80 |
+
if ($this->getIsApiCall() || $this->getIsSendButton()) {
|
81 |
+
return -1;
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
$eventsTypes = array(
|
86 |
+
'added' => 1,
|
87 |
+
'updated' => 1,
|
88 |
+
'deleted' => 3,
|
89 |
+
);
|
90 |
+
|
91 |
+
if (isset($eventsTypes[$event])) {
|
92 |
+
return $eventsTypes[$event];
|
93 |
+
}
|
94 |
+
|
95 |
+
return 'not_defined';
|
96 |
+
}
|
97 |
+
|
98 |
+
public function getTokenFromDb()
|
99 |
+
{
|
100 |
+
$tokenModel = Mage::getModel('advancedexport/configuration')
|
101 |
+
->load('token', 'config_code');
|
102 |
+
if ($tokenModel->getId()) {
|
103 |
+
return $tokenModel->getConfigValue();
|
104 |
+
}
|
105 |
+
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
|
109 |
+
public function putTokenToBase($token)
|
110 |
+
{
|
111 |
+
$data = array();
|
112 |
+
$tokenModel = Mage::getModel('advancedexport/configuration')
|
113 |
+
->load('token', 'config_code');
|
114 |
+
if ($tokenModel->getId()) {
|
115 |
+
$tokenModel->setConfigValue($token);
|
116 |
+
$tokenModel->save();
|
117 |
+
} else {
|
118 |
+
$newConfData = Mage::getModel('advancedexport/configuration');
|
119 |
+
$data['config_code'] = 'token';
|
120 |
+
$data['config_value'] = $token;
|
121 |
+
$newConfData->setData($data);
|
122 |
+
$newConfData->save();
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
public function authentification()
|
127 |
+
{
|
128 |
+
$mainHelper = Mage::Helper('advancedexport');
|
129 |
+
$authenticationUrl = $mainHelper->getApiAuthenticationUrl();
|
130 |
+
$authUser = $mainHelper->getApiUserName();
|
131 |
+
$authPwd = $mainHelper->getApiUserPassword();
|
132 |
+
unset($mainHelper);
|
133 |
+
return $this->testconnection($authenticationUrl, $authUser, $authPwd);
|
134 |
+
}
|
135 |
+
|
136 |
+
public function testconnection($authenticationUrl, $authUser, $authPwd)
|
137 |
+
{
|
138 |
+
$json = json_encode(
|
139 |
+
array(
|
140 |
+
"UserName" => $authUser,
|
141 |
+
"Password" => $authPwd
|
142 |
+
)
|
143 |
+
);
|
144 |
+
$curlObj = Mage::helper("advancedexport/curl");
|
145 |
+
if ($curlObj->curlSend($authenticationUrl, $json)) {
|
146 |
+
//we got a good response
|
147 |
+
try {
|
148 |
+
$dataObj = json_decode($curlObj->curlResult);
|
149 |
+
$token = $dataObj->Data;
|
150 |
+
if ($token) {
|
151 |
+
$this->putTokenToBase($token);
|
152 |
+
} else {
|
153 |
+
Mage::log(
|
154 |
+
'[WARNING] - Can not [AUTHENTICATE] with Freestyle: ',
|
155 |
+
1,
|
156 |
+
'freestyle.log'
|
157 |
+
);
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
} catch (Exception $e) {
|
161 |
+
Mage::log(
|
162 |
+
'[EXCEPTION] - Can not [AUTHENTICATE] with Freestyle: '
|
163 |
+
. $e->getMessage() . ' ' . $e->getFile() . '::'
|
164 |
+
. $e->getLine(),
|
165 |
+
1,
|
166 |
+
'freestyle.log'
|
167 |
+
);
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
} else {
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
unset($curlObj);
|
174 |
+
return $token;
|
175 |
+
}
|
176 |
+
|
177 |
+
public function sendNotification(
|
178 |
+
$entityToExport,
|
179 |
+
$entityIdForNotify,
|
180 |
+
$zipFile,
|
181 |
+
$entityEvent = false,
|
182 |
+
$scopeValue = 1
|
183 |
+
)
|
184 |
+
{
|
185 |
+
Mage::log('[INFO] - Send Notification Start', 1, 'freestyle.log');
|
186 |
+
|
187 |
+
$mainHelper = Mage::Helper('advancedexport');
|
188 |
+
|
189 |
+
/* Authentificate process */
|
190 |
+
|
191 |
+
$notificationUrl = $mainHelper->getApiNotificationUrl();
|
192 |
+
|
193 |
+
$token = $this->retreiveToken();
|
194 |
+
|
195 |
+
/* Required Info */
|
196 |
+
|
197 |
+
/* Notification Type: Although there are 2 types,
|
198 |
+
* only 0 is supported as the value (0 = EntityChanged),
|
199 |
+
* value 1 = API Request */
|
200 |
+
$notificationType = $this->getNotificationType();
|
201 |
+
$channelId = $mainHelper->getChanelId($scopeValue);
|
202 |
+
$entityType = $this->getEntityType($entityToExport);
|
203 |
+
$entityEventType = $this->getEntityEventType($entityEvent);
|
204 |
+
$entityId = $entityIdForNotify;
|
205 |
+
$dataXmlFileUrl = $zipFile;
|
206 |
+
|
207 |
+
/* Only When Passive mod disabled.
|
208 |
+
* For enabled Passive Mode will be used other solution */
|
209 |
+
$numberOfEntities = 1;
|
210 |
+
/* -------------------------------------------------------------------*/
|
211 |
+
|
212 |
+
/* Create Data Array for sending */
|
213 |
+
|
214 |
+
$params = array();
|
215 |
+
|
216 |
+
$params["Token"] = $token;
|
217 |
+
$params["NotificationType"] = $notificationType;
|
218 |
+
$params["channelId"] = $channelId;
|
219 |
+
$params["entityType"] = $entityType;
|
220 |
+
$params["entityEventType"] = $entityEventType;
|
221 |
+
$params["entityId"] = $entityId;
|
222 |
+
$fileLink = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)
|
223 |
+
. Mage::Helper('advancedexport')->getExportfolder() . DS
|
224 |
+
. $dataXmlFileUrl;
|
225 |
+
$params["dataXmlFileUrl"] = (string) $fileLink;
|
226 |
+
$params["numberOfEntities"] = $numberOfEntities;
|
227 |
+
Mage::log(
|
228 |
+
'[INFO] - Notify Specs: Event=[' . $entityEvent
|
229 |
+
. "]; Entity Type=["
|
230 |
+
. $entityToExport . "]; Entity ID=[" . $entityId . "]",
|
231 |
+
1,
|
232 |
+
'freestyle.log'
|
233 |
+
);
|
234 |
+
Mage::log(
|
235 |
+
'[INFO] - Notify Parameters for Freestyle: '
|
236 |
+
. serialize($params),
|
237 |
+
1,
|
238 |
+
'freestyle.log'
|
239 |
+
);
|
240 |
+
|
241 |
+
/* Send Notification (Curl) */
|
242 |
+
$attemptCount = 0;
|
243 |
+
$isErrorInStatus = false;
|
244 |
+
|
245 |
+
do {
|
246 |
+
$attemptCount++;
|
247 |
+
$jsonDataString = json_encode($params);
|
248 |
+
$curlObj = Mage::helper("advancedexport/curl");
|
249 |
+
if ($curlObj->curlSend($notificationUrl, $jsonDataString)) {
|
250 |
+
//we got something good?
|
251 |
+
$decodeResult = json_decode($curlObj->curlResult);
|
252 |
+
$status = $decodeResult->Data;
|
253 |
+
Mage::log(
|
254 |
+
'Try To Notify: '
|
255 |
+
. $curlObj->curlResult,
|
256 |
+
1,
|
257 |
+
'freestyle.log'
|
258 |
+
);
|
259 |
+
$isErrorInStatus = strpos($status, 'Error');
|
260 |
+
|
261 |
+
if ($isErrorInStatus !== false) {
|
262 |
+
Mage::log(
|
263 |
+
'[ALERT] - Error in response: ' . $status
|
264 |
+
. ', token is - ' . $params["Token"]
|
265 |
+
. ' , try again.... ' . 'Attempt Number is: '
|
266 |
+
. $attemptCount,
|
267 |
+
1,
|
268 |
+
'freestyle.log'
|
269 |
+
);
|
270 |
+
$token = $this->authentification();
|
271 |
+
if ($token != false) {
|
272 |
+
$params["Token"] = $token;
|
273 |
+
} else {
|
274 |
+
$attemptCount++;
|
275 |
+
}
|
276 |
+
} else {
|
277 |
+
Mage::log(
|
278 |
+
'[INFO] - Notification have been sent',
|
279 |
+
1,
|
280 |
+
'freestyle.log'
|
281 |
+
);
|
282 |
+
}
|
283 |
+
}
|
284 |
+
} while (($attemptCount < 3) && ($isErrorInStatus !== false));
|
285 |
+
|
286 |
+
Mage::log('[INFO] - Send Notification End', 1, 'freestyle.log');
|
287 |
+
|
288 |
+
if ($isErrorInStatus !== false) {
|
289 |
+
return false;
|
290 |
+
}
|
291 |
+
|
292 |
+
//write it to the history
|
293 |
+
$this->writeHistory($dataXmlFileUrl, $entityToExport);
|
294 |
+
return true;
|
295 |
+
}
|
296 |
+
|
297 |
+
protected function writeHistory($dataXmlFileUrl, $entityToExport)
|
298 |
+
{
|
299 |
+
$dateTimeStart = new DateTime();
|
300 |
+
$historyModel = Mage::getModel('advancedexport/history');
|
301 |
+
$historyData['export_date'] = $dateTimeStart->format('Y-m-d H:i:s');
|
302 |
+
$historyData['export_date_time_start'] =
|
303 |
+
$dateTimeStart->format('Y-m-d H:i:s');
|
304 |
+
$historyData['export_date_time_end'] =
|
305 |
+
$dateTimeStart->format('Y-m-d H:i:s');
|
306 |
+
$writeFile[] = $dataXmlFileUrl;
|
307 |
+
$historyData['created_files'] = serialize($writeFile);
|
308 |
+
$historyData['init_from'] = 'Event Observer';
|
309 |
+
$historyData['export_entity'] = $entityToExport;
|
310 |
+
//$historyData['errors'] = serialize($this->exportErrors);
|
311 |
+
$historyModel->setData($historyData);
|
312 |
+
$historyModel->save();
|
313 |
+
return;
|
314 |
+
}
|
315 |
+
|
316 |
+
public function sendQueue($jsonOutArray, $websiteId = 1)
|
317 |
+
{
|
318 |
+
if (empty($jsonOutArray)) {
|
319 |
+
return false;
|
320 |
+
}
|
321 |
+
|
322 |
+
$mainHelper = Mage::Helper('advancedexport');
|
323 |
+
|
324 |
+
/* Authenticate process */
|
325 |
+
$notificationUrl = Mage::Helper('advancedexport/queue')
|
326 |
+
->getQueueServiceUrl();
|
327 |
+
$channelId = $mainHelper->getChanelId($websiteId);
|
328 |
+
|
329 |
+
$tryAgain = false;
|
330 |
+
do {
|
331 |
+
$token = $this->retreiveToken();
|
332 |
+
$jsonData = array("Token" => $token,
|
333 |
+
"SalesChannelId" => $channelId,
|
334 |
+
"Entities" => $jsonOutArray
|
335 |
+
);
|
336 |
+
|
337 |
+
try {
|
338 |
+
$jsonDigest = json_encode($jsonData);
|
339 |
+
} catch (Exception $ex) {
|
340 |
+
Mage::log(
|
341 |
+
'[EXCEPTION] - Notify Parameters for Freestyle: '
|
342 |
+
. serialize($jsonData), 1, 'freestyle.log'
|
343 |
+
);
|
344 |
+
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
345 |
+
Mage::log(
|
346 |
+
'[EXCEPTION] - JSON ERROR = ' . json_last_error(),
|
347 |
+
1,
|
348 |
+
'freestyle.log'
|
349 |
+
);
|
350 |
+
}
|
351 |
+
Mage::log(
|
352 |
+
$ex->getMessage() . ' ' . $ex->getFile() . '::'
|
353 |
+
. $ex->getLine(), 1, 'freestyle.log'
|
354 |
+
);
|
355 |
+
$tryAgain = false;
|
356 |
+
return false; //send false to mark record(s) as error
|
357 |
+
}
|
358 |
+
|
359 |
+
try {
|
360 |
+
$tryAgain = false;
|
361 |
+
$curlObj = Mage::helper("advancedexport/curl");
|
362 |
+
if ($curlObj->curlSend($notificationUrl, $jsonDigest)) {
|
363 |
+
//we got something good?
|
364 |
+
Mage::log(
|
365 |
+
'[INFO] - Try To Notify: '
|
366 |
+
. $curlObj->curlResult,
|
367 |
+
1,
|
368 |
+
'freestyle.log'
|
369 |
+
);
|
370 |
+
$tryAgain = $this->parseResult($curlObj, $token);
|
371 |
+
unset($curlObj);
|
372 |
+
unset($jsonData);
|
373 |
+
unset($jsonDigest);
|
374 |
+
} else {
|
375 |
+
//we got something bad
|
376 |
+
$tryAgain = false;
|
377 |
+
return false;
|
378 |
+
}//$this->curlSend($notificationUrl, $jsonDigest)
|
379 |
+
} catch (Exception $e) {
|
380 |
+
$exceptionMessage =
|
381 |
+
'Can not [SEND] Notification to Freestyle: '
|
382 |
+
. $e->getMessage();
|
383 |
+
Mage::log(
|
384 |
+
'[EXCEPTION] - ' . $exceptionMessage . ' ' . $ex->getFile()
|
385 |
+
. '::' . $ex->getLine(),
|
386 |
+
1,
|
387 |
+
'freestyle.log'
|
388 |
+
);
|
389 |
+
$tryAgain = false;
|
390 |
+
//$curlObj->sendErrorMessage = $status;
|
391 |
+
$this->sendErrorMessage = $exceptionMessage;
|
392 |
+
return false;
|
393 |
+
}
|
394 |
+
} while ($tryAgain);
|
395 |
+
unset($curlObj);
|
396 |
+
return true;
|
397 |
+
}
|
398 |
+
|
399 |
+
public function sendMixQueue($jsonOutArray)
|
400 |
+
{
|
401 |
+
if (empty($jsonOutArray)) {
|
402 |
+
return false;
|
403 |
+
}
|
404 |
+
|
405 |
+
//$mainHelper = Mage::Helper('advancedexport');
|
406 |
+
|
407 |
+
/* Authentificate process */
|
408 |
+
$notificationUrl = Mage::Helper('advancedexport/queue')
|
409 |
+
->getQueueServiceUrl();
|
410 |
+
$notificationUrl = trim($notificationUrl) . "MultiStore";
|
411 |
+
|
412 |
+
$tryAgain = false;
|
413 |
+
do {
|
414 |
+
$token = $this->retreiveToken();
|
415 |
+
$jsonData = array("Token" => $token,
|
416 |
+
"Entities" => $jsonOutArray
|
417 |
+
);
|
418 |
+
|
419 |
+
try {
|
420 |
+
$jsonDigest = json_encode($jsonData);
|
421 |
+
} catch (Exception $ex) {
|
422 |
+
Mage::log(
|
423 |
+
'[EXCEPTION] - Notify Parameters for Freestyle: '
|
424 |
+
. serialize($jsonData),
|
425 |
+
1,
|
426 |
+
'freestyle.log'
|
427 |
+
);
|
428 |
+
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
429 |
+
Mage::log(
|
430 |
+
'[EXCEPTION] - JSON ERROR = ' . json_last_error(),
|
431 |
+
1,
|
432 |
+
'freestyle.log'
|
433 |
+
);
|
434 |
+
}
|
435 |
+
Mage::log(
|
436 |
+
$ex->getMessage() . ' ' . $ex->getFile()
|
437 |
+
. '::' . $ex->getLine(),
|
438 |
+
1,
|
439 |
+
'freestyle.log'
|
440 |
+
);
|
441 |
+
$tryAgain = false;
|
442 |
+
return false; //send false to mark record(s) as error
|
443 |
+
}
|
444 |
+
|
445 |
+
try {
|
446 |
+
$tryAgain = false;
|
447 |
+
$curlObj = Mage::helper("advancedexport/curl");
|
448 |
+
if ($curlObj->curlSend($notificationUrl, $jsonDigest)) {
|
449 |
+
//we got something good?
|
450 |
+
Mage::log(
|
451 |
+
'[INFO] - Try To Notify: ' . $curlObj->curlResult,
|
452 |
+
1,
|
453 |
+
'freestyle.log'
|
454 |
+
);
|
455 |
+
$tryAgain = $this->parseResult($curlObj, $token);
|
456 |
+
unset($curlObj);
|
457 |
+
unset($jsonData);
|
458 |
+
unset($jsonDigest);
|
459 |
+
} else {
|
460 |
+
//we got something bad
|
461 |
+
$tryAgain = false;
|
462 |
+
return false;
|
463 |
+
}//$this->curlSend($notificationUrl, $jsonDigest)
|
464 |
+
} catch (Exception $e) {
|
465 |
+
$exceptionMessage =
|
466 |
+
'Can not [SEND] Notification to Freestyle: '
|
467 |
+
. $e->getMessage();
|
468 |
+
Mage::log(
|
469 |
+
'[EXCEPTION] - ' . $exceptionMessage . ' ' . $e->getFile()
|
470 |
+
. '::' . $e->getLine(),
|
471 |
+
1,
|
472 |
+
'freestyle.log'
|
473 |
+
);
|
474 |
+
$tryAgain = false;
|
475 |
+
//$curlObj->sendErrorMessage = $status;
|
476 |
+
$this->sendErrorMessage = $exceptionMessage;
|
477 |
+
return false;
|
478 |
+
}
|
479 |
+
} while ($tryAgain);
|
480 |
+
unset($curlObj);
|
481 |
+
return !empty($this->sendErrorMessage) ? false : true;
|
482 |
+
}
|
483 |
+
|
484 |
+
protected function parseResult($curlObj, $token)
|
485 |
+
{
|
486 |
+
$status = json_decode($curlObj->curlResult); //extract the status
|
487 |
+
$isErrorInStatus = strpos($status, 'Error'); //integer if found;
|
488 |
+
// FALSE if not found
|
489 |
+
if ($isErrorInStatus !== false) {
|
490 |
+
Mage::log(
|
491 |
+
'[WARNING] - Error in response: [' . $curlObj->curlResult
|
492 |
+
. '], token is - ' . $token,
|
493 |
+
1,
|
494 |
+
'freestyle.log'
|
495 |
+
);
|
496 |
+
if (strpos($status, 'Invalid token')) {
|
497 |
+
Mage::log(
|
498 |
+
'[INFO] - Attempting to [RE-AUTHENTICATE]',
|
499 |
+
1,
|
500 |
+
'freestyle.log'
|
501 |
+
);
|
502 |
+
$token = $this->authentification();
|
503 |
+
if ($token != false) {
|
504 |
+
Mage::log(
|
505 |
+
'[INFO] - [RE-AUTHENTICATE] Successful. Token is '
|
506 |
+
. $token,
|
507 |
+
1,
|
508 |
+
'freestyle.log'
|
509 |
+
);
|
510 |
+
return true;
|
511 |
+
} else {
|
512 |
+
Mage::log(
|
513 |
+
'[ERROR] - [RE-AUTHENTICATE] failed.',
|
514 |
+
1,
|
515 |
+
'freestyle.log'
|
516 |
+
);
|
517 |
+
return true;
|
518 |
+
}//$token != false
|
519 |
+
} else {
|
520 |
+
//we got some other type of error
|
521 |
+
$this->sendErrorMessage = $status;
|
522 |
+
Mage::log($status, 1, 'freestyle.log');
|
523 |
+
return false;
|
524 |
+
}
|
525 |
+
}//$isErrorInStatus !== false
|
526 |
+
return false;
|
527 |
+
}
|
528 |
+
|
529 |
+
protected function retreiveToken()
|
530 |
+
{
|
531 |
+
if ($this->getTokenFromDb()) {
|
532 |
+
$token = $this->getTokenFromDb();
|
533 |
+
} else {
|
534 |
+
$token = $this->authentification();
|
535 |
+
}
|
536 |
+
return $token;
|
537 |
+
}
|
538 |
+
}
|
app/code/community/Freestyle/Advancedexport/Helper/Queue.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Helper_Queue extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
public function getEnableQueue()
|
14 |
+
{
|
15 |
+
return
|
16 |
+
Mage::getStoreConfig('freestyle_advancedexport/queue/enable_queue');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getIgnoreApi()
|
20 |
+
{
|
21 |
+
return
|
22 |
+
Mage::getStoreConfig('freestyle_advancedexport/queue/ignore_api');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getQueueBatchSize()
|
26 |
+
{
|
27 |
+
$classDesc = 'freestyle_advancedexport/queue/queuebatchsize';
|
28 |
+
|
29 |
+
return Mage::getStoreConfig($classDesc);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getQueueServiceUrl()
|
33 |
+
{
|
34 |
+
$classDesc = 'freestyle_advancedexport/queue/queue_service_url';
|
35 |
+
|
36 |
+
return Mage::getStoreConfig($classDesc);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getSendAsync()
|
40 |
+
{
|
41 |
+
return
|
42 |
+
Mage::getStoreConfig('freestyle_advancedexport/queue/send_async');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getSendOrderDependencies()
|
46 |
+
{
|
47 |
+
$classDesc = 'freestyle_advancedexport/queue/send_order_dependencies';
|
48 |
+
|
49 |
+
return Mage::getStoreConfig($classDesc);
|
50 |
+
}
|
51 |
+
}
|
app/code/community/Freestyle/Advancedexport/Helper/Website.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Helper_Website extends Mage_Core_Helper_Abstract
|
13 |
+
{
|
14 |
+
public function isWebSiteStoreViewSupported($websiteId = 0)
|
15 |
+
{
|
16 |
+
//check if there is a channel id for this website / store view
|
17 |
+
//$helper = Mage::helper('advancedexport');
|
18 |
+
//if the website_id passed is 0 (default scope)..
|
19 |
+
//then we may need to iterate
|
20 |
+
//otherwise, perform the check
|
21 |
+
$helper = Mage::Helper('advancedexport');
|
22 |
+
$defaultChannelId = $helper->getChanelId(0);
|
23 |
+
$thisChannelId = $helper->getChanelId($websiteId);
|
24 |
+
if ($thisChannelId === 'channelId') {
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
|
28 |
+
if ($defaultChannelId != $thisChannelId || $websiteId === null) {
|
29 |
+
return true;
|
30 |
+
}
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getWebsites($hideUnsynced = false)
|
35 |
+
{
|
36 |
+
$syncedWebsites = array();
|
37 |
+
$helper = Mage::Helper('advancedexport');
|
38 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
39 |
+
$currentWebsite['WebsiteId'] = $website->getId();
|
40 |
+
$currentWebsite['WebsiteName'] = $website->getName();
|
41 |
+
$salesChannelId = $helper->getChanelId($website->getId());
|
42 |
+
$salesChannelId = $salesChannelId == 'channelId' ? ''
|
43 |
+
: $salesChannelId;
|
44 |
+
$currentWebsite['SalesChannelId'] = $salesChannelId;
|
45 |
+
if ($hideUnsynced && $salesChannelId == '') {
|
46 |
+
continue;
|
47 |
+
} else {
|
48 |
+
array_push($syncedWebsites, $currentWebsite);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
return $syncedWebsites;
|
52 |
+
}
|
53 |
+
public function getWebsitesUtils($hideUnsynced = false)
|
54 |
+
{
|
55 |
+
$currentWebsite = array();
|
56 |
+
$helper = Mage::Helper('advancedexport');
|
57 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
58 |
+
//$currentWebsite['WebsiteId'] = $website->getId();
|
59 |
+
//$currentWebsite['WebsiteName'] = $website->getName();
|
60 |
+
$salesChannelId = $helper->getChanelId($website->getId());
|
61 |
+
$salesChannelId = $salesChannelId == 'channelId' ? ''
|
62 |
+
: $salesChannelId;
|
63 |
+
if ($hideUnsynced && $salesChannelId == '') {
|
64 |
+
continue;
|
65 |
+
} else {
|
66 |
+
$currentWebsite[] = $salesChannelId;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
return $currentWebsite;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getWebsiteByStoreId($storeId)
|
73 |
+
{
|
74 |
+
return Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
75 |
+
}
|
76 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Api.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Api
|
14 |
+
extends Mage_Api_Model_Resource_Abstract
|
15 |
+
{
|
16 |
+
|
17 |
+
const MAX_BATCH_SIZE = 1000000;
|
18 |
+
const MAX_SOCKET_TIME_OUT = 9999999;
|
19 |
+
const MAX_PROCESS_TIME_LIMIT = 99999999;
|
20 |
+
|
21 |
+
public $exportErrors;
|
22 |
+
|
23 |
+
public function getHelper()
|
24 |
+
{
|
25 |
+
return Mage::Helper('advancedexport');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function startexport($parametrs)
|
29 |
+
{
|
30 |
+
$helper = $this->getHelper();
|
31 |
+
if (!$helper->getIsExtEnabledForApi()) {
|
32 |
+
return 'access denied';
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
Mage::log('[INFO] - API Call Start... ', 1, 'freestyle.log');
|
37 |
+
|
38 |
+
try {
|
39 |
+
$parametrsArray = (array) json_decode($parametrs);
|
40 |
+
|
41 |
+
$filters = (array) $parametrsArray['filters'];
|
42 |
+
$processRequestId = $parametrsArray['requestid'];
|
43 |
+
$entity = $parametrsArray['entity'];
|
44 |
+
$batchSize = $parametrsArray['batch_size'];
|
45 |
+
|
46 |
+
//return $filters;
|
47 |
+
} catch (Exception $e) {
|
48 |
+
Mage::log(
|
49 |
+
'[EXCEPTION] - Wrong Parameters Format; ' . $e->getMessage()
|
50 |
+
. ' ' . $e->getFile() . '::' . $e->getLine(), 1, 'freestyle.log'
|
51 |
+
);
|
52 |
+
$this->_fault('data_invalid', 'Wrong Parameters Format');
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
if (!$processRequestId) {
|
57 |
+
$this->_fault('data_invalid', 'Missed Process Id');
|
58 |
+
} elseif (!$entity) {
|
59 |
+
$this->_fault('data_invalid', 'Missed Entity Type');
|
60 |
+
} elseif (!$batchSize) {
|
61 |
+
$this->_fault('data_invalid', 'Missed Batch Size');
|
62 |
+
}
|
63 |
+
|
64 |
+
if (!isset($filters['ids'])) {
|
65 |
+
$filters['ids'] = '';
|
66 |
+
}
|
67 |
+
if (!isset($filters['datefrom'])) {
|
68 |
+
$filters['datefrom'] = '';
|
69 |
+
}
|
70 |
+
if (!isset($filters['dateto'])) {
|
71 |
+
$filters['dateto'] = '';
|
72 |
+
}
|
73 |
+
|
74 |
+
try {
|
75 |
+
$filterPriority = $helper->getParamsPriority(
|
76 |
+
$filters['datefrom'],
|
77 |
+
$filters['dateto'],
|
78 |
+
$filters['ids']
|
79 |
+
);
|
80 |
+
} catch (Mage_Core_Exception $e) {
|
81 |
+
$this->_fault('data_invalid', $e->getMessage());
|
82 |
+
} catch (Exception $e) {
|
83 |
+
$this->_fault('data_invalid', $e->getMessage());
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!$helper->getEntityModel($entity)) {
|
87 |
+
$this->_fault(
|
88 |
+
'data_invalid',
|
89 |
+
'Unsupported Entity Type: ' . $entity
|
90 |
+
);
|
91 |
+
}
|
92 |
+
|
93 |
+
$callResult = $this->startExportProcess(
|
94 |
+
$processRequestId,
|
95 |
+
$entity,
|
96 |
+
$filterPriority,
|
97 |
+
$batchSize
|
98 |
+
);
|
99 |
+
return $callResult;
|
100 |
+
}
|
101 |
+
|
102 |
+
public function startExportProcess(
|
103 |
+
$processRequestId,
|
104 |
+
$entity,
|
105 |
+
$filters,
|
106 |
+
$batchSize
|
107 |
+
)
|
108 |
+
{
|
109 |
+
$url = Mage::getUrl(
|
110 |
+
'advancedexport/frontprocess/startApiExport',
|
111 |
+
array('_secure' => true)
|
112 |
+
) . '?requestid=' . $processRequestId . '&export_entity=' . $entity .
|
113 |
+
'&batch_size=' . $batchSize . '&date_start=' .
|
114 |
+
$filters['datefrom'] . '&date_end=' . $filters['dateto'] .
|
115 |
+
'&ids_to_export=' . $filters['ids'];
|
116 |
+
|
117 |
+
/* $result = file_get_contents($url); */
|
118 |
+
|
119 |
+
try {
|
120 |
+
$params = array();
|
121 |
+
$params['export_entity'] = $entity;
|
122 |
+
$params['batch_size'] = $batchSize;
|
123 |
+
$params['date_start'] = $filters['datefrom'];
|
124 |
+
$params['date_end'] = $filters['dateto'];
|
125 |
+
$params['ids_to_export'] = $filters['ids'];
|
126 |
+
|
127 |
+
foreach ($params as $key => &$val) {
|
128 |
+
if (is_array($val)) {
|
129 |
+
$val = implode(',', $val);
|
130 |
+
}
|
131 |
+
$postParams[] = $key . '=' . urlencode($val);
|
132 |
+
}
|
133 |
+
$postString = implode('&', $postParams);
|
134 |
+
|
135 |
+
$parts = parse_url($url);
|
136 |
+
|
137 |
+
$errno = false;
|
138 |
+
$errstr = false;
|
139 |
+
|
140 |
+
$fSock = fsockopen(
|
141 |
+
$parts['host'],
|
142 |
+
isset($parts['port']) ? $parts['port'] : 80,
|
143 |
+
$errno,
|
144 |
+
$errstr,
|
145 |
+
30
|
146 |
+
);
|
147 |
+
|
148 |
+
$out = "POST " . $parts['path'] . " HTTP/1.1\r\n";
|
149 |
+
$out.= "Host: " . $parts['host'] . "\r\n";
|
150 |
+
$out.= "Content-Type: application/x-www-form-urlencoded\r\n";
|
151 |
+
$out.= "Content-Length: " . strlen($postString) . "\r\n";
|
152 |
+
$out.= "Connection: Close\r\n\r\n";
|
153 |
+
if (isset($postString)) {
|
154 |
+
$out.= $postString;
|
155 |
+
}
|
156 |
+
|
157 |
+
fwrite($fSock, $out);
|
158 |
+
fclose($fSock);
|
159 |
+
} catch (Exception $e) {
|
160 |
+
$exceptionMessage = '[EXCEPTION] - API Call Error: '
|
161 |
+
. $e->getMessage() . ' ' . $e->getFile() . '::' . $e->getLine();
|
162 |
+
Mage::log($exceptionMessage, 1, 'freestyle.log');
|
163 |
+
return 'error';
|
164 |
+
}
|
165 |
+
|
166 |
+
//return $result;
|
167 |
+
return 'success';
|
168 |
+
}
|
169 |
+
|
170 |
+
public function getentityxml($entityType, $entityId, $storeId = null)
|
171 |
+
{
|
172 |
+
$helper = $this->getHelper();
|
173 |
+
if (!$helper->getIsExtEnabledForApi()) {
|
174 |
+
return 'access denied';
|
175 |
+
}
|
176 |
+
|
177 |
+
if ($entityType === 'product' && $storeId === null) {
|
178 |
+
//store id value is now required for product
|
179 |
+
$this->_fault(
|
180 |
+
'data_invalid',
|
181 |
+
'Store Id is required for Product Entity'
|
182 |
+
);
|
183 |
+
}
|
184 |
+
|
185 |
+
if ($entityId === null) {
|
186 |
+
//entity id value is required
|
187 |
+
$this->_fault(
|
188 |
+
'data_invalid',
|
189 |
+
'Entity Id is required for Product Entity'
|
190 |
+
);
|
191 |
+
}
|
192 |
+
|
193 |
+
$model = $helper->getEntityModel($entityType);
|
194 |
+
if (!$model) {
|
195 |
+
$this->_fault(
|
196 |
+
'data_invalid',
|
197 |
+
'Unsupported Entity Type: ' . $entityType
|
198 |
+
);
|
199 |
+
}
|
200 |
+
|
201 |
+
$entityData = false;
|
202 |
+
$entityXml = '';
|
203 |
+
try {
|
204 |
+
//initialize XML stuffs
|
205 |
+
$xmlVersionHeader = $helper->getXmlVersionHeader();
|
206 |
+
$xmlVersion = $helper->getMainXmlTagWithParams();
|
207 |
+
$xmlEndTag = $helper->getMainXmlTagEnd();
|
208 |
+
if ($entityType === 'product') {
|
209 |
+
$entityData = $model->info($entityId, $storeId);
|
210 |
+
} else {
|
211 |
+
$entityData = $model->info($entityId);
|
212 |
+
}
|
213 |
+
$data = array($entityType => $entityData);
|
214 |
+
$entityXmlBase =
|
215 |
+
Mage::getModel('advancedexport/exportmodels_abstract')
|
216 |
+
->arrayToXml($entityType, $data);
|
217 |
+
$entityXml = $xmlVersionHeader
|
218 |
+
. "<$xmlVersion>"
|
219 |
+
. $entityXmlBase
|
220 |
+
. "</$xmlEndTag>";
|
221 |
+
} catch (Mage_Core_Exception $e) {
|
222 |
+
$this->_fault('data_invalid', $e->getMessage());
|
223 |
+
} catch (Exception $e) {
|
224 |
+
$this->_fault('data_invalid', $e->getMessage());
|
225 |
+
}
|
226 |
+
return $entityXml;
|
227 |
+
}
|
228 |
+
|
229 |
+
public function getallcarriers()
|
230 |
+
{
|
231 |
+
Mage::log('API Call Start... ', 1, 'freestyle.log');
|
232 |
+
$allCarriers = Mage::getSingleton('shipping/config')->getAllCarriers();
|
233 |
+
foreach ($allCarriers as $carrierCode => $carrierModel) {
|
234 |
+
$options = array();
|
235 |
+
if ($carrierMethods = $carrierModel->getAllowedMethods()) {
|
236 |
+
foreach ($carrierMethods as $methodCode => $method) {
|
237 |
+
$code = $carrierCode . '_' . $methodCode;
|
238 |
+
$options[] = array('value' => $code, 'label' => $method);
|
239 |
+
}
|
240 |
+
$carrierString = 'carriers/' . $carrierCode . '/title';
|
241 |
+
$carrierTitle = Mage::getStoreConfig($carrierString);
|
242 |
+
}
|
243 |
+
$methodsAll[] = array(
|
244 |
+
'value' => $options,
|
245 |
+
'label' => $carrierTitle
|
246 |
+
);
|
247 |
+
}
|
248 |
+
return $methodsAll;
|
249 |
+
}
|
250 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Configuration.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Configuration
|
12 |
+
extends Mage_Core_Model_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('advancedexport/configuration');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Cronjob.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Cronjob
|
14 |
+
{
|
15 |
+
|
16 |
+
public function send()
|
17 |
+
{
|
18 |
+
//Mage::dispatchEvent('advancedexport_notify');
|
19 |
+
//$batchSize = 100;
|
20 |
+
$advHelper = Mage::Helper('advancedexport/queue');
|
21 |
+
if ($advHelper->getSendAsync() != '1') {
|
22 |
+
return true;
|
23 |
+
}
|
24 |
+
|
25 |
+
$batchSize = $advHelper->getQueueBatchSize();
|
26 |
+
|
27 |
+
$_websites = Mage::Helper('advancedexport/website')->getWebsites(true);
|
28 |
+
foreach ($_websites as $website) {
|
29 |
+
$batchSizeSent = 0;
|
30 |
+
do {
|
31 |
+
$batchSizeSent = Mage::getModel('advancedexport/queue')
|
32 |
+
->sendWebsiteCollection($batchSize, $website['WebsiteId']);
|
33 |
+
} while ($batchSizeSent == $batchSize);
|
34 |
+
}
|
35 |
+
//store the date so we can compare
|
36 |
+
$this->putCronStatusToDb(
|
37 |
+
Mage::getModel('core/date')->timestamp(time())
|
38 |
+
);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function purge()
|
42 |
+
{
|
43 |
+
Mage::getModel('advancedexport/queue')->purgeQueue();
|
44 |
+
//store the date so we can compare
|
45 |
+
$this->putCronStatusToDb(
|
46 |
+
Mage::getModel('core/date')->timestamp(time())
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
public function putCronStatusToDb($status)
|
51 |
+
{
|
52 |
+
$data = array();
|
53 |
+
$tokenModel = Mage::getModel('advancedexport/configuration')
|
54 |
+
->load('cronstatus', 'config_code');
|
55 |
+
if ($tokenModel->getId()) {
|
56 |
+
$tokenModel->setConfigValue($status);
|
57 |
+
$tokenModel->save();
|
58 |
+
} else {
|
59 |
+
$newConfData = Mage::getModel('advancedexport/configuration');
|
60 |
+
$data['config_code'] = 'cronstatus';
|
61 |
+
$data['config_value'] = $status;
|
62 |
+
$newConfData->setData($data);
|
63 |
+
$newConfData->save();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getCronStatusFromDb()
|
68 |
+
{
|
69 |
+
$tokenModel = Mage::getModel('advancedexport/configuration')
|
70 |
+
->load('cronstatus', 'config_code');
|
71 |
+
if ($tokenModel->getId()) {
|
72 |
+
return $tokenModel->getConfigValue();
|
73 |
+
}
|
74 |
+
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Abstract.php
ADDED
@@ -0,0 +1,754 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Exportmodels_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
const XML_VERSION = '1.0';
|
17 |
+
const ICONV_CHARSET = 'UTF-8';
|
18 |
+
|
19 |
+
public $entity;
|
20 |
+
public $stepErrors;
|
21 |
+
|
22 |
+
public function getHelper()
|
23 |
+
{
|
24 |
+
return Mage::Helper('advancedexport');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function arrayToXml($entityMain, $dataArray, $fieldsToExport = null)
|
28 |
+
{
|
29 |
+
if (!empty($dataArray[$entityMain])) {
|
30 |
+
$studentInfo = array($dataArray);
|
31 |
+
$entity = 'data';
|
32 |
+
|
33 |
+
$xmlInfo = new
|
34 |
+
Freestyle_Advancedexport_Model_Exportmodels_SimpleXMLExtended(
|
35 |
+
"<?xml version=\""
|
36 |
+
. self::XML_VERSION
|
37 |
+
. "\"?><$entity></$entity>"
|
38 |
+
);
|
39 |
+
$this->_arrayToXml($studentInfo, $xmlInfo, $fieldsToExport);
|
40 |
+
//return $xml_info->$entityMain->asXML();
|
41 |
+
$xmlReturnString = $xmlInfo->$entityMain->asXML();
|
42 |
+
//$xmlReturnStringUtf8 = $this->cleanString($xmlReturnString);
|
43 |
+
$xmlReturnStringUtf = $xmlReturnString;
|
44 |
+
return $xmlReturnStringUtf;
|
45 |
+
} else {
|
46 |
+
return '';
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
protected function cleanString($string)
|
51 |
+
{
|
52 |
+
Mage::log(
|
53 |
+
'libiconv ==' . (string) ('"libiconv"' != ICONV_IMPL),
|
54 |
+
1,
|
55 |
+
'freestyle.log'
|
56 |
+
);
|
57 |
+
return '"libiconv"' != ICONV_IMPL ? $string : iconv(
|
58 |
+
mb_detect_encoding($string),
|
59 |
+
self::ICONV_CHARSET . '//TRANSLIT', $string
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
public function encodeToUtf8($string)
|
64 |
+
{
|
65 |
+
return mb_convert_encoding(
|
66 |
+
$string,
|
67 |
+
"UTF-8",
|
68 |
+
mb_detect_encoding(
|
69 |
+
$string,
|
70 |
+
"UTF-8, ISO-8859-1, ISO-8859-15",
|
71 |
+
true
|
72 |
+
)
|
73 |
+
);
|
74 |
+
}
|
75 |
+
|
76 |
+
protected function _arrayToXml($info, &$xmlInfo, $fieldsToExport = null)
|
77 |
+
{
|
78 |
+
foreach ($info as $key => $value) {
|
79 |
+
$dataCheck = false;
|
80 |
+
$dataCheck = is_array($fieldsToExport)
|
81 |
+
&& !empty($fieldsToExport)
|
82 |
+
&& !is_array($value);
|
83 |
+
if ($dataCheck) {
|
84 |
+
if (!in_array($key, $fieldsToExport)) {
|
85 |
+
continue;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
if (is_array($value)) {
|
90 |
+
if (!is_numeric($key)) {
|
91 |
+
if (!empty($key)) {
|
92 |
+
$subnode = $xmlInfo->addChild("$key");
|
93 |
+
$this->_arrayToXml($value, $subnode, $fieldsToExport);
|
94 |
+
} else {
|
95 |
+
$subnode = $xmlInfo->addChild("blank_attribute");
|
96 |
+
$this->_arrayToXml($value, $subnode, $fieldsToExport);
|
97 |
+
}
|
98 |
+
} else {
|
99 |
+
$this->_arrayToXml($value, $xmlInfo, $fieldsToExport);
|
100 |
+
}
|
101 |
+
} else {
|
102 |
+
$keyToAdd = $key;
|
103 |
+
/*
|
104 |
+
if (($this->entity == 'product') || ($this->entity == 'category')) {
|
105 |
+
$valueToAdd = htmlspecialchars($value);
|
106 |
+
$xml_info->addChild($keyToAdd)->addCData($valueToAdd);
|
107 |
+
|
108 |
+
} else {
|
109 |
+
$valueToAdd = htmlspecialchars($value);
|
110 |
+
$xml_info->addChild($keyToAdd,$valueToAdd);
|
111 |
+
}
|
112 |
+
*/
|
113 |
+
|
114 |
+
/* Add CDATA Tag for all entities */
|
115 |
+
//$valueToAdd = htmlspecialchars($value);
|
116 |
+
//$xml_info->addChild($keyToAdd)->addCData($valueToAdd);
|
117 |
+
$xmlInfo->addChild($keyToAdd)->addCData($value);
|
118 |
+
|
119 |
+
unset($keyToAdd);
|
120 |
+
//unset($valueToAdd);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
protected function getStoresArray($websiteId = 1)
|
126 |
+
{
|
127 |
+
$storesCollection = Mage::getModel('core/store')
|
128 |
+
->getCollection()
|
129 |
+
->addFieldToFilter('group_id', $websiteId);
|
130 |
+
foreach ($storesCollection as $store) {
|
131 |
+
//stuff into array
|
132 |
+
$stores[] = $store->getId();
|
133 |
+
}
|
134 |
+
return $stores;
|
135 |
+
}
|
136 |
+
|
137 |
+
protected function getCustomerCollection($priority, $stores)
|
138 |
+
{
|
139 |
+
$result = array();
|
140 |
+
switch ($priority['param']) {
|
141 |
+
case 'all': {
|
142 |
+
$result = Mage::getModel('customer/customer')
|
143 |
+
->getCollection()
|
144 |
+
->addFieldToFilter(
|
145 |
+
'store_id', array(
|
146 |
+
'in' => array('in' => $stores)
|
147 |
+
)
|
148 |
+
);
|
149 |
+
break;
|
150 |
+
}
|
151 |
+
case 'ids': {
|
152 |
+
$idsArr = explode(",", $priority['values']);
|
153 |
+
$result = Mage::getModel('customer/customer')
|
154 |
+
->getCollection()
|
155 |
+
->addFieldToFilter(
|
156 |
+
'store_id', array(
|
157 |
+
'in' => array('in' => $stores)
|
158 |
+
)
|
159 |
+
)
|
160 |
+
->addAttributeToFilter(
|
161 |
+
'entity_id', array('in' => $idsArr)
|
162 |
+
);
|
163 |
+
break;
|
164 |
+
}
|
165 |
+
case 'date': {
|
166 |
+
$dateStart = $priority['startDate'];
|
167 |
+
$dateEnd = $priority['endDate'];
|
168 |
+
if ($dateStart && $dateEnd) {
|
169 |
+
$result = Mage::getModel('customer/customer')
|
170 |
+
->getCollection()
|
171 |
+
->addFieldToFilter(
|
172 |
+
'store_id', array(
|
173 |
+
'in' => array('in' => $stores)
|
174 |
+
)
|
175 |
+
)
|
176 |
+
->addAttributeToFilter(
|
177 |
+
'created_at', array(
|
178 |
+
'date' => true,
|
179 |
+
'from' => $dateStart,
|
180 |
+
'to' => $dateEnd
|
181 |
+
)
|
182 |
+
);
|
183 |
+
} elseif ($dateStart) {
|
184 |
+
$result = Mage::getModel('customer/customer')
|
185 |
+
->getCollection()
|
186 |
+
->addFieldToFilter(
|
187 |
+
'store_id', array(
|
188 |
+
'in' =>
|
189 |
+
array('in' => $stores)
|
190 |
+
)
|
191 |
+
)
|
192 |
+
->addAttributeToFilter(
|
193 |
+
'created_at', array(
|
194 |
+
'date' => true,
|
195 |
+
'from' => $dateStart
|
196 |
+
)
|
197 |
+
);
|
198 |
+
} else {
|
199 |
+
$result = Mage::getModel('customer/customer')
|
200 |
+
->getCollection()
|
201 |
+
->addFieldToFilter(
|
202 |
+
'store_id', array(
|
203 |
+
'in' =>
|
204 |
+
array('in' => $stores)
|
205 |
+
)
|
206 |
+
)
|
207 |
+
->addAttributeToFilter(
|
208 |
+
'created_at', array(
|
209 |
+
'date' => true,
|
210 |
+
'to' => $dateEnd
|
211 |
+
)
|
212 |
+
);
|
213 |
+
}
|
214 |
+
break;
|
215 |
+
}
|
216 |
+
case 'default': {
|
217 |
+
break;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
if (!empty($result)) {
|
221 |
+
//reset the columns
|
222 |
+
$result->getSelect()
|
223 |
+
->reset(Zend_Db_Select::COLUMNS)
|
224 |
+
->columns('entity_id');
|
225 |
+
}
|
226 |
+
return $result;
|
227 |
+
}
|
228 |
+
|
229 |
+
protected function getOrderCollection($priority, $stores)
|
230 |
+
{
|
231 |
+
$result = array();
|
232 |
+
switch ($priority['param']) {
|
233 |
+
case 'all': {
|
234 |
+
$result = Mage::getModel('sales/order')
|
235 |
+
->getCollection()
|
236 |
+
->addFieldToFilter(
|
237 |
+
'store_id', array(
|
238 |
+
'in' => array('in' => $stores)
|
239 |
+
)
|
240 |
+
);
|
241 |
+
break;
|
242 |
+
}
|
243 |
+
case 'ids': {
|
244 |
+
$idsArr = explode(",", $priority['values']);
|
245 |
+
$result = Mage::getModel('sales/order')
|
246 |
+
->getCollection()
|
247 |
+
->addFieldToFilter(
|
248 |
+
'store_id', array(
|
249 |
+
'in' => array('in' => $stores)
|
250 |
+
)
|
251 |
+
)
|
252 |
+
->addAttributeToFilter(
|
253 |
+
'increment_id', array('in' => $idsArr)
|
254 |
+
);
|
255 |
+
break;
|
256 |
+
}
|
257 |
+
case 'date': {
|
258 |
+
$dateStart = $priority['startDate'];
|
259 |
+
$dateEnd = $priority['endDate'];
|
260 |
+
if ($dateStart && $dateEnd) {
|
261 |
+
$result = Mage::getModel('sales/order')
|
262 |
+
->getCollection()
|
263 |
+
->addFieldToFilter(
|
264 |
+
'store_id', array(
|
265 |
+
'in' => array('in' => $stores)
|
266 |
+
)
|
267 |
+
)
|
268 |
+
->addAttributeToFilter(
|
269 |
+
'created_at', array(
|
270 |
+
'date' => true,
|
271 |
+
'from' => $dateStart,
|
272 |
+
'to' => $dateEnd
|
273 |
+
)
|
274 |
+
);
|
275 |
+
} elseif ($dateStart) {
|
276 |
+
$result = Mage::getModel('sales/order')
|
277 |
+
->getCollection()
|
278 |
+
->addFieldToFilter(
|
279 |
+
'store_id', array(
|
280 |
+
'in' => array('in' => $stores)
|
281 |
+
)
|
282 |
+
)
|
283 |
+
->addAttributeToFilter(
|
284 |
+
'created_at', array(
|
285 |
+
'date' => true,
|
286 |
+
'from' => $dateStart
|
287 |
+
)
|
288 |
+
);
|
289 |
+
} else {
|
290 |
+
$result = Mage::getModel('sales/order')
|
291 |
+
->getCollection()
|
292 |
+
->addFieldToFilter(
|
293 |
+
'store_id', array(
|
294 |
+
'in' => array('in' => $stores)
|
295 |
+
)
|
296 |
+
)
|
297 |
+
->addAttributeToFilter(
|
298 |
+
'created_at', array(
|
299 |
+
'date' => true,
|
300 |
+
'to' => $dateEnd
|
301 |
+
)
|
302 |
+
);
|
303 |
+
}
|
304 |
+
break;
|
305 |
+
}
|
306 |
+
case 'default': {
|
307 |
+
break;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
if (!empty($result)) {
|
311 |
+
//reset the columns
|
312 |
+
$result->getSelect()
|
313 |
+
->reset(Zend_Db_Select::COLUMNS)
|
314 |
+
->columns(
|
315 |
+
array('entity_id', 'increment_id')
|
316 |
+
);
|
317 |
+
}
|
318 |
+
return $result;
|
319 |
+
}
|
320 |
+
protected function getProductCollection($priority, $websiteId)
|
321 |
+
{
|
322 |
+
$result = array();
|
323 |
+
switch ($priority['param']) {
|
324 |
+
case 'all': {
|
325 |
+
$result = Mage::getModel('catalog/product')
|
326 |
+
->getCollection()
|
327 |
+
->addWebsiteFilter($websiteId);
|
328 |
+
break;
|
329 |
+
}
|
330 |
+
case 'ids': {
|
331 |
+
$idsArr = explode(",", $priority['values']);
|
332 |
+
$result = Mage::getModel('catalog/product')
|
333 |
+
->getCollection()
|
334 |
+
->addWebsiteFilter($websiteId)
|
335 |
+
->addAttributeToFilter(
|
336 |
+
'entity_id', array('in' => $idsArr)
|
337 |
+
);
|
338 |
+
break;
|
339 |
+
}
|
340 |
+
case 'date': {
|
341 |
+
$dateStart = $priority['startDate'];
|
342 |
+
$dateEnd = $priority['endDate'];
|
343 |
+
if ($dateStart && $dateEnd) {
|
344 |
+
$result = Mage::getModel('catalog/product')
|
345 |
+
->getCollection()
|
346 |
+
->addWebsiteFilter($websiteId)
|
347 |
+
->addAttributeToFilter(
|
348 |
+
'created_at', array(
|
349 |
+
'date' => true,
|
350 |
+
'from' => $dateStart,
|
351 |
+
'to' => $dateEnd
|
352 |
+
)
|
353 |
+
);
|
354 |
+
} elseif ($dateStart) {
|
355 |
+
$result = Mage::getModel('catalog/product')
|
356 |
+
->getCollection()
|
357 |
+
->addWebsiteFilter($websiteId)
|
358 |
+
->addAttributeToFilter(
|
359 |
+
'created_at', array(
|
360 |
+
'date' => true,
|
361 |
+
'from' => $dateStart
|
362 |
+
)
|
363 |
+
);
|
364 |
+
} else {
|
365 |
+
$result = Mage::getModel('catalog/product')
|
366 |
+
->getCollection()
|
367 |
+
->addWebsiteFilter($websiteId)
|
368 |
+
->addAttributeToFilter(
|
369 |
+
'created_at', array(
|
370 |
+
'date' => true,
|
371 |
+
'to' => $dateEnd
|
372 |
+
)
|
373 |
+
);
|
374 |
+
}
|
375 |
+
break;
|
376 |
+
}
|
377 |
+
case 'default': {
|
378 |
+
break;
|
379 |
+
}
|
380 |
+
}
|
381 |
+
if (!empty($result)) {
|
382 |
+
//reset the columns
|
383 |
+
$result->getSelect()
|
384 |
+
->reset(Zend_Db_Select::COLUMNS)
|
385 |
+
->columns('entity_id');
|
386 |
+
}
|
387 |
+
return $result;
|
388 |
+
}
|
389 |
+
|
390 |
+
protected function getCategoryCollection($priority)
|
391 |
+
{
|
392 |
+
$result = null;
|
393 |
+
switch ($priority['param']) {
|
394 |
+
case 'all': {
|
395 |
+
$result = Mage::getModel('catalog/category')
|
396 |
+
->getCollection();
|
397 |
+
break;
|
398 |
+
}
|
399 |
+
case 'ids': {
|
400 |
+
$idsArr = explode(",", $priority['values']);
|
401 |
+
$result = Mage::getModel('catalog/category')
|
402 |
+
->getCollection()
|
403 |
+
->addAttributeToFilter(
|
404 |
+
'entity_id', array('in' => $idsArr)
|
405 |
+
);
|
406 |
+
break;
|
407 |
+
}
|
408 |
+
case 'date': {
|
409 |
+
$dateStart = $priority['startDate'];
|
410 |
+
$dateEnd = $priority['endDate'];
|
411 |
+
if ($dateStart && $dateEnd) {
|
412 |
+
$result = Mage::getModel('catalog/category')
|
413 |
+
->getCollection()
|
414 |
+
->addAttributeToFilter(
|
415 |
+
'created_at', array(
|
416 |
+
'date' => true,
|
417 |
+
'from' => $dateStart,
|
418 |
+
'to' => $dateEnd
|
419 |
+
)
|
420 |
+
);
|
421 |
+
} elseif ($dateStart) {
|
422 |
+
$result = Mage::getModel('catalog/category')
|
423 |
+
->getCollection()
|
424 |
+
->addAttributeToFilter(
|
425 |
+
'created_at', array(
|
426 |
+
'date' => true,
|
427 |
+
'from' => $dateStart
|
428 |
+
)
|
429 |
+
);
|
430 |
+
} else {
|
431 |
+
$result = Mage::getModel('catalog/category')
|
432 |
+
->getCollection()
|
433 |
+
->addAttributeToFilter(
|
434 |
+
'created_at', array(
|
435 |
+
'date' => true,
|
436 |
+
'to' => $dateEnd
|
437 |
+
)
|
438 |
+
);
|
439 |
+
}
|
440 |
+
break;
|
441 |
+
}
|
442 |
+
case 'default': {
|
443 |
+
break;
|
444 |
+
}
|
445 |
+
}
|
446 |
+
return $result;
|
447 |
+
}
|
448 |
+
|
449 |
+
protected function getCustomerGroupCollection($priority)
|
450 |
+
{
|
451 |
+
$result = null;
|
452 |
+
switch ($priority['param']) {
|
453 |
+
case 'all':
|
454 |
+
case 'date': {
|
455 |
+
/* customer_group doesn't have create_at field */
|
456 |
+
$result = Mage::getModel('customer/group')
|
457 |
+
->getCollection();
|
458 |
+
break;
|
459 |
+
}
|
460 |
+
case 'ids': {
|
461 |
+
$idsArr = explode(",", $priority['values']);
|
462 |
+
$result = Mage::getModel('customer/group')
|
463 |
+
->getCollection()
|
464 |
+
->addFieldToFilter(
|
465 |
+
'customer_group_id', array('in' => $idsArr)
|
466 |
+
);
|
467 |
+
break;
|
468 |
+
}
|
469 |
+
case 'default': {
|
470 |
+
break;
|
471 |
+
}
|
472 |
+
}
|
473 |
+
return $result;
|
474 |
+
}
|
475 |
+
|
476 |
+
public function getEntityIdsCollection(
|
477 |
+
$entityToExport,
|
478 |
+
$priority,
|
479 |
+
$websiteId = 1
|
480 |
+
)
|
481 |
+
{
|
482 |
+
$result = array();
|
483 |
+
$stores = $this->getStoresArray($websiteId);
|
484 |
+
|
485 |
+
switch ($entityToExport) {
|
486 |
+
case 'customer': {
|
487 |
+
$result = $this->getCustomerCollection($priority, $stores);
|
488 |
+
break;
|
489 |
+
}
|
490 |
+
case 'order': {
|
491 |
+
$result = $this->getOrderCollection($priority, $stores);
|
492 |
+
break;
|
493 |
+
}
|
494 |
+
case 'product': {
|
495 |
+
$result = $this
|
496 |
+
->getProductCollection($priority, $websiteId);
|
497 |
+
break;
|
498 |
+
}
|
499 |
+
case 'category': {
|
500 |
+
$result = null;
|
501 |
+
$result = $this->getCategoryCollection($priority, $stores);
|
502 |
+
$result->getSelect()
|
503 |
+
->reset(Zend_Db_Select::COLUMNS)
|
504 |
+
->columns('entity_id');
|
505 |
+
break;
|
506 |
+
}
|
507 |
+
case 'customergroup': {
|
508 |
+
$result = null;
|
509 |
+
$result = $this->getCustomerGroupCollection($priority);
|
510 |
+
$result->getSelect()
|
511 |
+
->reset(Zend_Db_Select::COLUMNS)
|
512 |
+
->columns('customer_group_id');
|
513 |
+
break;
|
514 |
+
}
|
515 |
+
default: {
|
516 |
+
break;
|
517 |
+
}
|
518 |
+
}
|
519 |
+
return $result;
|
520 |
+
}
|
521 |
+
|
522 |
+
public function getExportData($entityToExport, $batchsize, $dataCollection)
|
523 |
+
{
|
524 |
+
$helper = $this->getHelper();
|
525 |
+
$this->entity = $entityToExport;
|
526 |
+
|
527 |
+
$entityModel = $helper->getEntityModel($entityToExport);
|
528 |
+
|
529 |
+
$data = array();
|
530 |
+
$bathCounter = 1;
|
531 |
+
$recordCounter = 0;
|
532 |
+
|
533 |
+
foreach ($dataCollection as $oneEntity) {
|
534 |
+
if ($entityToExport != 'order') {
|
535 |
+
$entityData = $entityModel->info($oneEntity['entity_id']);
|
536 |
+
} else {
|
537 |
+
$entityData = $entityModel->info($oneEntity['increment_id']);
|
538 |
+
}
|
539 |
+
|
540 |
+
$data[$bathCounter][$oneEntity['entity_id']] =
|
541 |
+
array($entityToExport => $entityData);
|
542 |
+
$recordCounter++;
|
543 |
+
if ($recordCounter == $batchsize) {
|
544 |
+
$recordCounter = 0;
|
545 |
+
$bathCounter++;
|
546 |
+
}
|
547 |
+
}
|
548 |
+
|
549 |
+
$date = date("m-d-Y_H-i-s");
|
550 |
+
$fileResult = array();
|
551 |
+
foreach ($data as $batchNumber => $oneBatch) {
|
552 |
+
$outXml = Mage::getModel('advancedexport/exportmodels_abstract')
|
553 |
+
->arrayToXml($entityToExport, $oneBatch);
|
554 |
+
$fileName =
|
555 |
+
$helper->putFile($entityToExport, $outXml, $batchNumber, $date);
|
556 |
+
if ($fileName) {
|
557 |
+
$fileResult[] = $fileName;
|
558 |
+
} else {
|
559 |
+
$this->errors[] = 'File failed to create. Batch Number is '
|
560 |
+
. $batchNumber . '. Batches count: ' . count($data);
|
561 |
+
Mage::log(
|
562 |
+
'File failed to create. Batch Number is ' . $batchNumber
|
563 |
+
. '. Batches count: ' . count($data), 1, 'freestyle.log'
|
564 |
+
);
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
return $fileResult;
|
569 |
+
}
|
570 |
+
|
571 |
+
public function getExportDataMemoryControll(
|
572 |
+
$entityToExport,
|
573 |
+
$batchsize,
|
574 |
+
$dataCollection,
|
575 |
+
$idsFile,
|
576 |
+
$dateTimeInit,
|
577 |
+
$lastExportedStepInfo,
|
578 |
+
$batchesFile,
|
579 |
+
$websiteId = 1
|
580 |
+
)
|
581 |
+
{
|
582 |
+
$maxMemory = (float) ini_get("memory_limit");
|
583 |
+
unset($idsFile);
|
584 |
+
$this->entity = $entityToExport;
|
585 |
+
$helper = $this->getHelper();
|
586 |
+
$entityModel = $helper->getEntityModel($entityToExport);
|
587 |
+
|
588 |
+
$data = array();
|
589 |
+
$memoryFinish = false;
|
590 |
+
|
591 |
+
$dataReturnStepValue = array();
|
592 |
+
|
593 |
+
$startRecordNumber = 0;
|
594 |
+
if ($lastExportedStepInfo['last_record_value']) {
|
595 |
+
$startRecordNumber =
|
596 |
+
(int) $lastExportedStepInfo['last_record_value'] + 1;
|
597 |
+
}
|
598 |
+
|
599 |
+
$currentBatchNumber = (int) ($startRecordNumber / (int) $batchsize);
|
600 |
+
$currentBatchNumber++;
|
601 |
+
|
602 |
+
$configPath = Mage::getBaseDir() . DS .
|
603 |
+
Mage::Helper('advancedexport')->getExportfolder();
|
604 |
+
$zipFile = '[' . $helper->getChanelName() . ']_'
|
605 |
+
. '[' . $helper->getChanelId($websiteId) . ']_'
|
606 |
+
. '[' . $entityToExport . ']_'
|
607 |
+
. '[' . $dateTimeInit . ']';
|
608 |
+
|
609 |
+
$tempfile = $zipFile . '_'
|
610 |
+
. '[batch-' . $currentBatchNumber . '].xml';
|
611 |
+
|
612 |
+
$fileFullPath = $configPath . DS . $tempfile;
|
613 |
+
$zipFileFullPath = $configPath . DS . $zipFile;
|
614 |
+
|
615 |
+
$batchesFile[$tempfile] = $fileFullPath;
|
616 |
+
|
617 |
+
for ($i = $startRecordNumber; $i < count($dataCollection); $i++) {
|
618 |
+
$this->closeXmlHeader($i, $batchsize, $fileFullPath);
|
619 |
+
$currentBatchNumber = (int) ($i / (int) $batchsize);
|
620 |
+
$currentBatchNumber++;
|
621 |
+
|
622 |
+
$tempfile = '[' . $helper->getChanelName() . ']_'
|
623 |
+
. '[' . $helper->getChanelId($websiteId) . ']_'
|
624 |
+
. '[' . $entityToExport . ']_'
|
625 |
+
. '[' . $dateTimeInit . ']_'
|
626 |
+
. '[batch-' . $currentBatchNumber . '].xml';
|
627 |
+
$fileFullPath = $configPath . DS . $tempfile;
|
628 |
+
|
629 |
+
$batchesFile[$tempfile] = $fileFullPath;
|
630 |
+
|
631 |
+
$oneEntity = $dataCollection[$i];
|
632 |
+
|
633 |
+
switch ($entityToExport){
|
634 |
+
case 'order' :
|
635 |
+
$entityData = $entityModel
|
636 |
+
->info($oneEntity['increment_id']);
|
637 |
+
$dataReturnStepValue['index'] = 'increment_id';
|
638 |
+
$dataReturnStepValue['value'] = $oneEntity['increment_id'];
|
639 |
+
$dataReturnStepValue['record_number'] = $i;
|
640 |
+
break;
|
641 |
+
case 'customergroup' :
|
642 |
+
$entityData = $entityModel
|
643 |
+
->info($oneEntity['customer_group_id']);
|
644 |
+
$dataReturnStepValue['index'] = 'customer_group_id';
|
645 |
+
$dataReturnStepValue['value'] =
|
646 |
+
$oneEntity['customer_group_id'];
|
647 |
+
$dataReturnStepValue['record_number'] = $i;
|
648 |
+
break;
|
649 |
+
default :
|
650 |
+
$entityData = $entityModel->info($oneEntity['entity_id']);
|
651 |
+
$dataReturnStepValue['index'] = 'entity_id';
|
652 |
+
$dataReturnStepValue['value'] = $oneEntity['entity_id'];
|
653 |
+
$dataReturnStepValue['record_number'] = $i;
|
654 |
+
}
|
655 |
+
|
656 |
+
$data = array($entityToExport => $entityData);
|
657 |
+
|
658 |
+
try {
|
659 |
+
$outXml = $this->arrayToXml($entityToExport, $data);
|
660 |
+
$helper->addToOutCollector(
|
661 |
+
$entityToExport,
|
662 |
+
$outXml,
|
663 |
+
$fileFullPath
|
664 |
+
);
|
665 |
+
} catch (Exception $e) {
|
666 |
+
$this->stepErrors[] = 'Can not Save Entity To Xml. Entity Id: '
|
667 |
+
. $oneEntity['entity_id'];
|
668 |
+
Mage::log(
|
669 |
+
'Can not [SAVE] Entity To Xml. Entity Id: '
|
670 |
+
. $oneEntity['entity_id'], 1, 'freestyle.log'
|
671 |
+
);
|
672 |
+
}
|
673 |
+
|
674 |
+
//Controll Memory
|
675 |
+
$currentMemoryUsage = (float) memory_get_usage() / 1024 / 1024;
|
676 |
+
if ($maxMemory < ($currentMemoryUsage + 10)) {
|
677 |
+
$finishStepInfo = array(
|
678 |
+
'error' => 'no_errors',
|
679 |
+
'action' => 'next_step',
|
680 |
+
'entermmidiateFileName' => $tempfile,
|
681 |
+
'last_exported_info' => $dataReturnStepValue,
|
682 |
+
'export_finished' => 0,
|
683 |
+
'memorylimit' => $maxMemory,
|
684 |
+
'memory_usage' => $currentMemoryUsage,
|
685 |
+
'error' => $this->stepErrors,
|
686 |
+
'batches_files' => $batchesFile,
|
687 |
+
);
|
688 |
+
|
689 |
+
$memoryFinish = true;
|
690 |
+
break;
|
691 |
+
}
|
692 |
+
}
|
693 |
+
|
694 |
+
if ($memoryFinish) {
|
695 |
+
return $finishStepInfo;
|
696 |
+
} else {
|
697 |
+
if (count($dataCollection)) {
|
698 |
+
//$helper->closeXmlHeaderTag($entityToExport, $fileFullPath);
|
699 |
+
$helper->closeXmlHeaderTag($fileFullPath);
|
700 |
+
} else {
|
701 |
+
//$helper->openXmlHeaderTag($entityToExport, $fileFullPath);
|
702 |
+
$helper->openXmlHeaderTag($fileFullPath);
|
703 |
+
//$helper->closeXmlHeaderTag($entityToExport, $fileFullPath);
|
704 |
+
$helper->closeXmlHeaderTag($fileFullPath);
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
$this->createZip($zipFileFullPath, $batchesFile);
|
709 |
+
|
710 |
+
$fileResult['export_finished'] = 1;
|
711 |
+
$fileResult['action'] = 'end';
|
712 |
+
$fileResult['batches_files'] = $batchesFile;
|
713 |
+
$fileResult['zip_file'] = array($zipFile . '.zip');
|
714 |
+
$fileResult['error'] = $this->stepErrors;
|
715 |
+
|
716 |
+
return $fileResult;
|
717 |
+
}
|
718 |
+
|
719 |
+
protected function closeXmlHeader($pointer, $batchsize, $fileFullPath)
|
720 |
+
{
|
721 |
+
$helper = $this->getHelper();
|
722 |
+
//File Name and File Path Format
|
723 |
+
if ((($pointer % (int) $batchsize) == 0) && ($pointer != 0)) {
|
724 |
+
//$helper->closeXmlHeaderTag($entityToExport, $fileFullPath);
|
725 |
+
$helper->closeXmlHeaderTag($fileFullPath);
|
726 |
+
}
|
727 |
+
}
|
728 |
+
|
729 |
+
protected function createZip($zipFileFullPath, $batchesFile)
|
730 |
+
{
|
731 |
+
$zip = new ZipArchive();
|
732 |
+
try {
|
733 |
+
$zip->open($zipFileFullPath . '.zip', ZIPARCHIVE::CREATE);
|
734 |
+
} catch (Exception $e) {
|
735 |
+
$this->stepErrors[] = 'Can not create Zip Archive';
|
736 |
+
Mage::log('Can not [CREATE] Zip Archive', 1, 'freestyle.log');
|
737 |
+
}
|
738 |
+
foreach ($batchesFile as $fileName => $fullPath) {
|
739 |
+
try {
|
740 |
+
$zip->addFile($fullPath, $fileName);
|
741 |
+
} catch (Exception $e) {
|
742 |
+
$this->stepErrors[] = 'Can not add file '
|
743 |
+
. $fileName
|
744 |
+
. ' to Zip Archive';
|
745 |
+
Mage::log(
|
746 |
+
'Can not [ADD] file '
|
747 |
+
. $fileName
|
748 |
+
. ' to Zip Archive', 1, 'freestyle.log'
|
749 |
+
);
|
750 |
+
}
|
751 |
+
}
|
752 |
+
$zip->close();
|
753 |
+
}
|
754 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Category.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Exportmodels_Category
|
12 |
+
extends Mage_Catalog_Model_Category_Api
|
13 |
+
{
|
14 |
+
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Initilize and return category model
|
18 |
+
*
|
19 |
+
* @param int $categoryId
|
20 |
+
* @param string|int $store
|
21 |
+
* @return Mage_Catalog_Model_Category
|
22 |
+
*/
|
23 |
+
protected function _initCategory($categoryId, $store = null)
|
24 |
+
{
|
25 |
+
$category = Mage::getModel('catalog/category')
|
26 |
+
->setStoreId($this->_getStoreId($store))
|
27 |
+
->load($categoryId);
|
28 |
+
|
29 |
+
if (!$category->getId()) {
|
30 |
+
Mage::log(
|
31 |
+
'[ALERT] - Advanced Export: Category Does '
|
32 |
+
. 'Not Exist. Category Id: ' . $categoryId,
|
33 |
+
1,
|
34 |
+
'freestyle.log'
|
35 |
+
);
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
|
39 |
+
return $category;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Retrieve category data
|
44 |
+
*
|
45 |
+
* @param int $categoryId
|
46 |
+
* @param string|int $store
|
47 |
+
* @param array $attributes
|
48 |
+
* @return array
|
49 |
+
*/
|
50 |
+
public function info($categoryId, $store = null, $attributes = null)
|
51 |
+
{
|
52 |
+
$result = array();
|
53 |
+
|
54 |
+
$isFlatEnabled = Mage::helper('catalog/category_flat')->isEnabled();
|
55 |
+
if ($isFlatEnabled) {
|
56 |
+
$defaultStoreId = Mage::app()->getWebsite()
|
57 |
+
->getDefaultGroup()
|
58 |
+
->getDefaultStoreId();
|
59 |
+
$category = $this->_initCategory($categoryId, $defaultStoreId);
|
60 |
+
if ($category) {
|
61 |
+
$result = $category->getData();
|
62 |
+
$result['category_id'] = $result['entity_id'];
|
63 |
+
}
|
64 |
+
} else {
|
65 |
+
$category = $this->_initCategory($categoryId, $store);
|
66 |
+
if ($category) {
|
67 |
+
// Basic category data
|
68 |
+
$result = array();
|
69 |
+
$result['category_id'] = $category->getId();
|
70 |
+
|
71 |
+
$result['is_active'] = $category->getIsActive();
|
72 |
+
$result['position'] = $category->getPosition();
|
73 |
+
$result['level'] = $category->getLevel();
|
74 |
+
|
75 |
+
foreach ($category->getAttributes() as $attribute) {
|
76 |
+
if ($this->_isAllowedAttribute($attribute, $attributes)) {
|
77 |
+
$result[$attribute->getAttributeCode()] =
|
78 |
+
$category->getData($attribute->getAttributeCode());
|
79 |
+
}
|
80 |
+
}
|
81 |
+
$result['parent_id'] = $category->getParentId();
|
82 |
+
$result['children'] = $category->getChildren();
|
83 |
+
$result['all_children'] = $category->getAllChildren();
|
84 |
+
|
85 |
+
|
86 |
+
if (is_array($result['available_sort_by'])) {
|
87 |
+
$sortedby = array();
|
88 |
+
foreach ($result['available_sort_by'] as $pos) {
|
89 |
+
$sortedby[]['value'] = $pos;
|
90 |
+
}
|
91 |
+
$result['available_sort_by'] = $sortedby;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
return $result;
|
97 |
+
}
|
98 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Customer.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Exportmodels_Customer
|
14 |
+
extends Mage_Customer_Model_Api_Resource
|
15 |
+
{
|
16 |
+
|
17 |
+
protected $_mapAttributes = array(
|
18 |
+
'customer_id' => 'entity_id'
|
19 |
+
);
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Prepare data to insert/update.
|
23 |
+
* Creating array for stdClass Object
|
24 |
+
*
|
25 |
+
* @param stdClass $data
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
protected function _prepareData($data)
|
29 |
+
{
|
30 |
+
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
|
31 |
+
if (isset($data[$attributeAlias])) {
|
32 |
+
$data[$attributeCode] = $data[$attributeAlias];
|
33 |
+
unset($data[$attributeAlias]);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
return $data;
|
37 |
+
}
|
38 |
+
|
39 |
+
//DE-10150 - refactor code
|
40 |
+
protected function _initCustomer($customerId)
|
41 |
+
{
|
42 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
43 |
+
if (!$customer->getId()) {
|
44 |
+
$this->_fault('not_exists');
|
45 |
+
}
|
46 |
+
return $customer;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Retrieve customer data
|
51 |
+
*
|
52 |
+
* @param int $customerId
|
53 |
+
* @param array $attributes
|
54 |
+
* @return array
|
55 |
+
*/
|
56 |
+
public function info($customerId, $attributes = null)
|
57 |
+
{
|
58 |
+
//$customer = Mage::getModel('customer/customer')->load($customerId);
|
59 |
+
try {
|
60 |
+
$customer = $this->_initCustomer($customerId);
|
61 |
+
} catch (Exception $e) {
|
62 |
+
$result = $e->getMessage();
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
$locale = Mage::app()->getLocale();
|
67 |
+
|
68 |
+
$dftBillAddr = '';
|
69 |
+
$dftShipAddr = '';
|
70 |
+
if ($customer->getDefaultBillingAddress()) {
|
71 |
+
$dftBillAddr = $customer
|
72 |
+
->getDefaultBillingAddress()
|
73 |
+
->getId();
|
74 |
+
}
|
75 |
+
if ($customer->getDefaultShippingAddress()) {
|
76 |
+
$dftShipAddr = $customer
|
77 |
+
->getDefaultShippingAddress()
|
78 |
+
->getId();
|
79 |
+
}
|
80 |
+
|
81 |
+
//DE-9638
|
82 |
+
/*
|
83 |
+
if (!$customer->getId()) {
|
84 |
+
$this->_fault('not_exists');
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
*
|
88 |
+
*/
|
89 |
+
|
90 |
+
if (!is_null($attributes) && !is_array($attributes)) {
|
91 |
+
$attributes = array($attributes);
|
92 |
+
}
|
93 |
+
|
94 |
+
$result = array();
|
95 |
+
|
96 |
+
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
|
97 |
+
$result[$attributeAlias] = $customer->getData($attributeCode);
|
98 |
+
}
|
99 |
+
|
100 |
+
$allowedAttribs = $this->getAllowedAttributes($customer, $attributes);
|
101 |
+
foreach ($allowedAttribs as $attributeCode => $attribute) {
|
102 |
+
$result[$attributeCode] = $customer->getData($attributeCode);
|
103 |
+
}
|
104 |
+
|
105 |
+
$customerAddresses = $customer->getAddresses();
|
106 |
+
if (count($customerAddresses)) {
|
107 |
+
foreach ($customer->getAddresses() as $address) {
|
108 |
+
$data['customer_address'] = $address->toArray();
|
109 |
+
if (isset($data['customer_address']['entity_id'])) {
|
110 |
+
$data['customer_address']['customer_address_id']
|
111 |
+
= $data['customer_address']['entity_id'];
|
112 |
+
unset($data['customer_address']['entity_id']);
|
113 |
+
}
|
114 |
+
if (isset($data['customer_address']['country_id'])) {
|
115 |
+
$countryName = $locale->
|
116 |
+
getCountryTranslation(
|
117 |
+
$data['customer_address']['country_id']
|
118 |
+
);
|
119 |
+
$data['customer_address']['country_name'] = $countryName;
|
120 |
+
}
|
121 |
+
$data['customer_address']['is_default_shipping'] = '0';
|
122 |
+
$data['customer_address']['is_default_billing'] = '0';
|
123 |
+
|
124 |
+
if ($address->getEntityId() == $dftBillAddr) {
|
125 |
+
$data['customer_address']['is_default_billing'] = '1';
|
126 |
+
}
|
127 |
+
if ($address->getEntityId() == $dftShipAddr) {
|
128 |
+
$data['customer_address']['is_default_shipping'] = '1';
|
129 |
+
}
|
130 |
+
|
131 |
+
$result['customer_addresses'][] = $data;
|
132 |
+
}
|
133 |
+
} else {
|
134 |
+
$result['customer_addresses'] = array();
|
135 |
+
}
|
136 |
+
|
137 |
+
unset($customerAddresses);
|
138 |
+
unset($data);
|
139 |
+
unset($customer);
|
140 |
+
unset($locale);
|
141 |
+
return $result;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
// Class Mage_Customer_Model_Customer_Api End
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Customergroup.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Exportmodels_Customergroup
|
14 |
+
extends Mage_Customer_Model_Group_Api
|
15 |
+
{
|
16 |
+
|
17 |
+
protected $_mapAttributes = array(
|
18 |
+
'customer_group_id' => 'customer_group_id',
|
19 |
+
'customer_group_code' => 'customer_group_code'
|
20 |
+
);
|
21 |
+
|
22 |
+
protected function _initCustomerGroup($customerGroupId)
|
23 |
+
{
|
24 |
+
$customerGroup = Mage::getModel('customer/group')
|
25 |
+
->load($customerGroupId);
|
26 |
+
|
27 |
+
return $customerGroup;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Retrieve customer group data
|
32 |
+
*
|
33 |
+
* @param int $customerGroupId
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function info($customerGroupId, $attributes = null)
|
37 |
+
{
|
38 |
+
try {
|
39 |
+
$customerGroup = $this->_initCustomerGroup($customerGroupId);
|
40 |
+
} catch(Exception $e) {
|
41 |
+
$result = $e->getMessage();
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
$result = array();
|
46 |
+
|
47 |
+
if ($customerGroup) {
|
48 |
+
foreach ($this->_mapAttributes as $attribAlias => $attributeCode) {
|
49 |
+
$result[$attribAlias] = $customerGroup
|
50 |
+
->getData($attributeCode);
|
51 |
+
}
|
52 |
+
|
53 |
+
$result['is_default'] = $customerGroup->usesAsDefault();
|
54 |
+
|
55 |
+
unset($customerGroup);
|
56 |
+
}
|
57 |
+
|
58 |
+
return $result;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getEntityIdFieldName()
|
62 |
+
{
|
63 |
+
return "customer_group_id";
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Order.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Exportmodels_Order
|
14 |
+
extends Mage_Sales_Model_Order_Api
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _initOrder($orderIncrementId)
|
18 |
+
{
|
19 |
+
$order = Mage::getModel('sales/order');
|
20 |
+
|
21 |
+
/* @var $order Mage_Sales_Model_Order */
|
22 |
+
|
23 |
+
$order->loadByIncrementId($orderIncrementId);
|
24 |
+
|
25 |
+
if (!$order->getId()) {
|
26 |
+
$this->_fault('not_exists');
|
27 |
+
}
|
28 |
+
|
29 |
+
return $order;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Retrieve full order information
|
34 |
+
*
|
35 |
+
* @param string $orderIncrementId
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function info($orderIncrementId)
|
39 |
+
{
|
40 |
+
//DE-10150 - gracefully handle error / exception
|
41 |
+
try {
|
42 |
+
$order = $this->_initOrder($orderIncrementId);
|
43 |
+
} catch (Exception $e) {
|
44 |
+
$result = $e->getMessage();
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($order->getGiftMessageId() > 0) {
|
49 |
+
$order->setGiftMessage(
|
50 |
+
Mage::getSingleton('giftmessage/message')
|
51 |
+
->load($order->getGiftMessageId())->getMessage()
|
52 |
+
);
|
53 |
+
}
|
54 |
+
|
55 |
+
$result = $this->_getAttributes($order, 'order');
|
56 |
+
|
57 |
+
$result['shipping_address'][]['salesOrderAddressEntity'] =
|
58 |
+
$this->_getAttributes(
|
59 |
+
$order->getShippingAddress(),
|
60 |
+
'order_address'
|
61 |
+
);
|
62 |
+
$result['billing_address'][]['salesOrderAddressEntity'] =
|
63 |
+
$this->_getAttributes(
|
64 |
+
$order->getBillingAddress(),
|
65 |
+
'order_address'
|
66 |
+
);
|
67 |
+
$result['items'] = array();
|
68 |
+
|
69 |
+
foreach ($order->getAllItems() as $item) {
|
70 |
+
if ($item->getGiftMessageId() > 0) {
|
71 |
+
$item->setGiftMessage(
|
72 |
+
Mage::getSingleton('giftmessage/message')
|
73 |
+
->load($item->getGiftMessageId())->getMessage()
|
74 |
+
);
|
75 |
+
}
|
76 |
+
$result['items'][]['salesOrderItemEntity'] =
|
77 |
+
$this->_getAttributes($item, 'order_item');
|
78 |
+
}
|
79 |
+
|
80 |
+
//Fixes for Authorize Payment
|
81 |
+
$paymentData = $this->_getAttributes(
|
82 |
+
$order->getPayment(),
|
83 |
+
'order_payment'
|
84 |
+
);
|
85 |
+
if (isset($paymentData['additional_information']['authorize_cards'])) {
|
86 |
+
$authorizeCards = array();
|
87 |
+
foreach ($paymentData['additional_information']['authorize_cards'] as $oneCart) {
|
88 |
+
$authorizeCards[]['card'] = $oneCart;
|
89 |
+
}
|
90 |
+
$paymentData['additional_information']['authorize_cards'] =
|
91 |
+
$authorizeCards;
|
92 |
+
}
|
93 |
+
|
94 |
+
$result['payment'][]['salesOrderPaymentEntity'] = $paymentData;
|
95 |
+
//$result['payment']['salesOrderPaymentEntity'] =
|
96 |
+
//$this->_getAttributes($order->getPayment(), 'order_payment');
|
97 |
+
|
98 |
+
$result['status_history'] = array();
|
99 |
+
|
100 |
+
foreach ($order->getAllStatusHistory() as $history) {
|
101 |
+
$result['status_history']['salesOrderStatusHistoryEntity'][] =
|
102 |
+
$this->_getAttributes($history, 'order_status_history');
|
103 |
+
}
|
104 |
+
|
105 |
+
return $result;
|
106 |
+
}
|
107 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/Product.php
ADDED
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Exportmodels_Product
|
14 |
+
extends Mage_Catalog_Model_Product_Api
|
15 |
+
{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Retrieve product info
|
19 |
+
*
|
20 |
+
* @param int|string $productId
|
21 |
+
* @param string|int $store
|
22 |
+
* @param array $attributes
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public $productId;
|
26 |
+
|
27 |
+
public function info(
|
28 |
+
$productId,
|
29 |
+
$store = null,
|
30 |
+
$attributes = null,
|
31 |
+
$identifierType = null
|
32 |
+
)
|
33 |
+
{
|
34 |
+
//TODO: Cycle thru the stores?
|
35 |
+
try {
|
36 |
+
$product = $this->_getProduct($productId, $store, $identifierType);
|
37 |
+
} catch (Exception $e) {
|
38 |
+
$result = $e->getMessage();
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
$helper = Mage::helper('catalog/image');
|
42 |
+
|
43 |
+
/*
|
44 |
+
$catalogApi = Mage::getModel('catalog/product_attribute_media_api');
|
45 |
+
$catalogApi->info();
|
46 |
+
*
|
47 |
+
*
|
48 |
+
*/
|
49 |
+
$imDt = $this->getAssignedImages($product, array(0));
|
50 |
+
$imagesInfo = array();
|
51 |
+
$imageOne = array();
|
52 |
+
$_images = $product->getMediaGallery();
|
53 |
+
$sendImages = Mage::Helper('advancedexport')
|
54 |
+
->getProductSendImages() == 1;
|
55 |
+
if ($sendImages && $_images) {
|
56 |
+
foreach ($_images as $_imageAr) {
|
57 |
+
foreach ($_imageAr as $_image) {
|
58 |
+
$imageOne['label'] = $_image['label'];
|
59 |
+
$imageOne['url'] = (string) $helper
|
60 |
+
->init($product, 'thumbnail', $_image['file']);
|
61 |
+
$imageOne['exclude'] = $_image['disabled'];
|
62 |
+
$imageOne['position'] = $_image['position'];
|
63 |
+
$imageOne['file'] = $_image['file'];
|
64 |
+
|
65 |
+
$imageTypes = array();
|
66 |
+
foreach ($imDt as $oneAttrImage) {
|
67 |
+
if ($_image['file'] == $oneAttrImage['filepath']) {
|
68 |
+
$imageTypes[]['string'] =
|
69 |
+
$oneAttrImage['attribute_code'];
|
70 |
+
}
|
71 |
+
}
|
72 |
+
$imageOne['types'] = $imageTypes;
|
73 |
+
|
74 |
+
$imagesInfo[]['product_image'] = $imageOne;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
$productsCategories = $product->getCategoryIds();
|
80 |
+
$productsWebsites = $product->getWebsiteIds();
|
81 |
+
|
82 |
+
$catData = array();
|
83 |
+
foreach ($productsCategories as $categoryId) {
|
84 |
+
$catData[]['string'] = $categoryId;
|
85 |
+
}
|
86 |
+
|
87 |
+
$websitesData = array();
|
88 |
+
foreach ($productsWebsites as $websiteId) {
|
89 |
+
$websitesData[]['string'] = $websiteId;
|
90 |
+
}
|
91 |
+
|
92 |
+
/* JPC@DYDA: cataloginventory/stock_item has
|
93 |
+
* access to qty and is_in_stock */
|
94 |
+
$stock = Mage::getModel('cataloginventory/stock_item')
|
95 |
+
->loadByProduct($product);
|
96 |
+
$result = array(// Basic product data
|
97 |
+
'product_id' => $product->getId(),
|
98 |
+
'sku' => $product->getSku(),
|
99 |
+
'set' => $product->getAttributeSetId(),
|
100 |
+
'type' => $product->getTypeId(),
|
101 |
+
'categories' => implode(",", $productsCategories),
|
102 |
+
'category_ids' => $catData,
|
103 |
+
'websites' => implode(",", $productsWebsites),
|
104 |
+
'website_ids' => $websitesData,
|
105 |
+
'product_images' => $imagesInfo,
|
106 |
+
'quantity' => $stock->getQty(),
|
107 |
+
'is_in_stock' => $stock->getIsInStock(),
|
108 |
+
);
|
109 |
+
|
110 |
+
|
111 |
+
// lol per Vinai.. check this array. Implode if not string?
|
112 |
+
$grpAttribs = $product
|
113 |
+
->getTypeInstance(true)
|
114 |
+
->getEditableAttributes($product);
|
115 |
+
foreach ($grpAttribs as $attribute) {
|
116 |
+
if ($this->_isAllowedAttribute($attribute, $attributes)) {
|
117 |
+
$attributeCode = $attribute->getAttributeCode();
|
118 |
+
if ($attributeCode != 'category_ids') {
|
119 |
+
$attributeData = $product->getData($attributeCode);
|
120 |
+
$result[$attributeCode] = $this
|
121 |
+
->serializeArray($attributeCode, $attributeData);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
//20150128 HS: Output custom options of the the product:
|
126 |
+
if($product->hasOptions) {
|
127 |
+
$optionArray = array();
|
128 |
+
foreach ($product->getOptions() as $opt) {
|
129 |
+
//Do we support File type???
|
130 |
+
$optionArray[] = $this->jsonizeOption($opt);
|
131 |
+
}
|
132 |
+
|
133 |
+
$optArray = '[';
|
134 |
+
foreach($optionArray as $optionObj){
|
135 |
+
$optArray = $optArray . $optionObj . ', ';
|
136 |
+
}
|
137 |
+
|
138 |
+
$optArray = rtrim($optArray, ', ') . ']';
|
139 |
+
|
140 |
+
//$result['productOptions']
|
141 |
+
//= $this->serializeArray('productOptions', $optionArray);
|
142 |
+
$result['productOptions'] = $optArray;
|
143 |
+
}
|
144 |
+
|
145 |
+
unset($catData);
|
146 |
+
unset($websitesData);
|
147 |
+
unset($product);
|
148 |
+
unset($_images);
|
149 |
+
unset($stock); //release variable
|
150 |
+
|
151 |
+
return $result;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* For all version compatibility
|
156 |
+
* Return assigned images for specific stores
|
157 |
+
*
|
158 |
+
* @param Mage_Catalog_Model_Product $product
|
159 |
+
* @param int|array $storeIds
|
160 |
+
* @return array
|
161 |
+
*
|
162 |
+
*/
|
163 |
+
public function getAssignedImages($product, $storeIds)
|
164 |
+
{
|
165 |
+
if (!is_array($storeIds)) {
|
166 |
+
$storeIds = array($storeIds);
|
167 |
+
}
|
168 |
+
|
169 |
+
$mainTable = $product->getResource()->getAttribute('image')
|
170 |
+
->getBackend()
|
171 |
+
->getTable();
|
172 |
+
|
173 |
+
$resourse = Mage::getSingleton('core/resource');
|
174 |
+
|
175 |
+
$read = $resourse->getConnection('core_read');
|
176 |
+
$select = $read->select()
|
177 |
+
->from(
|
178 |
+
array('images' => $mainTable),
|
179 |
+
array('value as filepath', 'store_id')
|
180 |
+
)
|
181 |
+
->joinLeft(
|
182 |
+
array(
|
183 |
+
'attr' => $resourse->getTableName('eav/attribute')
|
184 |
+
),
|
185 |
+
'images.attribute_id = attr.attribute_id',
|
186 |
+
array('attribute_code')
|
187 |
+
)
|
188 |
+
->where('entity_id = ?', $product->getId())
|
189 |
+
->where('store_id IN (?)', $storeIds)
|
190 |
+
->where(
|
191 |
+
'attribute_code IN (?)',
|
192 |
+
array('small_image', 'thumbnail', 'image')
|
193 |
+
);
|
194 |
+
|
195 |
+
$images = $read->fetchAll($select);
|
196 |
+
return $images;
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function serializeArray($attributeCode, $attributeData)
|
200 |
+
{
|
201 |
+
if ($attributeCode == 'group_price' || $attributeCode == 'tier_price') {
|
202 |
+
return $attributeData;
|
203 |
+
}
|
204 |
+
if (is_array($attributeData) && !$this->isAssoc($attributeData)) {
|
205 |
+
//return json_encode($attributeData,JSON_FORCE_OBJECT);
|
206 |
+
$returnJson = '';
|
207 |
+
try {
|
208 |
+
//serialize the data
|
209 |
+
$returnJson = json_encode($attributeData, JSON_FORCE_OBJECT);
|
210 |
+
} catch (Exception $ex) {
|
211 |
+
Mage::log(
|
212 |
+
'[EXCEPTION] - Error Serializing: '
|
213 |
+
. serialize($attributeCode) . "; "
|
214 |
+
. serialize($attributeData) . "; Product Id: "
|
215 |
+
. (string) $this->productId,
|
216 |
+
1,
|
217 |
+
'freestyle.log'
|
218 |
+
);
|
219 |
+
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
220 |
+
Mage::log(
|
221 |
+
'JSON ERROR = ' . json_last_error(),
|
222 |
+
1,
|
223 |
+
'freestyle.log'
|
224 |
+
);
|
225 |
+
}
|
226 |
+
Mage::log(
|
227 |
+
'Message: ' . $ex->getMessage() . ' In: ' . $ex->getFile()
|
228 |
+
. '::' . $ex->getLine(),
|
229 |
+
1,
|
230 |
+
'freestyle.log'
|
231 |
+
);
|
232 |
+
$returnJson = serialize($attributeData);
|
233 |
+
}
|
234 |
+
return $returnJson;
|
235 |
+
} else {
|
236 |
+
return $attributeData;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
protected function isAssoc($array)
|
241 |
+
{
|
242 |
+
return (bool) count(array_filter(array_keys($array), 'is_string'));
|
243 |
+
}
|
244 |
+
private function serializeArray($attributeCode, $attributeData) {
|
245 |
+
if ($attributeCode == 'group_price' || $attributeCode == 'tier_price') {
|
246 |
+
return $attributeData;
|
247 |
+
}
|
248 |
+
if (is_array($attributeData) && !$this->is_assoc($attributeData)) {
|
249 |
+
//return json_encode($attributeData,JSON_FORCE_OBJECT); //serialize the data
|
250 |
+
$returnJson = '';
|
251 |
+
try {
|
252 |
+
$returnJson = json_encode($attributeData, JSON_FORCE_OBJECT); //serialize the data
|
253 |
+
} catch (Exception $ex) {
|
254 |
+
Mage::log('[EXCEPTION] - Error Serializing: ' . serialize($attributeCode) . "; " . serialize($attributeData) . "; Product Id: " . (string) $this->productId, 1, 'freestyle.log');
|
255 |
+
if (version_compare(phpversion(), '5.3.0', '>='))
|
256 |
+
Mage::log('JSON ERROR = ' . json_last_error(), 1, 'freestyle.log');
|
257 |
+
Mage::log('Message: ' . $ex->getMessage() . ' In: ' . $ex->getFile() . '::' . $ex->getLine());
|
258 |
+
$returnJson = serialize($attributeData);
|
259 |
+
}
|
260 |
+
return $returnJson;
|
261 |
+
}
|
262 |
+
else {
|
263 |
+
return $attributeData;
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
private function is_assoc($array) {
|
268 |
+
return (bool) count(array_filter(array_keys($array), 'is_string'));
|
269 |
+
}
|
270 |
+
|
271 |
+
private function jsonizeOption($option)
|
272 |
+
{
|
273 |
+
$optionType = $option->getType();
|
274 |
+
$opt = '{' . '"Title": ' . '"' . $option->getTitle() . '", ' ;
|
275 |
+
$opt = $opt . '"InputType": ' . '"' . $optionType . '", ';
|
276 |
+
$opt = $opt . '"IsRequired": ' . $option->getIsRequire() . ', ';
|
277 |
+
$opt = $opt . '"SortOrder": ' . $option->getSortOrder() . ', ';
|
278 |
+
|
279 |
+
if ($optionType !='drop_down' && $optionType != 'radio' && $optionType != 'checkbox' && $optionType != 'multiple') {
|
280 |
+
$opt = $opt . '"Price": ' . $option->getPrice() . ', ';
|
281 |
+
$opt = $opt . '"PriceType": ' . '"' . $option->getPriceType()
|
282 |
+
. '", ';
|
283 |
+
$opt = $opt . '"SKU": ' . '"' . $option->getSku() . '"';
|
284 |
+
|
285 |
+
if($optionType === 'field' || $optionType === 'area'){
|
286 |
+
$opt = $opt . ', ' . '"MaxLength": '
|
287 |
+
. $option->getMaxCharacters();
|
288 |
+
}
|
289 |
+
} else {
|
290 |
+
$opt = $opt . '"SubOptions": ' . $this->jsonizeSubOptions($option);
|
291 |
+
}
|
292 |
+
|
293 |
+
$opt = $opt . '}';
|
294 |
+
|
295 |
+
return $opt;
|
296 |
+
}
|
297 |
+
|
298 |
+
private function jsonizeSubOptions($option)
|
299 |
+
{
|
300 |
+
$values = $option->getValues();
|
301 |
+
$suboptions = '[';
|
302 |
+
foreach($values as $v) {
|
303 |
+
$suboption = '{' . '"Title": ' . '"' . $v->getTitle() . '", ';
|
304 |
+
$suboption = $suboption . '"Price": ' . $v->getPrice() . ', ';
|
305 |
+
$suboption = $suboption . '"PriceType": ' . '"'
|
306 |
+
. $v->getPriceType() . '", ';
|
307 |
+
$suboption = $suboption . '"SKU": ' . '"' . $v->getSku() . '", ';
|
308 |
+
$suboption = $suboption . '"SortOrder": ' . $v->getSortOrder()
|
309 |
+
. '}, ';
|
310 |
+
$suboptions = $suboptions . $suboption;
|
311 |
+
}
|
312 |
+
|
313 |
+
$suboptions = rtrim($suboptions, ", ") . ']';
|
314 |
+
|
315 |
+
return $suboptions;
|
316 |
+
}
|
317 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Exportmodels/SimpleXMLExtended.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Exportmodels_SimpleXMLExtended
|
12 |
+
extends SimpleXMLElement
|
13 |
+
{
|
14 |
+
public function addCData($cdataText)
|
15 |
+
{
|
16 |
+
$node= dom_import_simplexml($this);
|
17 |
+
$owner = $node->ownerDocument;
|
18 |
+
$node->appendChild($owner->createCDATASection($cdataText));
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/History.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_History extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
public function _construct()
|
14 |
+
{
|
15 |
+
parent::_construct();
|
16 |
+
$this->_init('advancedexport/history');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getLastExportData()
|
20 |
+
{
|
21 |
+
$collection = $this->getCollection();
|
22 |
+
$collection->getSelect()->order('export_date_time_start DESC');
|
23 |
+
$last = $collection->getFirstItem();
|
24 |
+
return $last;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Import/Entity/Customer.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
class Freestyle_Advancedexport_Model_Import_Entity_Customer
|
13 |
+
extends Mage_ImportExport_Model_Import_Entity_Customer
|
14 |
+
{
|
15 |
+
|
16 |
+
protected function _importData()
|
17 |
+
{
|
18 |
+
/*
|
19 |
+
$resource = Mage::getModel('customer/customer');
|
20 |
+
|
21 |
+
$table = $resource->getResource()->getEntityTable();
|
22 |
+
|
23 |
+
$nextEntityId = Mage::getResourceHelper('importexport')
|
24 |
+
->getNextAutoincrement($table);
|
25 |
+
*/
|
26 |
+
|
27 |
+
//comment out next line
|
28 |
+
Mage::Helper('advancedexport')->processPassiveMode('set_to_passive');
|
29 |
+
$emails = array();
|
30 |
+
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
|
31 |
+
foreach ($bunch as $rowData) {
|
32 |
+
if ($rowData[self::COL_EMAIL]) {
|
33 |
+
$websiteCheck = isset(
|
34 |
+
$this->_websiteCodeToId[$rowData[self::COL_WEBSITE]]
|
35 |
+
);
|
36 |
+
if ($websiteCheck && isset($rowData[self::COL_EMAIL])) {
|
37 |
+
$data = array(
|
38 |
+
'website' => $this->
|
39 |
+
_websiteCodeToId[$rowData[self::COL_WEBSITE]],
|
40 |
+
'email' => $rowData[self::COL_EMAIL]
|
41 |
+
);
|
42 |
+
$emails[] = $data;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
$testCondition =
|
48 |
+
Mage_ImportExport_Model_Import::BEHAVIOR_DELETE
|
49 |
+
== $this->getBehavior();
|
50 |
+
if ($testCondition) {
|
51 |
+
$action = 'deleted';
|
52 |
+
Mage::dispatchEvent(
|
53 |
+
'customer_custom_import_finish_before',
|
54 |
+
array(
|
55 |
+
'changedids' => $emails,
|
56 |
+
'event' => $action
|
57 |
+
)
|
58 |
+
);
|
59 |
+
$this->_deleteCustomers();
|
60 |
+
} else {
|
61 |
+
$this->_saveCustomers();
|
62 |
+
$this->_addressEntity->importData();
|
63 |
+
//$action = 'updated';
|
64 |
+
$action = 'added';
|
65 |
+
Mage::dispatchEvent(
|
66 |
+
'customer_custom_import_finish_before',
|
67 |
+
array(
|
68 |
+
'changedids' => $emails,
|
69 |
+
'event' => $action
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
//comment out next line
|
74 |
+
$passiveResults = Mage::Helper('advancedexport')
|
75 |
+
->processPassiveMode('disable_passive');
|
76 |
+
/* Send Notification */
|
77 |
+
Mage::getModel('advancedexport/passivemode')
|
78 |
+
->sendNotification($passiveResults['id']);
|
79 |
+
|
80 |
+
return true;
|
81 |
+
}
|
82 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Import/Entity/Product.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Import_Entity_Product
|
14 |
+
extends Mage_ImportExport_Model_Import_Entity_Product
|
15 |
+
{
|
16 |
+
|
17 |
+
protected function _importData()
|
18 |
+
{
|
19 |
+
$ids = array();
|
20 |
+
$skus = array();
|
21 |
+
|
22 |
+
//re-enabled 11-21-2013
|
23 |
+
Mage::Helper('advancedexport')->processPassiveMode('set_to_passive');
|
24 |
+
$behaviorTest = Mage_ImportExport_Model_Import::BEHAVIOR_DELETE
|
25 |
+
== $this->getBehavior();
|
26 |
+
if ($behaviorTest) {
|
27 |
+
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
|
28 |
+
foreach ($bunch as $rowNum => $rowData) {
|
29 |
+
$rowValidation = $this->validateRow($rowData, $rowNum);
|
30 |
+
$selfValidation = self::SCOPE_DEFAULT ==
|
31 |
+
$this->getRowScope($rowData);
|
32 |
+
if ($rowValidation && $selfValidation) {
|
33 |
+
//echo '<pre>'; print_r($rowData);
|
34 |
+
$ids [] = $this
|
35 |
+
->_oldSku[$rowData[self::COL_SKU]]['entity_id'];
|
36 |
+
}
|
37 |
+
unset($rowValidation);
|
38 |
+
unset($selfValidation);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
$action = 'deleted';
|
44 |
+
Mage::dispatchEvent(
|
45 |
+
'catalog_custom_product_import_finish_before',
|
46 |
+
array('changedids' => $ids, 'eventtype' => $action)
|
47 |
+
);
|
48 |
+
|
49 |
+
$this->_deleteProducts();
|
50 |
+
} else {
|
51 |
+
while ($bunch = $this->_dataSourceModel->getNextBunch()) {
|
52 |
+
foreach ($bunch as $rowNum => $rowData) {
|
53 |
+
$rowValidation = $this->validateRow($rowData, $rowNum);
|
54 |
+
$selfValidation = self::SCOPE_DEFAULT ==
|
55 |
+
$this->getRowScope($rowData);
|
56 |
+
if ($rowValidation && $selfValidation) {
|
57 |
+
$skus [] = $rowData[self::COL_SKU];
|
58 |
+
}
|
59 |
+
unset($rowValidation);
|
60 |
+
unset($selfValidation);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
$this->_saveProducts();
|
66 |
+
$this->_saveStockItem();
|
67 |
+
$this->_saveLinks();
|
68 |
+
$this->_saveCustomOptions();
|
69 |
+
|
70 |
+
foreach ($this->_productTypeModels as $productTypeModel) {
|
71 |
+
$productTypeModel->saveData();
|
72 |
+
}
|
73 |
+
|
74 |
+
$action = 'updated';
|
75 |
+
Mage::dispatchEvent(
|
76 |
+
'catalog_custom_product_import_finish_before',
|
77 |
+
array('changedids' => $skus, 'eventtype' => $action)
|
78 |
+
);
|
79 |
+
}
|
80 |
+
|
81 |
+
Mage::dispatchEvent(
|
82 |
+
'catalog_product_import_finish_before', array('adapter' => $this)
|
83 |
+
);
|
84 |
+
//re-enabled 11-21-2013
|
85 |
+
$passiveResults = Mage::Helper('advancedexport')
|
86 |
+
->processPassiveMode('disable_passive');
|
87 |
+
/* Send Notification */
|
88 |
+
Mage::getModel('advancedexport/passivemode')
|
89 |
+
->sendNotification($passiveResults['id']);
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Invoice/Api.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Invoice_Api
|
14 |
+
extends Mage_Api_Model_Resource_Abstract
|
15 |
+
{
|
16 |
+
public function cancapture($invoiceId)
|
17 |
+
{
|
18 |
+
try {
|
19 |
+
$invoiceModel = $this->getInvoice($invoiceId);
|
20 |
+
$result = $invoiceModel->canCapture();
|
21 |
+
} catch (Mage_Core_Exception $e) {
|
22 |
+
return $this->_fault('data_invalid', $e->getMessage());
|
23 |
+
} catch (Exception $ex) {
|
24 |
+
return $this->_fault('data_invalid', $ex->getMessage());
|
25 |
+
}
|
26 |
+
return intval($result);
|
27 |
+
}
|
28 |
+
protected function getInvoice($invoiceId)
|
29 |
+
{
|
30 |
+
return Mage::getModel('sales/order_invoice')->load($invoiceId);
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/Configuration.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_Configuration
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('advancedexport/configuration', 'id');
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/Configuration/Collection.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_Configuration_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('advancedexport/configuration');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/History.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_History
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('advancedexport/history', 'id');
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/History/Collection.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_History_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('advancedexport/history');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/Passivemode.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_Passivemode
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('advancedexport/passivemode', 'id');
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/Passivemode/Collection.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_Passivemode_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('advancedexport/passivemode');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/Queue.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_Queue
|
12 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('advancedexport/queue', 'id');
|
17 |
+
}
|
18 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Mysql4/Queue/Collection.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Mysql4_Queue_Collection
|
12 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('advancedexport/queue');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Observer.php
ADDED
@@ -0,0 +1,741 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Observer
|
14 |
+
{
|
15 |
+
|
16 |
+
public $stepErrors;
|
17 |
+
|
18 |
+
public function getIsExtEnabled()
|
19 |
+
{
|
20 |
+
return Mage::Helper('advancedexport')->getIsExtEnabledForApi();
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getFilesNames($entityToExport, $dateTimeInit)
|
24 |
+
{
|
25 |
+
$helper = Mage::Helper('advancedexport');
|
26 |
+
|
27 |
+
$currentBatchNumber = '1';
|
28 |
+
|
29 |
+
$tempfile = '[' . $helper->getChanelName() . ']_'
|
30 |
+
. '[' . $helper->getChanelId() . ']_'
|
31 |
+
. '[' . $entityToExport . ']_'
|
32 |
+
. '[' . $dateTimeInit . ']_'
|
33 |
+
. '[batch-' . $currentBatchNumber . '].xml';
|
34 |
+
$fileFullPath = Mage::getBaseDir() . DS .
|
35 |
+
Mage::Helper('advancedexport')->getExportfolder() . DS .
|
36 |
+
$tempfile;
|
37 |
+
|
38 |
+
$zipFile = '[' . $helper->getChanelName() . ']_'
|
39 |
+
. '[' . $helper->getChanelId() . ']_'
|
40 |
+
. '[' . $entityToExport . ']_'
|
41 |
+
. '[' . $dateTimeInit . ']';
|
42 |
+
$zipFileFullPath = Mage::getBaseDir() . DS .
|
43 |
+
Mage::Helper('advancedexport')->getExportfolder() . DS .
|
44 |
+
$zipFile;
|
45 |
+
|
46 |
+
return array(
|
47 |
+
'fileName' => $tempfile,
|
48 |
+
'filePath' => $fileFullPath,
|
49 |
+
'zipFileName' => $zipFile,
|
50 |
+
'zipFilePath' => $zipFileFullPath
|
51 |
+
);
|
52 |
+
}
|
53 |
+
|
54 |
+
public function productSaveAfter($observer)
|
55 |
+
{
|
56 |
+
if (!$this->getIsExtEnabled()) {
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
//prevent non-extension API call from triggering notification
|
60 |
+
$product = $observer->getProduct();
|
61 |
+
Mage::log(
|
62 |
+
"[INFO] - [productSaveAfter] File generation "
|
63 |
+
. "for SKU [$product->sku].",
|
64 |
+
1,
|
65 |
+
'freestyle.log'
|
66 |
+
);
|
67 |
+
if ($this->getIsApiRunning()) {
|
68 |
+
Mage::log(
|
69 |
+
"[INFO] - [productSaveAfter] File generation skipped "
|
70 |
+
. "for SKU [$product->sku]. API Call...",
|
71 |
+
1,
|
72 |
+
'freestyle.log'
|
73 |
+
);
|
74 |
+
return true;
|
75 |
+
}
|
76 |
+
$entityToExport = 'product';
|
77 |
+
//$action = 'updated';
|
78 |
+
$action = 'added';
|
79 |
+
|
80 |
+
|
81 |
+
$entityId = $product->getEntityId();
|
82 |
+
$sku = $product->getSku();
|
83 |
+
|
84 |
+
//DE-8384 - Multi-Store Support
|
85 |
+
$storeId = Mage::app()->getRequest()->getParam('store');
|
86 |
+
if (is_null($storeId)) {
|
87 |
+
//it was saved in the default scope..
|
88 |
+
//$store_scopes= $product->getStoreIds();
|
89 |
+
$storeScopes = $product->getWebsiteIds();
|
90 |
+
} else {
|
91 |
+
$storeScopes = array($this->getWebsiteIdfromStoreId($storeId));
|
92 |
+
}
|
93 |
+
|
94 |
+
foreach ($storeScopes as $scopeval) {
|
95 |
+
$this->pushData(
|
96 |
+
$entityToExport,
|
97 |
+
$entityId,
|
98 |
+
$action,
|
99 |
+
null,
|
100 |
+
$sku,
|
101 |
+
'website',
|
102 |
+
$scopeval
|
103 |
+
);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
public function productDeleteBefore($observer)
|
108 |
+
{
|
109 |
+
if (!$this->getIsExtEnabled()) {
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
//prevent non-extension API call from triggering notification
|
113 |
+
$product = $observer->getProduct();
|
114 |
+
if ($this->getIsApiRunning()) {
|
115 |
+
Mage::log(
|
116 |
+
"[INFO] - [productDeleteBefore] File generation skipped "
|
117 |
+
. "for SKU [$product->sku]. API Call...",
|
118 |
+
1,
|
119 |
+
'freestyle.log'
|
120 |
+
);
|
121 |
+
//return false;
|
122 |
+
return true;
|
123 |
+
}
|
124 |
+
$entityToExport = 'product';
|
125 |
+
$action = 'deleted';
|
126 |
+
|
127 |
+
//DE-8384 - Multi-Store Support
|
128 |
+
$storeId = Mage::app()->getRequest()->getParam('store');
|
129 |
+
//$website_id = $this->getWebsiteIdfromStoreId($store_id); /* unused */
|
130 |
+
|
131 |
+
$entityId = $product->getEntityId();
|
132 |
+
$sku = $product->getSku();
|
133 |
+
$this->pushData(
|
134 |
+
$entityToExport,
|
135 |
+
$entityId,
|
136 |
+
$action,
|
137 |
+
null,
|
138 |
+
$sku,
|
139 |
+
'store',
|
140 |
+
$storeId
|
141 |
+
); //convert this later
|
142 |
+
}
|
143 |
+
|
144 |
+
public function productSaveAfterStandartImport($observer)
|
145 |
+
{
|
146 |
+
if (!$this->getIsExtEnabled()) {
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
//prevent non-extension API call from triggering notification
|
150 |
+
if ($this->getIsApiRunning()) {
|
151 |
+
Mage::log(
|
152 |
+
"[INFO] - [productSaveAfterStandartImport] File generation "
|
153 |
+
. "skipped. API Call...",
|
154 |
+
1,
|
155 |
+
'freestyle.log'
|
156 |
+
);
|
157 |
+
//return false;
|
158 |
+
return true;
|
159 |
+
}
|
160 |
+
$entityToExport = 'product';
|
161 |
+
$action = $observer->getEventtype();
|
162 |
+
|
163 |
+
$productsIds = $observer->getChangedids();
|
164 |
+
|
165 |
+
foreach ($productsIds as $entityId) {
|
166 |
+
$realId = $entityId;
|
167 |
+
$productModel = Mage::getModel('catalog/product')
|
168 |
+
->loadByAttribute('sku', $entityId);
|
169 |
+
if ($action == 'updated') {
|
170 |
+
$realId = $productModel->getId();
|
171 |
+
}
|
172 |
+
|
173 |
+
//DE-8384 - Multi-Store Support
|
174 |
+
$storeScopes = $productModel->getWebsiteIds();
|
175 |
+
foreach ($storeScopes as $scopeval) {
|
176 |
+
$this->pushData(
|
177 |
+
$entityToExport,
|
178 |
+
$realId,
|
179 |
+
$action,
|
180 |
+
null,
|
181 |
+
$entityId,
|
182 |
+
'website',
|
183 |
+
$scopeval
|
184 |
+
);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
public function categorySaveAfter($observer)
|
190 |
+
{
|
191 |
+
if (!$this->getIsExtEnabled()) {
|
192 |
+
return false;
|
193 |
+
}
|
194 |
+
//prevent non-extension API call from triggering notification
|
195 |
+
if ($this->getIsApiRunning()) {
|
196 |
+
Mage::log(
|
197 |
+
"[INFO] - [categorySaveAfter] File generation skipped. "
|
198 |
+
. "API Call...",
|
199 |
+
1,
|
200 |
+
'freestyle.log'
|
201 |
+
);
|
202 |
+
//return false;
|
203 |
+
return true;
|
204 |
+
}
|
205 |
+
$entityToExport = 'category';
|
206 |
+
$action = 'added';
|
207 |
+
|
208 |
+
$category = $observer->getCategory();
|
209 |
+
$entityId = $category->getEntityId();
|
210 |
+
|
211 |
+
$this->pushData($entityToExport, $entityId, $action);
|
212 |
+
}
|
213 |
+
|
214 |
+
public function categoryDeleteBefore($observer)
|
215 |
+
{
|
216 |
+
if (!$this->getIsExtEnabled()) {
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
//prevent non-extension API call from triggering notification
|
220 |
+
if ($this->getIsApiRunning()) {
|
221 |
+
Mage::log(
|
222 |
+
"[INFO] - [categoryDeleteBefore] File generation skipped."
|
223 |
+
. " API Call...",
|
224 |
+
1,
|
225 |
+
'freestyle.log'
|
226 |
+
);
|
227 |
+
//return false;
|
228 |
+
return true;
|
229 |
+
}
|
230 |
+
$entityToExport = 'category';
|
231 |
+
$action = 'deleted';
|
232 |
+
|
233 |
+
$category = $observer->getCategory();
|
234 |
+
$entityId = $category->getEntityId();
|
235 |
+
|
236 |
+
$this->pushData($entityToExport, $entityId, $action);
|
237 |
+
}
|
238 |
+
|
239 |
+
public function customerSaveAfter($observer)
|
240 |
+
{
|
241 |
+
if (!$this->getIsExtEnabled()) {
|
242 |
+
return false;
|
243 |
+
}
|
244 |
+
//prevent non-extension API call from triggering notification
|
245 |
+
$customer = $observer->getCustomer();
|
246 |
+
if ($this->getIsApiRunning()) {
|
247 |
+
Mage::log(
|
248 |
+
"[INFO] - [customerSaveAfter] File generation skipped "
|
249 |
+
. "for Customer ID [$customer->entity_id]. API Call...",
|
250 |
+
1,
|
251 |
+
'freestyle.log'
|
252 |
+
);
|
253 |
+
//return false;
|
254 |
+
return true;
|
255 |
+
}
|
256 |
+
Mage::log(
|
257 |
+
"[INFO] - [customerSaveAfter] File generation for "
|
258 |
+
. "Customer ID [$customer->entity_id].",
|
259 |
+
1,
|
260 |
+
'freestyle.log'
|
261 |
+
);
|
262 |
+
|
263 |
+
$entityToExport = 'customer';
|
264 |
+
$action = 'added';
|
265 |
+
|
266 |
+
$entityId = $customer->getEntityId();
|
267 |
+
|
268 |
+
//DE-8384 - Multi-Store Support
|
269 |
+
//$store_id = Mage::app()->getRequest()->getParam('store');
|
270 |
+
//$website_id = $this->getWebsiteIdfromStoreId($store_id);
|
271 |
+
$websiteId = $customer->getWebsiteId();
|
272 |
+
|
273 |
+
$this->pushData(
|
274 |
+
$entityToExport,
|
275 |
+
$entityId,
|
276 |
+
$action,
|
277 |
+
null,
|
278 |
+
$customer->getName(),
|
279 |
+
'website',
|
280 |
+
$websiteId
|
281 |
+
);
|
282 |
+
}
|
283 |
+
|
284 |
+
public function customerDeleteBefore($observer)
|
285 |
+
{
|
286 |
+
if (!$this->getIsExtEnabled()) {
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
//prevent non-extension API call from triggering notification
|
290 |
+
$customer = $observer->getCustomer();
|
291 |
+
if ($this->getIsApiRunning()) {
|
292 |
+
Mage::log(
|
293 |
+
"[INFO] - [customerDeleteBefore] File generation skipped "
|
294 |
+
. "for Customer ID [$customer->entity_id]. API Call...",
|
295 |
+
1,
|
296 |
+
'freestyle.log'
|
297 |
+
);
|
298 |
+
//return false;
|
299 |
+
return true;
|
300 |
+
}
|
301 |
+
$entityToExport = 'customer';
|
302 |
+
$action = 'deleted';
|
303 |
+
|
304 |
+
$entityId = $customer->getEntityId();
|
305 |
+
|
306 |
+
//DE-8384 - Multi-Store Support
|
307 |
+
$storeId = Mage::app()->getRequest()->getParam('store');
|
308 |
+
$websiteId = $this->getWebsiteIdfromStoreId($storeId);
|
309 |
+
|
310 |
+
$this->pushData(
|
311 |
+
$entityToExport,
|
312 |
+
$entityId,
|
313 |
+
$action,
|
314 |
+
null,
|
315 |
+
$customer->getName(),
|
316 |
+
'website',
|
317 |
+
$websiteId
|
318 |
+
);
|
319 |
+
}
|
320 |
+
|
321 |
+
public function customerAddressSaveAfter($observer)
|
322 |
+
{
|
323 |
+
if (!$this->getIsExtEnabled()) {
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
//prevent non-extension API call from triggering notification
|
327 |
+
if ($this->getIsApiRunning()) {
|
328 |
+
Mage::log(
|
329 |
+
"[INFO] - [customerAddressSaveAfter] File generation skipped. "
|
330 |
+
. "API Call...",
|
331 |
+
1,
|
332 |
+
'freestyle.log'
|
333 |
+
);
|
334 |
+
//return false;
|
335 |
+
return true;
|
336 |
+
}
|
337 |
+
$entityToExport = 'customer';
|
338 |
+
$action = 'added';
|
339 |
+
|
340 |
+
$address = $observer->getCustomerAddress();
|
341 |
+
$customer = $address->getCustomer();
|
342 |
+
$entityId = $customer->getEntityId();
|
343 |
+
|
344 |
+
//DE-8384 - Multi-Store Support
|
345 |
+
$websiteId = $customer->getWebsiteId();
|
346 |
+
|
347 |
+
$this->pushData(
|
348 |
+
$entityToExport,
|
349 |
+
$entityId,
|
350 |
+
$action,
|
351 |
+
null,
|
352 |
+
$customer->getName(),
|
353 |
+
'website',
|
354 |
+
$websiteId
|
355 |
+
);
|
356 |
+
}
|
357 |
+
|
358 |
+
public function customerSaveAfterStandartImport($observer)
|
359 |
+
{
|
360 |
+
if (!$this->getIsExtEnabled()) {
|
361 |
+
return false;
|
362 |
+
}
|
363 |
+
//prevent non-extension API call from triggering notification
|
364 |
+
if ($this->getIsApiRunning()) {
|
365 |
+
Mage::log(
|
366 |
+
"[INFO] - [customerSaveAfterStandartImport] File "
|
367 |
+
. "generation skipped. API Call...",
|
368 |
+
1,
|
369 |
+
'freestyle.log'
|
370 |
+
);
|
371 |
+
//return false;
|
372 |
+
return true;
|
373 |
+
}
|
374 |
+
$entityToExport = 'customer';
|
375 |
+
$action = $observer->getEvent();
|
376 |
+
|
377 |
+
$customersIds = $observer->getChangedids();
|
378 |
+
|
379 |
+
$customerModel = Mage::getModel('customer/customer');
|
380 |
+
//echo '<pre>'; print_r($customersIds);
|
381 |
+
foreach ($customersIds as $info) {
|
382 |
+
$entityId = $customerModel
|
383 |
+
->setWebsiteId($info['website'])
|
384 |
+
->loadByEmail($info['email'])->getId();
|
385 |
+
if ($entityId) {
|
386 |
+
$websiteId = $customerModel->getWebsiteId();
|
387 |
+
$this->pushData(
|
388 |
+
$entityToExport,
|
389 |
+
$entityId,
|
390 |
+
$action,
|
391 |
+
null,
|
392 |
+
$customerModel->getName(),
|
393 |
+
'website',
|
394 |
+
$websiteId
|
395 |
+
);
|
396 |
+
}
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
public function getOrderCutOff()
|
401 |
+
{
|
402 |
+
return strtotime(Mage::Helper('advancedexport')->getOrderCutOffDate());
|
403 |
+
}
|
404 |
+
|
405 |
+
public function orderSaveAfter($observer)
|
406 |
+
{
|
407 |
+
if (!$this->getIsExtEnabled()) {
|
408 |
+
return false;
|
409 |
+
}
|
410 |
+
//prevent non-extension API call from triggering notification
|
411 |
+
$order = $observer->getOrder();
|
412 |
+
if ($this->getIsApiRunning()) {
|
413 |
+
Mage::log(
|
414 |
+
"[INFO] - [orderSaveAfter] File generation "
|
415 |
+
. "skipped for Order [$order->increment_id]. API Call...",
|
416 |
+
1,
|
417 |
+
'freestyle.log'
|
418 |
+
);
|
419 |
+
//return false;
|
420 |
+
return true;
|
421 |
+
}
|
422 |
+
|
423 |
+
//DE-10071 - compare cutoff date and current date as time values
|
424 |
+
$cutOff = $this->getOrderCutOff();
|
425 |
+
|
426 |
+
if (!is_null($cutOff) && !is_bool($cutOff)) {
|
427 |
+
$currentOrderTime = strtotime($order->created_at);
|
428 |
+
if ($currentOrderTime <= $cutOff) {
|
429 |
+
Mage::log(
|
430 |
+
"[INFO] - [orderSaveAfter] File generation "
|
431 |
+
. "skipped for Order [$order->increment_id]. Prior to "
|
432 |
+
. date('Y-m-d', $cutOff) . " cutoff date",
|
433 |
+
1,
|
434 |
+
'freestyle.log'
|
435 |
+
);
|
436 |
+
return true;
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
$entityToExport = 'order';
|
441 |
+
$action = 'added';
|
442 |
+
|
443 |
+
//attempt to write the real order id instead
|
444 |
+
if (Mage::helper('advancedexport/queue')->getEnableQueue()) {
|
445 |
+
$entityId = $order->getId();
|
446 |
+
} else {
|
447 |
+
$entityId = $order->getIncrementId();
|
448 |
+
}
|
449 |
+
|
450 |
+
|
451 |
+
$history = $order->getAllStatusHistory();
|
452 |
+
|
453 |
+
//TODO: grab which store this order is for!!
|
454 |
+
if (!empty($history)) {
|
455 |
+
$orderStatus = $order->getStatus();
|
456 |
+
$storeId = $order->getStoreId();
|
457 |
+
$websiteId = $this->getWebsiteIdfromStoreId($storeId);
|
458 |
+
|
459 |
+
if (strtoupper($orderStatus) == "COMPLETED") {
|
460 |
+
$this->pushData(
|
461 |
+
$entityToExport,
|
462 |
+
$entityId,
|
463 |
+
$action,
|
464 |
+
$order,
|
465 |
+
$order->getIncrementId(),
|
466 |
+
'website',
|
467 |
+
$websiteId
|
468 |
+
);
|
469 |
+
} else {
|
470 |
+
$this->pushData(
|
471 |
+
$entityToExport,
|
472 |
+
$entityId,
|
473 |
+
$action,
|
474 |
+
null,
|
475 |
+
$order->getIncrementId(),
|
476 |
+
'website',
|
477 |
+
$websiteId
|
478 |
+
);
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}
|
482 |
+
|
483 |
+
public function mediaSaveAfter($observer)
|
484 |
+
{
|
485 |
+
if (!$this->getIsExtEnabled()) {
|
486 |
+
return false;
|
487 |
+
}
|
488 |
+
//prevent non-extension API call from triggering notification
|
489 |
+
$product = $observer->getProduct();
|
490 |
+
if ($this->getIsApiRunning()) {
|
491 |
+
Mage::log(
|
492 |
+
"[INFO] - [productDeleteBefore] File generation "
|
493 |
+
. "skipped for SKU [$product->sku]. API Call...",
|
494 |
+
1,
|
495 |
+
'freestyle.log'
|
496 |
+
);
|
497 |
+
//return false;
|
498 |
+
return true;
|
499 |
+
}
|
500 |
+
$entityToExport = 'product';
|
501 |
+
$action = 'image';
|
502 |
+
|
503 |
+
|
504 |
+
$entityId = $product->getEntityId();
|
505 |
+
$sku = $product->getSku();
|
506 |
+
$this->pushData($entityToExport, $entityId, $action, null, $sku);
|
507 |
+
}
|
508 |
+
|
509 |
+
public function getIsApiRunning()
|
510 |
+
{
|
511 |
+
$helper = Mage::helper('advancedexport/queue');
|
512 |
+
$ignoreApiCalls = $helper->getIgnoreApi() == 1;
|
513 |
+
if ($helper->getEnableQueue() == 0) {
|
514 |
+
//queue is disabled... always ignore api calls
|
515 |
+
$ignoreApiCalls = true;
|
516 |
+
}
|
517 |
+
|
518 |
+
$isApiRunning = false;
|
519 |
+
|
520 |
+
if ($ignoreApiCalls) {
|
521 |
+
//do not ignore api calls
|
522 |
+
$isApiRunning =
|
523 |
+
Mage::getSingleton('api/server')->getAdapter() != null;
|
524 |
+
}
|
525 |
+
|
526 |
+
return $isApiRunning;
|
527 |
+
}
|
528 |
+
|
529 |
+
protected function pushData(
|
530 |
+
$entityToExport,
|
531 |
+
$entityId,
|
532 |
+
$action,
|
533 |
+
$order = null,
|
534 |
+
$entityValue = '',
|
535 |
+
$scope = 'website',
|
536 |
+
$scopeId = 1
|
537 |
+
)
|
538 |
+
{
|
539 |
+
//$store_website_id = Mage::app()->getStore()->getWebsiteId();
|
540 |
+
//$store_website_id = Mage::app()->getWebsite()->getId();
|
541 |
+
// //To Get the current store
|
542 |
+
// $store = Mage::app()->getStore();
|
543 |
+
// //To get Store Id
|
544 |
+
// $store_id = Mage::app()->getStore()->getStoreId();
|
545 |
+
// //To get Store Code
|
546 |
+
// $store_code = Mage::app()->getStore()->getCode();
|
547 |
+
// //To get Website Id
|
548 |
+
// $store_website_id = Mage::app()->getStore()->getWebsiteId();
|
549 |
+
// //To get Store Name
|
550 |
+
// $store_name = Mage::app()->getStore()->getName();
|
551 |
+
// //To get Store Status
|
552 |
+
// $store_status = Mage::app()->getStore()->getIsActive();
|
553 |
+
// //To get Store Home Url
|
554 |
+
// $store_home_url = Mage::app()->getStore()->getHomeUrl();
|
555 |
+
// //To get current running website id
|
556 |
+
// $website_id = Mage::app()->getWebsite()->getId();
|
557 |
+
$helper = Mage::Helper('advancedexport/queue');
|
558 |
+
$isStoreSupported = Mage::Helper('advancedexport/website')
|
559 |
+
->isWebSiteStoreViewSupported($scopeId);
|
560 |
+
if ($isStoreSupported) {
|
561 |
+
if ($helper->getEnableQueue()) {
|
562 |
+
$queueModel = Mage::getModel('advancedexport/queue');
|
563 |
+
$scope = ($scopeId === null) ? 'default' : $scope;
|
564 |
+
$scopeId = ($scopeId === null) ? 0 : $scopeId;
|
565 |
+
|
566 |
+
//$scope_id = Mage::app()->getRequest()->getParam('store');
|
567 |
+
$queueModel = $queueModel->addToQueue(
|
568 |
+
$entityToExport,
|
569 |
+
$entityId,
|
570 |
+
$action,
|
571 |
+
$entityValue,
|
572 |
+
$scope,
|
573 |
+
$scopeId
|
574 |
+
);
|
575 |
+
//echo $queueModel->getId();
|
576 |
+
if (!$helper->getSendAsync()) {
|
577 |
+
//send this one record immediately...
|
578 |
+
$queueModel->sendMixCollection(1, $queueModel->getId());
|
579 |
+
}
|
580 |
+
} else {
|
581 |
+
if ($scope === 'store' && $entityToExport != 'product') {
|
582 |
+
$scope = 'website'; //overwrite
|
583 |
+
$scopeId = $this->getWebsiteIdfromStoreId($scopeId);
|
584 |
+
}
|
585 |
+
$this->sendNow(
|
586 |
+
$entityToExport,
|
587 |
+
$entityId,
|
588 |
+
$action,
|
589 |
+
$order,
|
590 |
+
$scopeId
|
591 |
+
);
|
592 |
+
}
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
public function getWebsiteIdfromStoreId($storeId = 1)
|
597 |
+
{
|
598 |
+
return Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
599 |
+
}
|
600 |
+
|
601 |
+
protected function sendNow(
|
602 |
+
$entityToExport,
|
603 |
+
$entityId,
|
604 |
+
$action,
|
605 |
+
$order = NULL,
|
606 |
+
$scopeValue = null
|
607 |
+
)
|
608 |
+
{
|
609 |
+
//$zipFile = $this
|
610 |
+
//->generateAndSaveExportFile($entityToExport, $entityId, $action);
|
611 |
+
$zipFile = Mage::helper('advancedexport')
|
612 |
+
->generateAndSaveExportFile(
|
613 |
+
$entityToExport,
|
614 |
+
$entityId,
|
615 |
+
$action,
|
616 |
+
$order,
|
617 |
+
$scopeValue
|
618 |
+
);
|
619 |
+
$enabledPassive = Mage::getModel('advancedexport/passivemode')
|
620 |
+
->getIsPassiveEnabled();
|
621 |
+
if (!$enabledPassive) {
|
622 |
+
Mage::helper('advancedexport/notificationSender')
|
623 |
+
->sendNotification(
|
624 |
+
$entityToExport,
|
625 |
+
$entityId,
|
626 |
+
$zipFile,
|
627 |
+
$action,
|
628 |
+
$scopeValue
|
629 |
+
);
|
630 |
+
}
|
631 |
+
}
|
632 |
+
|
633 |
+
public function customergroupSaveAfter($observer)
|
634 |
+
{
|
635 |
+
$customerGroup = $observer->getEvent()->getObject();
|
636 |
+
$this->pushCustomerGroupData($customerGroup, 'customergroupSaveAfter');
|
637 |
+
}
|
638 |
+
|
639 |
+
public function customergroupDeleteBefore($observer)
|
640 |
+
{
|
641 |
+
if (!$this->getIsExtEnabled()) {
|
642 |
+
return false;
|
643 |
+
}
|
644 |
+
//prevent non-extension API call from triggering notification
|
645 |
+
if ($this->getIsApiRunning()) {
|
646 |
+
Mage::log(
|
647 |
+
"[customergroupDeleteBefore] File generation skipped. "
|
648 |
+
. "API Call..." ,
|
649 |
+
1,
|
650 |
+
'freestyle.log'
|
651 |
+
);
|
652 |
+
return true;
|
653 |
+
}
|
654 |
+
|
655 |
+
$entityToExport = 'customergroup';
|
656 |
+
$action = 'deleted';
|
657 |
+
|
658 |
+
$customerGroup = $observer->getEvent()->getObject();
|
659 |
+
$customerGroupId = $customerGroup->getCustomerGroupId();
|
660 |
+
$customerGroupCode = $customerGroup->getCustomerGroupCode();
|
661 |
+
|
662 |
+
$this->pushData(
|
663 |
+
$entityToExport,
|
664 |
+
$customerGroupId,
|
665 |
+
$action,
|
666 |
+
NULL,
|
667 |
+
$customerGroupCode
|
668 |
+
);
|
669 |
+
}
|
670 |
+
|
671 |
+
public function systemConfigChangedSectionCustomer($observer)
|
672 |
+
{
|
673 |
+
$this->handleDefaultCustomerGroupUpdate();
|
674 |
+
}
|
675 |
+
|
676 |
+
private function handleDefaultCustomerGroupUpdate()
|
677 |
+
{
|
678 |
+
$pushDataToQueue = false;
|
679 |
+
$newDefaultCustomerGroupdId =
|
680 |
+
Mage::getStoreConfig('customer/create_account/default_group');
|
681 |
+
$tokenModel = Mage::getModel('advancedexport/configuration')
|
682 |
+
->load('default_customer_group', 'config_code');
|
683 |
+
|
684 |
+
if ($tokenModel->getId()) {
|
685 |
+
$oldDefaultCustomerGroupId = $tokenModel->getConfigValue();
|
686 |
+
if ($newDefaultCustomerGroupdId != $oldDefaultCustomerGroupId) {
|
687 |
+
$tokenModel->setConfigValue($newDefaultCustomerGroupdId);
|
688 |
+
$tokenModel->save();
|
689 |
+
$pushDataToQueue = true;
|
690 |
+
}
|
691 |
+
} else {
|
692 |
+
$data = array();
|
693 |
+
$newConfData = Mage::getModel('advancedexport/configuration');
|
694 |
+
$data['config_code'] = 'default_customer_group';
|
695 |
+
$data['config_value'] = $newDefaultCustomerGroupdId;
|
696 |
+
$newConfData->setData($data);
|
697 |
+
$newConfData->save();
|
698 |
+
$pushDataToQueue = true;
|
699 |
+
}
|
700 |
+
|
701 |
+
if ($pushDataToQueue) {
|
702 |
+
$customerGroup = Mage::getModel('customer/group')
|
703 |
+
->load($newDefaultCustomerGroupdId);
|
704 |
+
$this->pushCustomerGroupData(
|
705 |
+
$customerGroup,
|
706 |
+
'systemConfigChangedSectionCustomer_CustomerGroup'
|
707 |
+
);
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
private function pushCustomerGroupData($customerGroup, $source)
|
712 |
+
{
|
713 |
+
if (!$this->getIsExtEnabled()) {
|
714 |
+
return false;
|
715 |
+
}
|
716 |
+
//prevent non-extension API call from triggering notification
|
717 |
+
if ($this->getIsApiRunning()) {
|
718 |
+
Mage::log(
|
719 |
+
"[$source] File generation skipped. API Call...",
|
720 |
+
1,
|
721 |
+
'freestyle.log'
|
722 |
+
);
|
723 |
+
return true;
|
724 |
+
}
|
725 |
+
|
726 |
+
$entityToExport = 'customergroup';
|
727 |
+
$action = 'added';
|
728 |
+
|
729 |
+
$customerGroupId = $customerGroup->getCustomerGroupId();
|
730 |
+
$customerGroupCode = $customerGroup->getCustomerGroupCode();
|
731 |
+
|
732 |
+
$this->pushData(
|
733 |
+
$entityToExport,
|
734 |
+
$customerGroupId,
|
735 |
+
$action,
|
736 |
+
NULL,
|
737 |
+
$customerGroupCode
|
738 |
+
);
|
739 |
+
}
|
740 |
+
|
741 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Order.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Order extends Mage_Sales_Model_Order
|
14 |
+
{
|
15 |
+
public function canInvoiceReason()
|
16 |
+
{
|
17 |
+
$reason = array(
|
18 |
+
canUnhold => 0,
|
19 |
+
isPaymentReview => 0,
|
20 |
+
isCanceled => 0,
|
21 |
+
isCompleteState => 0,
|
22 |
+
isClosedState => 0,
|
23 |
+
actionFlagIsInvoice => 0,
|
24 |
+
someItemsAreInvoiced => 1,
|
25 |
+
unknownError => 0
|
26 |
+
);
|
27 |
+
$reason['canUnhold'] = intval($this->canUnhold());
|
28 |
+
$reason['isPaymentReview'] = intval($this->isPaymentReview());
|
29 |
+
|
30 |
+
$state = $this->getState();
|
31 |
+
$reason['isCanceled'] = intval($this->isCanceled());
|
32 |
+
$reason['isCompleteState'] = intval($state === self::STATE_COMPLETE);
|
33 |
+
|
34 |
+
$reason['actionFlagIsInvoice'] =
|
35 |
+
intval($this->getActionFlag(self::ACTION_FLAG_INVOICE) === false);
|
36 |
+
|
37 |
+
foreach ($this->getAllItems() as $item) {
|
38 |
+
if ($item->getQtyToInvoice()>0 && !$item->getLockedDoInvoice()) {
|
39 |
+
$reason['someItemsAreInvoiced'] = 0;
|
40 |
+
break;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
if ($this->canUnhold() || $this->isPaymentReview()) {
|
45 |
+
return $reason;
|
46 |
+
}
|
47 |
+
|
48 |
+
$reasonCheck = $this->isCanceled()
|
49 |
+
|| $state === self::STATE_COMPLETE
|
50 |
+
|| $state === self::STATE_CLOSED;
|
51 |
+
if ($reasonCheck) {
|
52 |
+
return $reason;
|
53 |
+
}
|
54 |
+
|
55 |
+
if ($this->getActionFlag(self::ACTION_FLAG_INVOICE) === false) {
|
56 |
+
return $reason;
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($reason['someItemsAreInvoice'] == 1) {
|
60 |
+
return $reason;
|
61 |
+
}
|
62 |
+
|
63 |
+
$reason['unknownError'] = 1;
|
64 |
+
return $reason;
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Order/Api.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Order_Api
|
14 |
+
extends Mage_Sales_Model_Order_Api
|
15 |
+
{
|
16 |
+
// Mage_Sales_Model_Api_Resource {//Mage_Api_Model_Resource_Abstract {
|
17 |
+
public function canInvoice($orderId)
|
18 |
+
{
|
19 |
+
try {
|
20 |
+
$orderModel = $this->getOrder($orderId);
|
21 |
+
$result = $orderModel->canInvoice();
|
22 |
+
} catch (Mage_Core_Exception $e) {
|
23 |
+
$this->_fault('data_invalid', $e->getMessage());
|
24 |
+
} catch (Exception $ex) {
|
25 |
+
$this->_fault('data_invalid', $ex->getMessage());
|
26 |
+
}
|
27 |
+
return intval($result);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function canShip($orderId)
|
31 |
+
{
|
32 |
+
try {
|
33 |
+
$orderModel = $this->getOrder($orderId);
|
34 |
+
$result = $orderModel->canShip();
|
35 |
+
} catch (Mage_Core_Exception $e) {
|
36 |
+
$this->_fault('data_invalid', $e->getMessage());
|
37 |
+
} catch (Exception $ex) {
|
38 |
+
$this->_fault('data_invalid', $e->getMessage());
|
39 |
+
}
|
40 |
+
return intval($result);
|
41 |
+
}
|
42 |
+
|
43 |
+
public function canCreditMemo($orderId)
|
44 |
+
{
|
45 |
+
try {
|
46 |
+
$orderModel = $this->getOrder($orderId);
|
47 |
+
$result = $orderModel->canCreditMemo();
|
48 |
+
} catch (Mage_Core_Exception $e) {
|
49 |
+
$this->_fault('data_invalid', $e->getMessage());
|
50 |
+
} catch (Exception $ex) {
|
51 |
+
$this->_fault('data_invalid', $e->getMessage());
|
52 |
+
}
|
53 |
+
return intval($result);
|
54 |
+
}
|
55 |
+
|
56 |
+
public function checkactions($orderId)
|
57 |
+
{
|
58 |
+
$result = array();
|
59 |
+
try {
|
60 |
+
//$orderModel = $this->getOrder($orderId);
|
61 |
+
$orderModel = $this->getOrder();
|
62 |
+
$orderModel->load($orderId);
|
63 |
+
$result['canInvoice'] = $orderModel->canInvoice();
|
64 |
+
$result['canShip'] = $orderModel->canShip();
|
65 |
+
$result['canCreditMemo'] = $orderModel->canCreditMemo();
|
66 |
+
$result['canEdit'] = $orderModel->canEdit();
|
67 |
+
$result['canCancel'] = $orderModel->canCancel();
|
68 |
+
} catch (Mage_Core_Exception $e) {
|
69 |
+
$this->_fault('data_invalid', $e->getMessage());
|
70 |
+
} catch (Exception $ex) {
|
71 |
+
$this->_fault('data_invalid', $e->getMessage());
|
72 |
+
}
|
73 |
+
if (!$orderModel->getId()) {
|
74 |
+
$this->_fault('not_exists', "Order Id not found.");
|
75 |
+
}
|
76 |
+
$result = array($result, $orderModel->canInvoiceReason());
|
77 |
+
return $result;
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
//protected function getOrder($orderId)
|
82 |
+
protected function getOrder()
|
83 |
+
{
|
84 |
+
//return Mage::getModel('sales/order')->load($orderId);
|
85 |
+
return Mage::getModel('freestyle_utilities/order');//->load($orderId);
|
86 |
+
}
|
87 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Order/V2.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
class Freestyle_Advancedexport_Model_Order_Api_V2
|
12 |
+
extends Freestyle_Utilities_Model_Order_Api
|
13 |
+
{
|
14 |
+
//no implementation
|
15 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Passivemode.php
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Passivemode
|
14 |
+
extends Mage_Core_Model_Abstract
|
15 |
+
{
|
16 |
+
|
17 |
+
public function _construct()
|
18 |
+
{
|
19 |
+
parent::_construct();
|
20 |
+
$this->_init('advancedexport/passivemode');
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getIsPassiveEnabled()
|
24 |
+
{
|
25 |
+
$passiveEnabled = $this->getCollection()
|
26 |
+
->addFieldToFilter('passivemod_enabled', array('eq' => '1'));
|
27 |
+
if ($passiveEnabled->count()) {
|
28 |
+
return true;
|
29 |
+
}
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getEnabledId()
|
34 |
+
{
|
35 |
+
$passiveEnabled = $this->getCollection()
|
36 |
+
->addFieldToFilter('passivemod_enabled', array('eq' => '1'));
|
37 |
+
if ($passiveEnabled->count()) {
|
38 |
+
return $passiveEnabled->getLastItem()->getId();
|
39 |
+
}
|
40 |
+
return false;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function addFileDataToCollector($filesToAdd)
|
44 |
+
{
|
45 |
+
if (isset($filesToAdd['zipFilePath'])) {
|
46 |
+
unset($filesToAdd['zipFilePath']);
|
47 |
+
}
|
48 |
+
//echo '<pre>'; print_r($filesToAdd);
|
49 |
+
$passiveModeDataCollcetor = $this->load($this->getEnabledId());
|
50 |
+
$data = $passiveModeDataCollcetor->getData();
|
51 |
+
$files = unserialize($data['created_files']);
|
52 |
+
$files[] = $filesToAdd;
|
53 |
+
$data['created_files'] = serialize($files);
|
54 |
+
$passiveModeDataCollcetor->setData($data);
|
55 |
+
$passiveModeDataCollcetor->save();
|
56 |
+
|
57 |
+
return true;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function sendNotification($modeIds)
|
61 |
+
{
|
62 |
+
$helper = $this->getHelper();
|
63 |
+
|
64 |
+
$explodedIds = explode(',', $modeIds);
|
65 |
+
$zipEntityPackages = array();
|
66 |
+
|
67 |
+
foreach ($explodedIds as $modeIdBad) {
|
68 |
+
$modeId = trim($modeIdBad);
|
69 |
+
if ($modeId) {
|
70 |
+
$modeObj = Mage::getModel('advancedexport/passivemode')
|
71 |
+
->load($modeId);
|
72 |
+
if ($modeObj->getId()) {
|
73 |
+
if ($modeObj->getPassivemodEnabled()) {
|
74 |
+
$message = 'Passive Mode Id: ' . $modeId .
|
75 |
+
'. in Enabled State, before Notificate, '
|
76 |
+
. 'disable it.';
|
77 |
+
Mage::getSingleton('core/session')->addError($message);
|
78 |
+
continue;
|
79 |
+
}
|
80 |
+
$createdFiles = unserialize($modeObj->getCreatedFiles());
|
81 |
+
|
82 |
+
/* Collect Files By Entity Type,
|
83 |
+
* for different .zip packages */
|
84 |
+
|
85 |
+
foreach ($createdFiles as $file) {
|
86 |
+
$zipEntityPackages[$modeIdBad]
|
87 |
+
['files']
|
88 |
+
[$file['entity']]
|
89 |
+
[] = $file;
|
90 |
+
$zipEntityPackages[$modeIdBad]['datefinished'] =
|
91 |
+
$modeObj->getPassivemodEnd();
|
92 |
+
}
|
93 |
+
|
94 |
+
} else {
|
95 |
+
$message = 'Wrong Passive Mode Id: '
|
96 |
+
. $modeId . '. Status: Skipped.';
|
97 |
+
Mage::getSingleton('core/session')->addError($message);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
$notificationStorage = array();
|
103 |
+
|
104 |
+
if (count($zipEntityPackages)) {
|
105 |
+
$chanelName = $helper->getChanelName();
|
106 |
+
$chanelId = $helper->getChanelId();
|
107 |
+
$baseDir = Mage::getBaseDir();
|
108 |
+
$exportFolder = $helper->getExportfolder();
|
109 |
+
|
110 |
+
foreach ($zipEntityPackages as $modeId => $oneMode) {
|
111 |
+
$dateTimeInit = $helper
|
112 |
+
->getTimeByStamp($oneMode['datefinished']);
|
113 |
+
|
114 |
+
foreach ($oneMode['files'] as $entityToExp => $oneEntityFiles) {
|
115 |
+
$zip = new ZipArchive();
|
116 |
+
$zipFile = '[' . $chanelName . ']_'
|
117 |
+
. '[' . $chanelId . ']_'
|
118 |
+
. '[' . $entityToExp . ']_'
|
119 |
+
. '[' . $dateTimeInit . ']';
|
120 |
+
$zipFileFullPath = $baseDir . DS .
|
121 |
+
$exportFolder . DS . $zipFile;
|
122 |
+
|
123 |
+
$notificationStorage[$modeId][$entityToExp]['zip']['filename']
|
124 |
+
= $zipFile . '.zip';
|
125 |
+
$notificationStorage[$modeId][$entityToExp]['zip']['fullPath']
|
126 |
+
= $zipFileFullPath;
|
127 |
+
|
128 |
+
try {
|
129 |
+
$zip->open(
|
130 |
+
$zipFileFullPath . '.zip',
|
131 |
+
ZIPARCHIVE::CREATE
|
132 |
+
);
|
133 |
+
} catch (Exception $e) {
|
134 |
+
$this->stepErrors[] = 'Can not [CREATE] Zip Archive';
|
135 |
+
Mage::log(
|
136 |
+
'Can not [CREATE] Zip Archive',
|
137 |
+
1,
|
138 |
+
'freestyle.log'
|
139 |
+
);
|
140 |
+
}
|
141 |
+
|
142 |
+
foreach ($oneEntityFiles as $file) {
|
143 |
+
try {
|
144 |
+
$zip->addFile($file['filePath'], $file['fileName']);
|
145 |
+
} catch (Exception $e) {
|
146 |
+
$this->stepErrors[] = 'Can not [ADD] file ' .
|
147 |
+
$fileName . ' to Zip Archive';
|
148 |
+
Mage::log(
|
149 |
+
'Can not [ADD] file ' . $fileName .
|
150 |
+
' to Zip Archive',
|
151 |
+
1,
|
152 |
+
'freestyle.log'
|
153 |
+
);
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
$zip->close();
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/* Send Notification Tlo NextGen */
|
163 |
+
|
164 |
+
foreach ($notificationStorage as $modeId => $zips) {
|
165 |
+
foreach ($zips as $entity => $filesInfo) {
|
166 |
+
Mage::log(
|
167 |
+
'Sending Notification For Mode Id: ' . $modeId .
|
168 |
+
', Entity Type: ' . $entity,
|
169 |
+
1,
|
170 |
+
'freestyle.log'
|
171 |
+
);
|
172 |
+
|
173 |
+
$sendResult = Mage::helper('advancedexport/notificationSender')
|
174 |
+
->sendNotification(
|
175 |
+
$entity,
|
176 |
+
$entityId = -1,
|
177 |
+
$filesInfo['zip']['filename'],
|
178 |
+
'updated'
|
179 |
+
);
|
180 |
+
Mage::log(
|
181 |
+
'files = '. $filesInfo['zip']['filename'],
|
182 |
+
1,
|
183 |
+
'freestyle.log'
|
184 |
+
);
|
185 |
+
|
186 |
+
if ($sendResult) {
|
187 |
+
$modeObj = Mage::getModel('advancedexport/passivemode')
|
188 |
+
->load($modeId);
|
189 |
+
$modeObj->setIsNotificationSent(1);
|
190 |
+
$modeObj->save();
|
191 |
+
Mage::log(
|
192 |
+
'Notification For Mode Id: ' . $modeId .
|
193 |
+
', Entity Type: ' . $entity . ' , sent succesfully.',
|
194 |
+
1,
|
195 |
+
'freestyle.log'
|
196 |
+
);
|
197 |
+
} else {
|
198 |
+
Mage::log(
|
199 |
+
'Notification For Mode Id: ' . $modeId .
|
200 |
+
', Entity Type: ' . $entity . ' , failed.',
|
201 |
+
1,
|
202 |
+
'freestyle.log'
|
203 |
+
);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
public function getHelper()
|
210 |
+
{
|
211 |
+
return Mage::Helper('advancedexport');
|
212 |
+
}
|
213 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Queue.php
ADDED
@@ -0,0 +1,755 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Queue extends Mage_Core_Model_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
protected $_sequence = 1;
|
17 |
+
protected $_jsonOut = array();
|
18 |
+
public $_transmissionHasError = false;
|
19 |
+
|
20 |
+
public function _construct()
|
21 |
+
{
|
22 |
+
parent::_construct();
|
23 |
+
$this->_init('advancedexport/queue');
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getLastExportData()
|
27 |
+
{
|
28 |
+
$collection = $this->getCollection();
|
29 |
+
$collection->getSelect()->order('create_time DESC');
|
30 |
+
$last = $collection->getFirstItem();
|
31 |
+
return $last;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Send queue records based on website id
|
36 |
+
*
|
37 |
+
* @param int $batchSize - number of records to send
|
38 |
+
* @param int $websiteId - website Id to send
|
39 |
+
* @return int - number of records sent; can be less than batchsize
|
40 |
+
* */
|
41 |
+
public function sendWebsiteCollection($batchSize = 50, $websiteId = 1)
|
42 |
+
{
|
43 |
+
$batchSize = ($batchSize == NULL) ? 50 : $batchSize;
|
44 |
+
$websiteId = ($websiteId == NULL) ? 1 : $websiteId;
|
45 |
+
|
46 |
+
$returnCount = 0;
|
47 |
+
$okToContinue = false;
|
48 |
+
try {
|
49 |
+
$collection = $this->getCollection()
|
50 |
+
->addFieldToFilter('status', 'pending')
|
51 |
+
->addFieldToFilter('scope_value', $websiteId)
|
52 |
+
->setOrder('create_time', 'ASC')
|
53 |
+
->setPageSize($batchSize)
|
54 |
+
->setCurPage(1);
|
55 |
+
$okToContinue = true;
|
56 |
+
} catch (Exception $ex) {
|
57 |
+
$errorMessage = "[EXCEPTION] - Unable to gather data collection for"
|
58 |
+
. " [Website Id = {$websiteId}]; Exception: "
|
59 |
+
. $ex->getMessage();
|
60 |
+
Mage::log(
|
61 |
+
$errorMessage . ' ' . $ex->getFile() . '::'
|
62 |
+
. (string) $ex->getLine(),
|
63 |
+
1,
|
64 |
+
'freestyle.log'
|
65 |
+
);
|
66 |
+
$returnCount = 0;
|
67 |
+
}
|
68 |
+
|
69 |
+
if ($okToContinue) {
|
70 |
+
try {
|
71 |
+
$this->prepareEntities($collection);
|
72 |
+
$updateToSuccess = false;
|
73 |
+
$notifier = Mage::helper('advancedexport/notificationSender');
|
74 |
+
if (!empty($this->_jsonOut)) {
|
75 |
+
$updateToSuccess = $notifier
|
76 |
+
->sendQueue($this->_jsonOut, $websiteId);
|
77 |
+
}
|
78 |
+
|
79 |
+
foreach ($collection as $row) {
|
80 |
+
$row->setStatus($updateToSuccess ? 'sent' : 'error');
|
81 |
+
$row->setErrorMsg(
|
82 |
+
$updateToSuccess ? null : $notifier->sendErrorMessage
|
83 |
+
);
|
84 |
+
$row->setUpdateTime($this->createTimestamp());
|
85 |
+
}
|
86 |
+
$collection->save();
|
87 |
+
//$returnCount = $collection->count();
|
88 |
+
$returnCount = $collection->getSize();
|
89 |
+
} catch (Exception $exx) {
|
90 |
+
$errorMessage = "[EXCEPTION] - Unable to gather data collection"
|
91 |
+
. " for [Website Id = {$websiteId}]; Exception: " .
|
92 |
+
$exx->getMessage();
|
93 |
+
Mage::log(
|
94 |
+
$errorMessage . ' ' . $exx->getFile() . '::' .
|
95 |
+
(string) $exx->getLine(),
|
96 |
+
1,
|
97 |
+
'freestyle.log'
|
98 |
+
);
|
99 |
+
foreach ($collection as $row) {
|
100 |
+
$row->setStatus('error');
|
101 |
+
$row->setErrorMsg($errorMessage);
|
102 |
+
$row->setUpdateTime($this->createTimestamp());
|
103 |
+
}
|
104 |
+
$collection->save();
|
105 |
+
$returnCount = 0;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
//DE-11662 - reset the array
|
109 |
+
$this->_jsonOut = array();
|
110 |
+
return $returnCount;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Sends queue records based on ids or array of ids
|
115 |
+
*
|
116 |
+
* @param int $batchSize - number of records to send
|
117 |
+
* @param mixed $idToSend - an id or an array of ids from the queue table
|
118 |
+
* @return int - number of records processed
|
119 |
+
*/
|
120 |
+
public function sendMixCollection($batchSize = 50, $idToSend = 0)
|
121 |
+
{
|
122 |
+
$batchSize = ($batchSize == NULL) ? 50 : $batchSize;
|
123 |
+
|
124 |
+
if ($idToSend == 0) {
|
125 |
+
return false;
|
126 |
+
}
|
127 |
+
$this->_transmissionHasError = false; //reset
|
128 |
+
$returnCount = 0;
|
129 |
+
$okToContinue = false;
|
130 |
+
try {
|
131 |
+
if (is_array($idToSend)) {
|
132 |
+
$integerIds = array_map('intval', $idToSend);
|
133 |
+
$collection = $this->getCollection()
|
134 |
+
->addFieldToFilter('id', array('in' => $integerIds))
|
135 |
+
->setOrder('create_time', 'ASC')
|
136 |
+
->setPageSize($batchSize)
|
137 |
+
->setCurPage(1);
|
138 |
+
} else {
|
139 |
+
$collection = $this->getCollection()
|
140 |
+
->addFieldToFilter('id', $idToSend)
|
141 |
+
->setOrder('create_time', 'ASC')
|
142 |
+
->setPageSize($batchSize)
|
143 |
+
->setCurPage(1);
|
144 |
+
}
|
145 |
+
$okToContinue = true;
|
146 |
+
} catch (Exception $ex) {
|
147 |
+
$errorMessage = "[EXCEPTION] - Unable to gather data collection "
|
148 |
+
. "for [Website Id = {$websiteId}]; Exception: "
|
149 |
+
. $ex->getMessage();
|
150 |
+
Mage::log(
|
151 |
+
$errorMessage . ' ' . $ex->getFile() . '::' .
|
152 |
+
(string) $ex->getLine(),
|
153 |
+
1,
|
154 |
+
'freestyle.log'
|
155 |
+
);
|
156 |
+
$returnCount = 0;
|
157 |
+
}
|
158 |
+
|
159 |
+
if ($okToContinue) {
|
160 |
+
try {
|
161 |
+
$this->prepareEntities($collection, true);
|
162 |
+
|
163 |
+
$updateToSuccess = false;
|
164 |
+
$notifier = Mage::helper('advancedexport/notificationSender');
|
165 |
+
if (!empty($this->_jsonOut)) {
|
166 |
+
$updateToSuccess = $notifier->sendMixQueue($this->_jsonOut);
|
167 |
+
}
|
168 |
+
|
169 |
+
foreach ($collection as $row) {
|
170 |
+
$row->setStatus($updateToSuccess ? 'sent' : 'error');
|
171 |
+
$row->setErrorMsg(
|
172 |
+
$updateToSuccess ? NULL : $notifier->sendErrorMessage
|
173 |
+
);
|
174 |
+
$row->setUpdateTime($this->createTimestamp());
|
175 |
+
}
|
176 |
+
$this->_transmissionHasError =
|
177 |
+
!empty($notifier->sendErrorMessage);
|
178 |
+
$collection->save();
|
179 |
+
//$returnCount = $collection->count();
|
180 |
+
$returnCount = $collection->getSize();
|
181 |
+
} catch (Exception $exx) {
|
182 |
+
$errorMessage = "[EXCEPTION] - Unable to gather data collection"
|
183 |
+
. " for [Website Id = {$websiteId}]; Exception: "
|
184 |
+
. $exx->getMessage();
|
185 |
+
Mage::log(
|
186 |
+
$errorMessage . ' ' . $exx->getFile() . '::' .
|
187 |
+
(string) $exx->getLine(),
|
188 |
+
1,
|
189 |
+
'freestyle.log'
|
190 |
+
);
|
191 |
+
foreach ($collection as $row) {
|
192 |
+
$row->setStatus('error');
|
193 |
+
$row->setErrorMsg($errorMessage);
|
194 |
+
$row->setUpdateTime($this->createTimestamp());
|
195 |
+
}
|
196 |
+
$collection->save();
|
197 |
+
$returnCount = 0;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
//DE-11662 - reset the array
|
202 |
+
$this->_jsonOut = array();
|
203 |
+
return $returnCount;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Sends queue records based on ids or array of ids
|
208 |
+
*
|
209 |
+
* @param int $batchSize - number of records to send
|
210 |
+
* @param mixed $idToSend - an id or an array of ids from the queue table
|
211 |
+
* @param int $websiteId - website Id to send
|
212 |
+
* @return int - number of records processed
|
213 |
+
*/
|
214 |
+
public function getEntitiesToExport(
|
215 |
+
$batchSize = 50,
|
216 |
+
$idToSend = null,
|
217 |
+
$websiteId = 1
|
218 |
+
)
|
219 |
+
{
|
220 |
+
if ($idToSend) {
|
221 |
+
return $this->sendMixCollection($batchSize, $idToSend);
|
222 |
+
} else {
|
223 |
+
return $this->sendWebsiteCollection($batchSize, $websiteId);
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Add records to the queue
|
229 |
+
*
|
230 |
+
* @param string $entityToExport -
|
231 |
+
* {'order', 'product', 'customer', 'category'}
|
232 |
+
* @param int $entityId - entity id for the entity to export
|
233 |
+
* @param string $action - {'added', 'deleted'}
|
234 |
+
* @param string $entityValue -
|
235 |
+
* display value for entity {increment id, sku, first+last name}
|
236 |
+
* @param string $scope - 'website';
|
237 |
+
* @param int scope_value - website id;
|
238 |
+
* @return this (Freestyle_Advancedexport_Model_Queue)
|
239 |
+
*/
|
240 |
+
public function addToQueue(
|
241 |
+
$entityToExport,
|
242 |
+
$entityId,
|
243 |
+
$action,
|
244 |
+
$entityValue = '',
|
245 |
+
$scope = '',
|
246 |
+
$scopeId = 1
|
247 |
+
)
|
248 |
+
{
|
249 |
+
$collectionCheck = $this->checkDistinct(
|
250 |
+
$entityToExport,
|
251 |
+
$entityId,
|
252 |
+
$action,
|
253 |
+
$scope,
|
254 |
+
$scopeId
|
255 |
+
);
|
256 |
+
if ($collectionCheck->count() == 0) {
|
257 |
+
$websites = array();
|
258 |
+
$helper = Mage::Helper('advancedexport/website');
|
259 |
+
|
260 |
+
if ($scope === 'default') {
|
261 |
+
//create an array of multiple stores
|
262 |
+
//get a list of stores that are supported
|
263 |
+
$syncedSites = $helper->getWebsites(true);
|
264 |
+
foreach ($syncedSites as $website) {
|
265 |
+
$config['scope'] = 'website';
|
266 |
+
$config['scope_value'] = $website['WebsiteId'];
|
267 |
+
array_push($websites, $config);
|
268 |
+
}
|
269 |
+
} else {
|
270 |
+
if ($helper->isWebSiteStoreViewSupported($scopeId)) {
|
271 |
+
$single['scope'] = 'website';
|
272 |
+
$single['scope_value'] = Mage::app()
|
273 |
+
->getWebsite($scopeId)
|
274 |
+
->getId();
|
275 |
+
array_push($websites, $single);
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
foreach ($websites as $web) {
|
280 |
+
$messageData['entity_type'] = $entityToExport;
|
281 |
+
$messageData['entity_id'] = $entityId;
|
282 |
+
$messageData['action'] = $action;
|
283 |
+
$messageData['create_time'] = $this->createTimestamp();
|
284 |
+
$messageData['status'] = 'pending';
|
285 |
+
$messageData['entity_value'] = utf8_encode($entityValue);
|
286 |
+
|
287 |
+
$messageData['scope'] = $web['scope'];
|
288 |
+
$messageData['scope_value'] = $web['scope_value'];
|
289 |
+
|
290 |
+
$this->setData($messageData);
|
291 |
+
$this->save();
|
292 |
+
}
|
293 |
+
return $this;
|
294 |
+
} else {
|
295 |
+
//get the record and return it..
|
296 |
+
$newQueueModel = Mage::getModel('advancedexport/queue');
|
297 |
+
foreach ($collectionCheck as $row) {
|
298 |
+
$newQueueModel->load($row->getId());
|
299 |
+
break;
|
300 |
+
}
|
301 |
+
return $newQueueModel;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Removes records from queue table
|
307 |
+
*
|
308 |
+
* @param int $daysToKeep - number of days to keep as history
|
309 |
+
*/
|
310 |
+
public function purgeQueue($daysToKeep = 30)
|
311 |
+
{
|
312 |
+
$dateModel = Mage::getModel('core/date');
|
313 |
+
$dateEndTime = $dateModel->timestamp(
|
314 |
+
time() - ($daysToKeep * 24 * 60 * 60)
|
315 |
+
);
|
316 |
+
$dateEnd = $dateModel->date('Y-m-d', $dateEndTime) . " 00:00:00";
|
317 |
+
|
318 |
+
$result = $this->getCollection()
|
319 |
+
->addFieldToFilter(
|
320 |
+
'create_time',
|
321 |
+
array('date' => true, 'to' => $dateEnd)
|
322 |
+
)
|
323 |
+
->addFieldToFilter('status', 'sent');
|
324 |
+
$result->getSelect()
|
325 |
+
->reset(Zend_Db_Select::COLUMNS)
|
326 |
+
->columns('id');
|
327 |
+
foreach ($result as $row) {
|
328 |
+
$row->setStatus('deleted');
|
329 |
+
$row->setUpdateTime($this->createTimestamp());
|
330 |
+
}
|
331 |
+
|
332 |
+
$result->delete();
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Sends one order to Freestyle immediately
|
337 |
+
*
|
338 |
+
* @param mixed $orderIncrementId - string usually
|
339 |
+
* @return bool $updateToSuccess
|
340 |
+
*/
|
341 |
+
public function resendOrder($orderIncrementId)
|
342 |
+
{
|
343 |
+
$advHelper = Mage::Helper('advancedexport');
|
344 |
+
$webHelper = Mage::Helper('advancedexport/website');
|
345 |
+
|
346 |
+
//$rowsToUpdate = array();
|
347 |
+
|
348 |
+
//initialize XML stuffs
|
349 |
+
$xmlVersionHeader = $advHelper->getXmlVersionHeader();
|
350 |
+
$xmlVersion = $advHelper->getMainXmlTagWithParams();
|
351 |
+
$xmlEndTag = $advHelper->getMainXmlTagEnd();
|
352 |
+
|
353 |
+
$entityToExport = 'order';
|
354 |
+
$action = 'added';
|
355 |
+
|
356 |
+
$orderModel = Mage::getModel('sales/order');
|
357 |
+
$orderModel->loadByIncrementId($orderIncrementId);
|
358 |
+
|
359 |
+
//get the website for the store this order was placed under
|
360 |
+
$storeId = $orderModel->getStoreId();
|
361 |
+
$websiteId = $webHelper->getWebsiteByStoreId($storeId);
|
362 |
+
if (!$webHelper->isWebSiteStoreViewSupported($websiteId)) {
|
363 |
+
//website is not synced to Freestyle
|
364 |
+
$resultMsg = "Unable to send Order $orderIncrementId to Freestyle."
|
365 |
+
. " Website is not synced with Freestyle.";
|
366 |
+
Mage::getSingleton('adminhtml/session')->addError($resultMsg);
|
367 |
+
$this->_jsonOut = array(); //reset
|
368 |
+
Mage::app()->getResponse()->setBody($resultMsg);
|
369 |
+
return false;
|
370 |
+
}
|
371 |
+
|
372 |
+
$entityId = $orderModel->getId();
|
373 |
+
|
374 |
+
if (!$entityId) {
|
375 |
+
$resultMsg = "Unable to send Order $orderIncrementId to Freestyle."
|
376 |
+
. " Please ensure you have entered a valid Order Number";
|
377 |
+
Mage::getSingleton('adminhtml/session')->addError($resultMsg);
|
378 |
+
return false;
|
379 |
+
}
|
380 |
+
|
381 |
+
$entityDisplayValue = $orderIncrementId;
|
382 |
+
$entityXml = '';
|
383 |
+
|
384 |
+
//generic code
|
385 |
+
$model = $advHelper->getEntityModel($entityToExport);
|
386 |
+
|
387 |
+
//if order, check setting, if send dependencies, gather order items
|
388 |
+
//if order, check setting, if send dependencies, gather customer
|
389 |
+
$sendExtra = Mage::Helper('advancedexport/queue')
|
390 |
+
->getSendOrderDependencies();
|
391 |
+
if ($entityToExport == 'order' && $sendExtra) {
|
392 |
+
$this->appendOrderDependencies($entityId);
|
393 |
+
}
|
394 |
+
|
395 |
+
if (strtoupper($action) != 'DELETED') {
|
396 |
+
$entityData = $model->info($orderIncrementId);
|
397 |
+
$data = array($entityToExport => $entityData);
|
398 |
+
$entityXml = Mage::getModel('advancedexport/exportmodels_abstract')
|
399 |
+
->arrayToXml($entityToExport, $data);
|
400 |
+
$entityXml = $xmlVersionHeader
|
401 |
+
. "<$xmlVersion>"
|
402 |
+
. $entityXml
|
403 |
+
. "</$xmlEndTag>";
|
404 |
+
} else {
|
405 |
+
$entityXml = 'DELETED';
|
406 |
+
}
|
407 |
+
|
408 |
+
//key value matches FS
|
409 |
+
$rowOut['EntityId'] = $entityId;
|
410 |
+
$rowOut['EntityType'] = $entityToExport;
|
411 |
+
$rowOut['EntityEventType'] = $action;
|
412 |
+
$rowOut['EntityXml'] = $entityXml;
|
413 |
+
$rowOut['EntityValue'] = utf8_encode($entityDisplayValue);
|
414 |
+
$rowOut['MagentoCreateTime'] = $orderModel->created_at;
|
415 |
+
$rowOut['Sequence'] = $this->_sequence;
|
416 |
+
$this->_sequence++;
|
417 |
+
array_push($this->_jsonOut, $rowOut);
|
418 |
+
|
419 |
+
$updateToSuccess = false;
|
420 |
+
|
421 |
+
if (!empty($this->_jsonOut)) {
|
422 |
+
$notifier = Mage::helper('advancedexport/notificationSender');
|
423 |
+
$storeId = $orderModel->getStoreId();
|
424 |
+
$websiteId = $webHelper->getWebsiteByStoreId($storeId);
|
425 |
+
$updateToSuccess = $notifier->sendQueue(
|
426 |
+
$this->_jsonOut, $websiteId
|
427 |
+
);
|
428 |
+
}
|
429 |
+
|
430 |
+
$resultMsg = '';
|
431 |
+
if ($updateToSuccess) {
|
432 |
+
$resultMsg = "Success! Order $orderIncrementId sent to Freestyle";
|
433 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($resultMsg);
|
434 |
+
} else {
|
435 |
+
$resultMsg = "Unable to send Order $orderIncrementId to Freestyle."
|
436 |
+
. " Please ensure you have entered a valid Order Number";
|
437 |
+
Mage::getSingleton('adminhtml/session')->addError($resultMsg);
|
438 |
+
}
|
439 |
+
|
440 |
+
$this->_jsonOut = array(); //reset
|
441 |
+
Mage::app()->getResponse()->setBody($resultMsg);
|
442 |
+
return $updateToSuccess;
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Gathers collection of records from queue table
|
447 |
+
*
|
448 |
+
* @param int $startValue - beginning Id value
|
449 |
+
* @param int $endValue - ending Id value
|
450 |
+
* @return array $collection->data
|
451 |
+
*/
|
452 |
+
public function getEntityQueue($startValue = 1, $endValue = 1)
|
453 |
+
{
|
454 |
+
$collection = $this->getCollection();
|
455 |
+
$collection->getSelect()->where(
|
456 |
+
'`id` >= ' . $startValue . ' && `id` <= ' . $endValue
|
457 |
+
)->order('create_time ASC');
|
458 |
+
$select = $collection->getData();
|
459 |
+
return $select;
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* Generates XML based on collection passed
|
464 |
+
*
|
465 |
+
* @param object $collection - collection of queue records
|
466 |
+
* @param bool $isMix - true if the data needs to be prepared with sales
|
467 |
+
* channel id needs to be embedded in the payload
|
468 |
+
*/
|
469 |
+
protected function prepareEntities($collection, $isMix = false)
|
470 |
+
{
|
471 |
+
$advHelper = Mage::Helper('advancedexport');
|
472 |
+
//$rowsToUpdate = array();
|
473 |
+
|
474 |
+
//initialize XML stuffs
|
475 |
+
$xmlVersionHeader = $advHelper->getXmlVersionHeader();
|
476 |
+
$xmlVersion = $advHelper->getMainXmlTagWithParams();
|
477 |
+
$xmlEndTag = $advHelper->getMainXmlTagEnd();
|
478 |
+
|
479 |
+
foreach ($collection as $row) {
|
480 |
+
$entityToExport = $row->getEntityType();
|
481 |
+
$entityId = $row->getEntityId();
|
482 |
+
$action = $row->getAction();
|
483 |
+
$entityDisplayValue = $row->getEntityValue();
|
484 |
+
$entityXml = '';
|
485 |
+
|
486 |
+
//generic code
|
487 |
+
$model = $advHelper->getEntityModel($entityToExport);
|
488 |
+
$channelId = null;
|
489 |
+
if ($isMix) {
|
490 |
+
$channelId = $advHelper->getChanelId($row->getScopeValue());
|
491 |
+
}
|
492 |
+
//if order, check setting, if send dependencies, gather order items
|
493 |
+
//if order, check setting, if send dependencies, gather customer
|
494 |
+
if ($entityToExport == 'order') {
|
495 |
+
//swap entityid to contain increment id
|
496 |
+
$sendExtra = Mage::Helper('advancedexport/queue')
|
497 |
+
->getSendOrderDependencies();
|
498 |
+
if ($sendExtra) {
|
499 |
+
$this->appendOrderDependencies($entityId, $channelId);
|
500 |
+
//array_merge($jsonOut, $rowDepOut);
|
501 |
+
}
|
502 |
+
$entityId = $row->getEntityValue();
|
503 |
+
}
|
504 |
+
|
505 |
+
if (strtoupper($action) != 'DELETED') {
|
506 |
+
//if($entityToExport==='product')
|
507 |
+
// $entityData = $model->info($entityId,$row->getStoreId());
|
508 |
+
//else
|
509 |
+
$entityData = $model->info($entityId); //currently, store level
|
510 |
+
// info is not supported.
|
511 |
+
$data = array($entityToExport => $entityData);
|
512 |
+
$fsAbstract =
|
513 |
+
Mage::getModel('advancedexport/exportmodels_abstract');
|
514 |
+
$entityXml = $fsAbstract->arrayToXml($entityToExport, $data);
|
515 |
+
$entityXml = $xmlVersionHeader
|
516 |
+
. "<$xmlVersion>"
|
517 |
+
. $entityXml
|
518 |
+
. "</$xmlEndTag>";
|
519 |
+
} else {
|
520 |
+
if (method_exists($model, "getEntityIdFieldName")) {
|
521 |
+
$entityData = $model->info($entityId);
|
522 |
+
$entityIdFieldName = $model->getEntityIdFieldName();
|
523 |
+
$entityData[$entityIdFieldName] = $entityId;
|
524 |
+
$data = array($entityToExport => $entityData);
|
525 |
+
$fieldsToExport = array($entityIdFieldName);
|
526 |
+
$entityXml =
|
527 |
+
Mage::getModel('advancedexport/exportmodels_abstract')
|
528 |
+
->arrayToXml($entityToExport, $data, $fieldsToExport);
|
529 |
+
$entityXml = $xmlVersionHeader
|
530 |
+
. "<$xmlVersion>"
|
531 |
+
. $entityXml
|
532 |
+
. "</$xmlEndTag>";
|
533 |
+
} else {
|
534 |
+
$entityXml = $xmlVersionHeader
|
535 |
+
. "<$xmlVersion>"
|
536 |
+
. "DELETED"
|
537 |
+
. "</$xmlEndTag>";
|
538 |
+
}
|
539 |
+
}
|
540 |
+
|
541 |
+
if ($entityToExport == 'order') {
|
542 |
+
//swap it back
|
543 |
+
$entityId = $row->getEntityId();
|
544 |
+
}
|
545 |
+
|
546 |
+
//key value matches FS
|
547 |
+
$rowOut['EntityId'] = $entityId;
|
548 |
+
$rowOut['EntityType'] = $entityToExport;
|
549 |
+
$rowOut['EntityEventType'] = $action;
|
550 |
+
$rowOut['EntityXml'] = $entityXml;
|
551 |
+
$rowOut['EntityValue'] = $this->encodeToUtf8($entityDisplayValue);
|
552 |
+
$rowOut['MagentoCreateTime'] = $row->getCreateTime();
|
553 |
+
$rowOut['Sequence'] = $this->_sequence;
|
554 |
+
if ($isMix) {
|
555 |
+
$rowOut['SalesChannelId'] = $channelId;
|
556 |
+
}
|
557 |
+
$this->_sequence++;
|
558 |
+
array_push($this->_jsonOut, $rowOut);
|
559 |
+
|
560 |
+
//update the row to 'processing'
|
561 |
+
$row->setStatus('processing');
|
562 |
+
}
|
563 |
+
$collection->save();
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Checks if there is an unprocessed record in the queue already
|
568 |
+
*
|
569 |
+
* @param string $entityToExport -
|
570 |
+
* {'order', 'product', 'customer', 'category'}
|
571 |
+
* @param int $entityId - entity id for the entity to export
|
572 |
+
* @param string $action - {'added', 'deleted'}
|
573 |
+
* @param string $entityValue - display value for entity
|
574 |
+
* {increment id, sku, first+last name}
|
575 |
+
* @param string $scope - 'website';
|
576 |
+
* @param int scope_value - website id;
|
577 |
+
* @return object $collection
|
578 |
+
*/
|
579 |
+
protected function checkDistinct(
|
580 |
+
$entityToExport,
|
581 |
+
$entityId,
|
582 |
+
$action,
|
583 |
+
$scope = 'website',
|
584 |
+
$scopeValue = 1
|
585 |
+
)
|
586 |
+
{
|
587 |
+
$batchSize = Mage::Helper('advancedexport/queue')->getQueueBatchSize();
|
588 |
+
$collection = $this->getCollection()
|
589 |
+
->addFieldToFilter('entity_type', $entityToExport)
|
590 |
+
->addFieldToFilter('entity_id', $entityId)
|
591 |
+
->addFieldToFilter('action', $action)
|
592 |
+
->addFieldToFilter('status', 'pending')
|
593 |
+
->addFieldToFilter('scope', $scope)
|
594 |
+
->addFieldToFilter('scope_value', $scopeValue)
|
595 |
+
->setOrder('create_time', 'ASC')
|
596 |
+
->setPageSize($batchSize)
|
597 |
+
->setCurPage(1);
|
598 |
+
return $collection;
|
599 |
+
}
|
600 |
+
|
601 |
+
/**
|
602 |
+
* Gathers items and customers for an order and pre-pends
|
603 |
+
* them in the payload
|
604 |
+
*
|
605 |
+
* @param int $orderId - order id to be processed
|
606 |
+
* @param string channelId - sales channel id of the website for this order
|
607 |
+
*/
|
608 |
+
//TODO: inspect order model and skip dependencies if order is cancelled
|
609 |
+
protected function appendOrderDependencies($orderId, $channelId = null)
|
610 |
+
{
|
611 |
+
//$queueArray = array();
|
612 |
+
$customerInfo = array();
|
613 |
+
//$orderItemsArray = array();
|
614 |
+
|
615 |
+
$advHelper = Mage::Helper('advancedexport');
|
616 |
+
|
617 |
+
//initialize XML stuffs
|
618 |
+
$xmlVersionHeader = $advHelper->getXmlVersionHeader();
|
619 |
+
$xmlVersion = $advHelper->getMainXmlTagWithParams();
|
620 |
+
$xmlEndTag = $advHelper->getMainXmlTagEnd();
|
621 |
+
|
622 |
+
$entityXml = '';
|
623 |
+
|
624 |
+
//load the order
|
625 |
+
$orderModel = Mage::getModel('sales/order');
|
626 |
+
$orderModel->load($orderId);
|
627 |
+
|
628 |
+
$magentoCreateTime = $orderModel->created_at;
|
629 |
+
|
630 |
+
//get the customer
|
631 |
+
$customerIdtoExport = $orderModel->customer_id;
|
632 |
+
$model = $advHelper->getEntityModel('customer');
|
633 |
+
$entityData = $model->info($customerIdtoExport);
|
634 |
+
$data = array('customer' => $entityData);
|
635 |
+
$entityXml = Mage::getModel('advancedexport/exportmodels_abstract')
|
636 |
+
->arrayToXml('customer', $data);
|
637 |
+
$entityXml = $xmlVersionHeader
|
638 |
+
. "<$xmlVersion>"
|
639 |
+
. $entityXml
|
640 |
+
. "</$xmlEndTag>";
|
641 |
+
$entityDisplayValue = trim($entityData['firstname'])
|
642 |
+
. " " . trim($entityData['lastname']);
|
643 |
+
|
644 |
+
$customerInfo['EntityId'] = $customerIdtoExport;
|
645 |
+
$customerInfo['EntityType'] = 'customer';
|
646 |
+
$customerInfo['EntityEventType'] = 'added';
|
647 |
+
$customerInfo['EntityXml'] = $entityXml;
|
648 |
+
$customerInfo['EntityValue'] = $this->encodeToUtf8($entityDisplayValue);
|
649 |
+
$customerInfo['MagentoCreateTime'] = $magentoCreateTime;
|
650 |
+
$customerInfo['Sequence'] = $this->_sequence;
|
651 |
+
|
652 |
+
if ($channelId) {
|
653 |
+
$customerInfo['SalesChannelId'] = $channelId;
|
654 |
+
}
|
655 |
+
|
656 |
+
$this->_sequence++;
|
657 |
+
array_push($this->_jsonOut, $customerInfo);
|
658 |
+
|
659 |
+
unset($model);
|
660 |
+
unset($data);
|
661 |
+
unset($entityXml);
|
662 |
+
unset($entityData);
|
663 |
+
unset($entityDisplayValue);
|
664 |
+
unset($customerInfo);
|
665 |
+
|
666 |
+
//walk thru the items
|
667 |
+
$items = $orderModel->getAllItems();
|
668 |
+
$model = $advHelper->getEntityModel('product');
|
669 |
+
//foreach ($items as $itemId => $item) {
|
670 |
+
foreach ($items as $item) {
|
671 |
+
$itemInfo = array();
|
672 |
+
$productIdtoExport = $item->getProductId();
|
673 |
+
$entityData = $model->info($productIdtoExport);
|
674 |
+
$data = array('product' => $entityData);
|
675 |
+
$entityXml = Mage::getModel('advancedexport/exportmodels_abstract')
|
676 |
+
->arrayToXml('product', $data);
|
677 |
+
$entityXml = $xmlVersionHeader
|
678 |
+
. "<$xmlVersion>"
|
679 |
+
. $entityXml
|
680 |
+
. "</$xmlEndTag>";
|
681 |
+
$entityValue = $item->getSku();
|
682 |
+
|
683 |
+
$itemInfo['EntityId'] = $productIdtoExport;
|
684 |
+
$itemInfo['EntityType'] = 'product';
|
685 |
+
$itemInfo['EntityEventType'] = 'added';
|
686 |
+
$itemInfo['EntityXml'] = $entityXml;
|
687 |
+
$itemInfo['EntityValue'] = $this->encodeToUtf8($entityValue);
|
688 |
+
$itemInfo['MagentoCreateTime'] = $magentoCreateTime;
|
689 |
+
$itemInfo['Sequence'] = $this->_sequence;
|
690 |
+
|
691 |
+
if ($channelId) {
|
692 |
+
$itemInfo['SalesChannelId'] = $channelId;
|
693 |
+
}
|
694 |
+
|
695 |
+
$this->_sequence++;
|
696 |
+
array_push($this->_jsonOut, $itemInfo);
|
697 |
+
unset($data);
|
698 |
+
unset($entityXml);
|
699 |
+
unset($entityValue);
|
700 |
+
unset($entityData);
|
701 |
+
unset($itemInfo);
|
702 |
+
}
|
703 |
+
return true;
|
704 |
+
}
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Generates TimeStamp. Added for compatibility with EE1.10
|
708 |
+
*
|
709 |
+
* @return DateTime
|
710 |
+
*/
|
711 |
+
protected function createTimestamp()
|
712 |
+
{
|
713 |
+
/*
|
714 |
+
$currentDate = Varien_Date::now();
|
715 |
+
$currentTimestamp = Varien_Date::toTimestamp($currentDate);
|
716 |
+
return $currentTimestamp;
|
717 |
+
*
|
718 |
+
*/
|
719 |
+
$usePrimitiveDate = false;
|
720 |
+
$mageVersion = Mage::getVersion();
|
721 |
+
$fsHelper = Mage::Helper('advancedexport');
|
722 |
+
if ($fsHelper->isEnterprise() == 'Enterprise') {
|
723 |
+
$usePrimitiveDate = version_compare($mageVersion, '1.12.0.0') <= 0;
|
724 |
+
}
|
725 |
+
|
726 |
+
$currentTimeStamp = Mage::getSingleton('core/date')->gmtTimestamp();
|
727 |
+
|
728 |
+
//added fix for EE 1.10 returning null time stamps
|
729 |
+
if ($currentTimeStamp == null || $usePrimitiveDate) {
|
730 |
+
$currentDateTime = new DateTime('now', new DateTimeZone('UTC'));
|
731 |
+
$currentTimeStamp = $currentDateTime->format('Y-m-d H:i:s');
|
732 |
+
unset($currentDateTime);
|
733 |
+
}
|
734 |
+
return $currentTimeStamp;
|
735 |
+
}
|
736 |
+
|
737 |
+
/**
|
738 |
+
* Converts string to UTF8 for XML Compatibility
|
739 |
+
*
|
740 |
+
* @param string $string
|
741 |
+
* @return string
|
742 |
+
*/
|
743 |
+
public function encodeToUtf8($string)
|
744 |
+
{
|
745 |
+
return mb_convert_encoding(
|
746 |
+
$string,
|
747 |
+
"UTF-8",
|
748 |
+
mb_detect_encoding(
|
749 |
+
$string,
|
750 |
+
"UTF-8, ISO-8859-1, ISO-8859-15",
|
751 |
+
true
|
752 |
+
)
|
753 |
+
);
|
754 |
+
}
|
755 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Queuebatchsize.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/************************************************************************
|
3 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
4 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
5 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
6 |
+
or its affiliates.
|
7 |
+
All other product and company names mentioned herein are used for
|
8 |
+
identification purposes only, and may be trademarks of
|
9 |
+
their respective companies.
|
10 |
+
************************************************************************/
|
11 |
+
|
12 |
+
// app/code/community/Freestyle/Advancedexport/Model/Queuebatchsize.php
|
13 |
+
class Freestyle_Advancedexport_Model_Queuebatchsize
|
14 |
+
extends Mage_Core_Model_Config_Data
|
15 |
+
{
|
16 |
+
|
17 |
+
const VALIDATION_MESSAGE = 'Queue Batch Size must be between 1 and 500';
|
18 |
+
|
19 |
+
public function save()
|
20 |
+
{
|
21 |
+
$batchSize = $this->getValue();
|
22 |
+
if ($batchSize < 1) {
|
23 |
+
Mage::throwException(self::VALIDATION_MESSAGE);
|
24 |
+
//Mage::getSingleton('core/session')
|
25 |
+
//->addError(self::VALIDATION_MESSAGE);
|
26 |
+
}
|
27 |
+
|
28 |
+
if ($batchSize > 500) {
|
29 |
+
Mage::throwException(self::VALIDATION_MESSAGE);
|
30 |
+
//Mage::getSingleton('core/session')
|
31 |
+
//->addError(self::VALIDATION_MESSAGE);
|
32 |
+
}
|
33 |
+
|
34 |
+
return parent::save();
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Resend.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Resend extends Mage_Core_Model_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
public function _construct()
|
17 |
+
{
|
18 |
+
parent::_construct();
|
19 |
+
$this->_init('advancedexport/resend');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getIsPassiveEnabled()
|
23 |
+
{
|
24 |
+
$passiveEnabled = $this->getCollection()
|
25 |
+
->addFieldToFilter('passivemod_enabled', array('eq' => '1'));
|
26 |
+
if ($passiveEnabled->count()) {
|
27 |
+
return true;
|
28 |
+
}
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getEnabledId()
|
33 |
+
{
|
34 |
+
$passiveEnabled = $this->getCollection()
|
35 |
+
->addFieldToFilter('passivemod_enabled', array('eq' => '1'));
|
36 |
+
if ($passiveEnabled->count()) {
|
37 |
+
return $passiveEnabled->getLastItem()->getId();
|
38 |
+
}
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function addFileDataToCollector($filesToAdd)
|
43 |
+
{
|
44 |
+
if (isset($filesToAdd['zipFilePath'])) {
|
45 |
+
unset($filesToAdd['zipFilePath']);
|
46 |
+
}
|
47 |
+
//echo '<pre>'; print_r($filesToAdd);
|
48 |
+
$passvModeDataCollectr = $this->load($this->getEnabledId());
|
49 |
+
$data = $passvModeDataCollectr->getData();
|
50 |
+
$files = unserialize($data['created_files']);
|
51 |
+
$files[] = $filesToAdd;
|
52 |
+
$data['created_files'] = serialize($files);
|
53 |
+
$passvModeDataCollectr->setData($data);
|
54 |
+
$passvModeDataCollectr->save();
|
55 |
+
|
56 |
+
return true;
|
57 |
+
}
|
58 |
+
|
59 |
+
/* DE-10150 - resend orders to freestyle using GUI in admin panel */
|
60 |
+
|
61 |
+
public function sendNotification($modeIds)
|
62 |
+
{
|
63 |
+
if (!$this->getIsExtEnabled() || empty($modeIds)) {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
|
67 |
+
Mage::log(
|
68 |
+
"[INFO] - Resend File generation "
|
69 |
+
. "[Order->IncrementId=$modeIds]",
|
70 |
+
1,
|
71 |
+
'freestyle.log'
|
72 |
+
);
|
73 |
+
$entityId = trim($modeIds);
|
74 |
+
$sendResult = false;
|
75 |
+
$sendResultCustomer = false;
|
76 |
+
$helper = $this->getHelper();
|
77 |
+
|
78 |
+
//load the order
|
79 |
+
$order = Mage::getModel('sales/order');
|
80 |
+
$order->loadByIncrementId($entityId);
|
81 |
+
|
82 |
+
//export the customer...
|
83 |
+
$customerIdtoExport = $order->customer_id;
|
84 |
+
if (!empty($customerIdtoExport) && $customerIdtoExport != "0") {
|
85 |
+
$entityToExport = 'customer';
|
86 |
+
$action = 'updated';
|
87 |
+
|
88 |
+
$zipFile = $helper->generateAndSaveExportFile(
|
89 |
+
$entityToExport,
|
90 |
+
$customerIdtoExport,
|
91 |
+
$action
|
92 |
+
);
|
93 |
+
if ($zipFile) {
|
94 |
+
$noteSender = Mage::helper('advancedexport/notificationSender');
|
95 |
+
$sendResultCustomer = $noteSender->sendNotification(
|
96 |
+
$entityToExport,
|
97 |
+
$customerIdtoExport,
|
98 |
+
$zipFile,
|
99 |
+
$action
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
if ($sendResultCustomer) {
|
104 |
+
$resultMsg = "Success! Customer $customerIdtoExport "
|
105 |
+
. "sent to Freestyle";
|
106 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($resultMsg);
|
107 |
+
Mage::log(
|
108 |
+
"[INFO] - Customer [RESEND] "
|
109 |
+
. "[Order->IncrementId=$modeIds], "
|
110 |
+
. "[Customer->Id=$customerIdtoExport] success",
|
111 |
+
1,
|
112 |
+
'freestyle.log'
|
113 |
+
);
|
114 |
+
} else {
|
115 |
+
$resultMsg = "Unable to send Customer $customerIdtoExport "
|
116 |
+
. "to Freestyle. Please ensure you have "
|
117 |
+
. "entered a valid Order Number";
|
118 |
+
Mage::getSingleton('adminhtml/session')->addError($resultMsg);
|
119 |
+
Mage::log(
|
120 |
+
"[ALERT] - Resend File generation "
|
121 |
+
. "[Order->IncrementId=$modeIds], "
|
122 |
+
. "[Customer->Id=$customerIdtoExport] FAILED",
|
123 |
+
1,
|
124 |
+
'freestyle.log'
|
125 |
+
);
|
126 |
+
}
|
127 |
+
} else {
|
128 |
+
// guest order.. nothing to export
|
129 |
+
$sendResultCustomer = true;
|
130 |
+
}
|
131 |
+
|
132 |
+
if ($sendResultCustomer) {
|
133 |
+
//export the order
|
134 |
+
$entityToExport = 'order';
|
135 |
+
$action = 'updated';
|
136 |
+
|
137 |
+
$zipFile = $helper->generateAndSaveExportFile(
|
138 |
+
$entityToExport,
|
139 |
+
$entityId,
|
140 |
+
$action
|
141 |
+
);
|
142 |
+
if ($zipFile) {
|
143 |
+
$sendResult = Mage::helper('advancedexport/notificationSender')
|
144 |
+
->sendNotification(
|
145 |
+
$entityToExport,
|
146 |
+
$entityId,
|
147 |
+
$zipFile,
|
148 |
+
$action
|
149 |
+
);
|
150 |
+
}
|
151 |
+
|
152 |
+
if ($sendResult) {
|
153 |
+
$resultMsg = "Success! Order $modeIds sent to Freestyle";
|
154 |
+
Mage::getSingleton('adminhtml/session')->addSuccess($resultMsg);
|
155 |
+
Mage::log(
|
156 |
+
"[INFO] - Order [RESEND] [Order->IncrementId=$modeIds], "
|
157 |
+
. "[Customer->Id=$customerIdtoExport] success",
|
158 |
+
1,
|
159 |
+
'freestyle.log'
|
160 |
+
);
|
161 |
+
} else {
|
162 |
+
$resultMsg = "Unable to send Order $modeIds to Freestyle. "
|
163 |
+
. "Please ensure you have entered a valid Order Number";
|
164 |
+
Mage::getSingleton('adminhtml/session')->addError($resultMsg);
|
165 |
+
Mage::log(
|
166 |
+
"[ALERT] - [RESEND] [Order->IncrementId=$modeIds], "
|
167 |
+
. "[Customer->Id=$customerIdtoExport] FAILED",
|
168 |
+
1,
|
169 |
+
'freestyle.log'
|
170 |
+
);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
Mage::app()->getResponse()->setBody($resultMsg);
|
175 |
+
Mage::log(
|
176 |
+
"[INFO] - End Resend File generation [Order->IncrementId=$modeIds]",
|
177 |
+
1,
|
178 |
+
'freestyle.log'
|
179 |
+
);
|
180 |
+
}
|
181 |
+
|
182 |
+
public function getIsExtEnabled()
|
183 |
+
{
|
184 |
+
return Mage::Helper('advancedexport')->getIsExtEnabledForApi();
|
185 |
+
}
|
186 |
+
|
187 |
+
public function getHelper()
|
188 |
+
{
|
189 |
+
return Mage::Helper('advancedexport');
|
190 |
+
}
|
191 |
+
}
|
app/code/community/Freestyle/Advancedexport/Model/Website.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Model_Website extends Mage_Core_Model_Abstract
|
14 |
+
{
|
15 |
+
//put your code here
|
16 |
+
public function toOptionArray()
|
17 |
+
{
|
18 |
+
$helper = Mage::Helper('advancedexport/website');
|
19 |
+
$_websites = $helper->getWebsites(true);
|
20 |
+
|
21 |
+
$optArray = array(array('value'=>'', 'label'=>''));
|
22 |
+
|
23 |
+
foreach ($_websites as $website) {
|
24 |
+
$optArray[] = array(
|
25 |
+
'value'=>$website['WebsiteId'],
|
26 |
+
'label'=>$website['WebsiteName']
|
27 |
+
);
|
28 |
+
}
|
29 |
+
return $optArray;
|
30 |
+
}
|
31 |
+
}
|
app/code/community/Freestyle/Advancedexport/controllers/Adminhtml/AdvancedexportController.php
ADDED
@@ -0,0 +1,559 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_Adminhtml_AdvancedexportController
|
14 |
+
extends Mage_Adminhtml_Controller_Action
|
15 |
+
{
|
16 |
+
|
17 |
+
const MAX_BATCH_SIZE = 1000000;
|
18 |
+
const MAX_SOCKET_TIME_OUT = 9999999;
|
19 |
+
const MAX_PROCESS_TIME_LIMIT = 99999999;
|
20 |
+
|
21 |
+
public $exportErrors;
|
22 |
+
|
23 |
+
public function getHelper()
|
24 |
+
{
|
25 |
+
return Mage::Helper('advancedexport');
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _initAction()
|
29 |
+
{
|
30 |
+
$this->loadLayout()->_setActiveMenu('advancedexport');
|
31 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
32 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
33 |
+
}
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
//apply ACL
|
38 |
+
protected function _isAllowed()
|
39 |
+
{
|
40 |
+
return Mage::getSingleton('admin/session')
|
41 |
+
->isAllowed('freestyle_advancedexport/exportblock');
|
42 |
+
}
|
43 |
+
|
44 |
+
public function indexAction()
|
45 |
+
{
|
46 |
+
if (!$this->getHelper()->getIsExtEnabledForApi()) {
|
47 |
+
$this->_initAction();
|
48 |
+
$displayText = '<h1>Extension Disabled</h1><br/>' .
|
49 |
+
'<p>Please go to '
|
50 |
+
. '<strong>System >> '
|
51 |
+
. 'Configuration >> '
|
52 |
+
. 'Freestyle >> '
|
53 |
+
. 'Advanced Export >> '
|
54 |
+
. 'Settings</strong> to enable.</p>';
|
55 |
+
//$block = $this->getLayout()->createBlock('core/text')
|
56 |
+
//->setText('<h1>Extension Disabled</h1>');
|
57 |
+
$block = $this->getLayout()->createBlock('core/text')
|
58 |
+
->setText($displayText);
|
59 |
+
$this->_addContent($block);
|
60 |
+
$this->renderLayout();
|
61 |
+
} else {
|
62 |
+
$this->_initAction();
|
63 |
+
$this->_addContent(
|
64 |
+
$this->getLayout()
|
65 |
+
->createBlock('advancedexport/adminhtml_form_edit')
|
66 |
+
)
|
67 |
+
->_addLeft(
|
68 |
+
$this->getLayout()
|
69 |
+
->createBlock('advancedexport/adminhtml_form_edit_tabs')
|
70 |
+
);
|
71 |
+
$this->renderLayout();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
public function processdataAction()
|
76 |
+
{
|
77 |
+
$fatal = false;
|
78 |
+
|
79 |
+
$this->exportErrors = array();
|
80 |
+
$helper = $this->getHelper();
|
81 |
+
//$postData = $this->getRequest()->getPost(); /*unused*/
|
82 |
+
|
83 |
+
$entityToExport = $this->getRequest()->getPost('export_entity', false);
|
84 |
+
$startDate = $this->getRequest()->getPost('date_start', false);
|
85 |
+
$endDate = $this->getRequest()->getPost('date_end', false);
|
86 |
+
$idsToExport = (string) $this->getRequest()
|
87 |
+
->getPost('ids_to_export', '');
|
88 |
+
$batchsize = (int) $this->getRequest()
|
89 |
+
->getPost('batch_size', self::MAX_BATCH_SIZE);
|
90 |
+
|
91 |
+
$getPassiveModel = $this->getRequest()
|
92 |
+
->getPost('switchToPassiveMode', 'no_action');
|
93 |
+
|
94 |
+
$sendNotification = $this->getRequest()
|
95 |
+
->getPost('sendnotificationflag', 'no_action');
|
96 |
+
$passiveModeIds = $this->getRequest()
|
97 |
+
->getPost('notifyId', '');
|
98 |
+
|
99 |
+
$resendNotification = $this->getRequest()
|
100 |
+
->getPost('resendnotification', 'no_action');
|
101 |
+
$resendId = $this->getRequest()->getPost('notifyIncrementId', '');
|
102 |
+
|
103 |
+
//DE-8384
|
104 |
+
$websiteToExport = $this->getRequest()->getPost('website_id', 1);
|
105 |
+
|
106 |
+
//Proccess Passive Mode
|
107 |
+
$exportFiles = ($getPassiveModel == 'no_action')
|
108 |
+
&& ($sendNotification == 'no_action')
|
109 |
+
&& ($resendNotification == 'no_action');
|
110 |
+
if ($exportFiles) {
|
111 |
+
|
112 |
+
|
113 |
+
//Add last Params to Session
|
114 |
+
Mage::getSingleton('adminhtml/session')
|
115 |
+
->setData(
|
116 |
+
'advancedExportValues', array(
|
117 |
+
'export_entity' => $entityToExport,
|
118 |
+
'batch_size' => $batchsize,
|
119 |
+
'date_start' => $startDate,
|
120 |
+
'date_end' => $endDate,
|
121 |
+
'ids_to_export' => $idsToExport,
|
122 |
+
'website_id' => $websiteToExport
|
123 |
+
)
|
124 |
+
);
|
125 |
+
|
126 |
+
if (!$batchsize) {
|
127 |
+
$batchsize = self::MAX_BATCH_SIZE;
|
128 |
+
}
|
129 |
+
|
130 |
+
$date = $helper->getCurrentTime();
|
131 |
+
|
132 |
+
$dateTimeStart = new DateTime();
|
133 |
+
|
134 |
+
$priority = $helper
|
135 |
+
->getParamsPriority($startDate, $endDate, $idsToExport);
|
136 |
+
|
137 |
+
$fsAbstract =
|
138 |
+
Mage::getModel('advancedexport/exportmodels_abstract');
|
139 |
+
$dataCollection = $fsAbstract->getEntityIdsCollection(
|
140 |
+
$entityToExport,
|
141 |
+
$priority,
|
142 |
+
$websiteToExport
|
143 |
+
)->getData();
|
144 |
+
|
145 |
+
$file = 'datatemp' . $date . '.txt';
|
146 |
+
$filesBatchArray = 'batchFiles' . $date . '.txt';
|
147 |
+
|
148 |
+
try {
|
149 |
+
$permissionsResult = $helper->checkFoldersPremissions();
|
150 |
+
if (!$permissionsResult) {
|
151 |
+
$fatal = true;
|
152 |
+
$this->exportErrors[] = 'Can not put write to '
|
153 |
+
. '"freestyleexport" or '
|
154 |
+
. '"freestyleexport/tempFiles" folder(s). '
|
155 |
+
. 'Check permissions';
|
156 |
+
Mage::log(
|
157 |
+
'Can not [WRITE] to "freestyleexport" or '
|
158 |
+
. '"freestyleexport/tempFiles" folder(s). '
|
159 |
+
. 'Check permissions',
|
160 |
+
1,
|
161 |
+
'freestyle.log'
|
162 |
+
);
|
163 |
+
} else {
|
164 |
+
$tempfile = Mage::getBaseDir() . DS
|
165 |
+
. Mage::Helper('advancedexport')->getExportfolder()
|
166 |
+
. DS . 'tempFiles' . DS . $file;
|
167 |
+
$putResult = file_put_contents(
|
168 |
+
$tempfile,
|
169 |
+
serialize($dataCollection)
|
170 |
+
);
|
171 |
+
|
172 |
+
$tempfileBatches = Mage::getBaseDir() . DS
|
173 |
+
. Mage::Helper('advancedexport')->getExportfolder()
|
174 |
+
. DS . 'tempFiles' . DS . $filesBatchArray;
|
175 |
+
$putResult = file_put_contents(
|
176 |
+
$tempfileBatches,
|
177 |
+
serialize(array())
|
178 |
+
);
|
179 |
+
}
|
180 |
+
} catch (Exception $e) {
|
181 |
+
$this->exportErrors[] = 'Can not write to "freestyleexport" '
|
182 |
+
. 'or "freestyleexport/tempFiles" folder(s). '
|
183 |
+
. 'Check permissions';
|
184 |
+
Mage::log(
|
185 |
+
'Can not [WRITE] to "freestyleexport" '
|
186 |
+
. 'or "freestyleexport/tempFiles" folder(s). '
|
187 |
+
. 'Check permissions',
|
188 |
+
1,
|
189 |
+
'freestyle.log'
|
190 |
+
);
|
191 |
+
$fatal = true;
|
192 |
+
}
|
193 |
+
|
194 |
+
/* + Execution Time + Memory Limit */
|
195 |
+
ini_set('default_socket_timeout', self::MAX_SOCKET_TIME_OUT);
|
196 |
+
set_time_limit(self::MAX_PROCESS_TIME_LIMIT);
|
197 |
+
ini_set('memory_limit', $helper->getMemoryLimit() . 'M');
|
198 |
+
|
199 |
+
$url = Mage::getUrl(
|
200 |
+
'advancedexport/frontprocess/processexport',
|
201 |
+
array('_secure' => true)
|
202 |
+
)
|
203 |
+
. '?export_entity='
|
204 |
+
. $entityToExport
|
205 |
+
. '&batch_size=' . $batchsize
|
206 |
+
. '&tempfile=' . $file
|
207 |
+
. '&batchesfile=' . $filesBatchArray
|
208 |
+
. '&datetimeinit=' . $date
|
209 |
+
. '&website_id=' . $websiteToExport;
|
210 |
+
|
211 |
+
$stepCounter = 0;
|
212 |
+
|
213 |
+
if (!$fatal) {
|
214 |
+
do {
|
215 |
+
$httpResult = file_get_contents($url);
|
216 |
+
$goFromRequests = false;
|
217 |
+
|
218 |
+
if ($httpResult === false) {
|
219 |
+
$this->exportErrors[] = 'Server Response Error';
|
220 |
+
$errorMessage = 'Server Response Error is blank '
|
221 |
+
. 'export_entity=' . $entityToExport
|
222 |
+
. '&batch_size=' . $batchsize
|
223 |
+
. '&tempfile=' . $file
|
224 |
+
. '&batchesfile=' . $filesBatchArray
|
225 |
+
. '&datetimeinit=' . $date;
|
226 |
+
Mage::log($errorMessage, 1, 'freestyle.log');
|
227 |
+
}
|
228 |
+
|
229 |
+
try {
|
230 |
+
$structure = unserialize($httpResult);
|
231 |
+
|
232 |
+
if (isset($structure['error_fatal'])) {
|
233 |
+
if (count($structure['error'])) {
|
234 |
+
foreach ($structure['error'] as $one) {
|
235 |
+
$this->exportErrors[] = $one;
|
236 |
+
Mage::log($one, 1, 'freestyle.log');
|
237 |
+
}
|
238 |
+
}
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
|
242 |
+
if (!$structure['export_finished']) {
|
243 |
+
|
244 |
+
// Add Params To Url For Next Step
|
245 |
+
$url .= '&last_entity_value='
|
246 |
+
. $structure['last_exported_info']['value']
|
247 |
+
. '&last_record_value='
|
248 |
+
. $structure['last_exported_info']
|
249 |
+
['record_number'];
|
250 |
+
Mage::log(
|
251 |
+
$stepCounter
|
252 |
+
. '. Export Next Step. Record Start : '
|
253 |
+
. $structure['last_exported_info']
|
254 |
+
['record_number'],
|
255 |
+
1,
|
256 |
+
'freestyle.log'
|
257 |
+
);
|
258 |
+
}
|
259 |
+
|
260 |
+
if (count($structure['error'])) {
|
261 |
+
foreach ($structure['error'] as $one) {
|
262 |
+
$this->exportErrors[] = $one;
|
263 |
+
Mage::log($one, 1, 'freestyle.log');
|
264 |
+
}
|
265 |
+
}
|
266 |
+
} catch (Exception $e) {
|
267 |
+
$this->exportErrors[] = 'Server Response Error';
|
268 |
+
Mage::log(
|
269 |
+
'Server Response Error ' . $e->getMessage(),
|
270 |
+
1,
|
271 |
+
'freestyle.log'
|
272 |
+
);
|
273 |
+
Mage::log(
|
274 |
+
'Server Response: ' . $httpResult,
|
275 |
+
1,
|
276 |
+
'freestyle.log'
|
277 |
+
);
|
278 |
+
|
279 |
+
$goFromRequests = true;
|
280 |
+
$structure['action'] = 'end';
|
281 |
+
$structure['export_finished'] = 1;
|
282 |
+
}
|
283 |
+
|
284 |
+
$stepCounter++;
|
285 |
+
} while (($structure['action'] == 'next_step') && (!$structure['export_finished']) && (!$goFromRequests));
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
$dateTimeEnd = new DateTime();
|
290 |
+
|
291 |
+
/* Save Export To History */
|
292 |
+
if (isset($structure['zip_file'])) {
|
293 |
+
$fileResult = $structure['zip_file'];
|
294 |
+
} else {
|
295 |
+
$fileResult = array();
|
296 |
+
}
|
297 |
+
|
298 |
+
$historyModel = Mage::getModel('advancedexport/history');
|
299 |
+
$historyData['export_date'] = $dateTimeStart->format('Y-m-d H:i:s');
|
300 |
+
$historyData['export_date_time_start'] = $dateTimeStart
|
301 |
+
->format('Y-m-d H:i:s');
|
302 |
+
$historyData['export_date_time_end'] = $dateTimeEnd
|
303 |
+
->format('Y-m-d H:i:s');
|
304 |
+
$historyData['created_files'] = serialize($fileResult);
|
305 |
+
$historyData['init_from'] = 'Magento Admin Panel';
|
306 |
+
$historyData['export_entity'] = $entityToExport;
|
307 |
+
$historyData['errors'] = serialize($this->exportErrors);
|
308 |
+
$historyModel->setData($historyData);
|
309 |
+
$historyModel->save();
|
310 |
+
} elseif ($sendNotification == 'sendnotify') {
|
311 |
+
|
312 |
+
/* Send Notification */
|
313 |
+
$result = Mage::getModel('advancedexport/passivemode')
|
314 |
+
->sendNotification($passiveModeIds);
|
315 |
+
} elseif ($resendNotification == 'sendnotify') {
|
316 |
+
/* Send Notification */
|
317 |
+
if (Mage::helper('advancedexport/queue')->getEnableQueue()) {
|
318 |
+
$result = Mage::getModel('advancedexport/queue')
|
319 |
+
->resendOrder(trim($resendId));
|
320 |
+
} else {
|
321 |
+
$result = Mage::getModel('advancedexport/resend')
|
322 |
+
->sendNotification(trim($resendId));
|
323 |
+
}
|
324 |
+
} else {
|
325 |
+
|
326 |
+
/* For Passive Mode */
|
327 |
+
$result = $helper->processPassiveMode($getPassiveModel);
|
328 |
+
|
329 |
+
if (!empty($result['errors'])) {
|
330 |
+
foreach ($result['errors'] as $one) {
|
331 |
+
Mage::getSingleton('core/session')->addError($one);
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
$this->_redirectReferer();
|
337 |
+
}
|
338 |
+
|
339 |
+
public function gridAction()
|
340 |
+
{
|
341 |
+
$this->getResponse()->setBody(
|
342 |
+
$this->getLayout()
|
343 |
+
->createBlock(
|
344 |
+
'advancedexport/adminhtml_form_edit_tab_history'
|
345 |
+
)->toHtml()
|
346 |
+
);
|
347 |
+
}
|
348 |
+
|
349 |
+
public function gridpassiveAction()
|
350 |
+
{
|
351 |
+
$this->getResponse()->setBody(
|
352 |
+
$this->getLayout()
|
353 |
+
->createBlock('advancedexport/adminhtml_form_edit_tab_passive')
|
354 |
+
->toHtml()
|
355 |
+
);
|
356 |
+
}
|
357 |
+
|
358 |
+
public function gridqueueAction()
|
359 |
+
{
|
360 |
+
$this->getResponse()->setBody(
|
361 |
+
$this->getLayout()
|
362 |
+
->createBlock('advancedexport/adminhtml_form_edit_tab_queue')
|
363 |
+
->toHtml()
|
364 |
+
);
|
365 |
+
}
|
366 |
+
|
367 |
+
public function deleteexportfilesAction()
|
368 |
+
{
|
369 |
+
$path = Mage::getBaseDir() . DS .
|
370 |
+
Mage::Helper('advancedexport')->getExportfolder();
|
371 |
+
$this->deleteFiles($path);
|
372 |
+
$this->_redirectReferer();
|
373 |
+
}
|
374 |
+
|
375 |
+
public function deleteFiles($path)
|
376 |
+
{
|
377 |
+
if (file_exists($path)) {
|
378 |
+
$directoryIterator = new DirectoryIterator($path);
|
379 |
+
|
380 |
+
foreach ($directoryIterator as $fileInfo) {
|
381 |
+
$filePath = $fileInfo->getPathname();
|
382 |
+
if (!$fileInfo->isDot()) {
|
383 |
+
if ($fileInfo->isFile()) {
|
384 |
+
unlink($filePath);
|
385 |
+
} elseif ($fileInfo->isDir()) {
|
386 |
+
$this->deleteFiles($filePath);
|
387 |
+
}
|
388 |
+
}
|
389 |
+
}
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
public function checkAction()
|
394 |
+
{
|
395 |
+
$result = 1;
|
396 |
+
Mage::app()->getResponse()->setBody($result);
|
397 |
+
}
|
398 |
+
|
399 |
+
public function testconnectionAction()
|
400 |
+
{
|
401 |
+
//echo "You found me!\n";
|
402 |
+
$result['message'] = "Unable to connect.\n"
|
403 |
+
. "Please confirm the credentials "
|
404 |
+
. "and SAVE config before attempting again.";
|
405 |
+
$result['type'] = 'error'; //success, error, warn, notice
|
406 |
+
$objAuthenticate = Mage::helper("advancedexport/notificationSender");
|
407 |
+
/*
|
408 |
+
$authenticationUrl = Mage::app()->getRequest()->getParam('authurl');
|
409 |
+
$authUser = Mage::app()->getRequest()->getParam('authuser');
|
410 |
+
$authPwd = Mage::app()->getRequest()->getParam('authpwd');
|
411 |
+
parameters:{authuser:$('freestyle_advancedexport_api_api_username').value,
|
412 |
+
authpwd: $('freestyle_advancedexport_api_api_password').value,
|
413 |
+
authurl: $('freestyle_advancedexport_api_api_authorization_url').value
|
414 |
+
},
|
415 |
+
*
|
416 |
+
*
|
417 |
+
*/
|
418 |
+
//A Error Message
|
419 |
+
//Mage::getSingleton('checkout/session')
|
420 |
+
//->addError("Your cart has been updated successfully!");
|
421 |
+
//A Info Message (See link below)
|
422 |
+
//Mage::getSingleton('checkout/session')
|
423 |
+
//->addNotice("This is just a FYI message...");
|
424 |
+
try {
|
425 |
+
//$token = $objAuthenticate->setIsApiCall(false)
|
426 |
+
//->testconnection($authenticationUrl, $authUser, $authPwd);
|
427 |
+
$token = $objAuthenticate->setIsApiCall(false)->authentification();
|
428 |
+
} catch (Exception $e) {
|
429 |
+
$result['message'] = $e->getMessage();
|
430 |
+
Mage::getSingleton('adminhtml/session')->addError($result);
|
431 |
+
}
|
432 |
+
//echo "Token = ".$token;
|
433 |
+
if ($token) {
|
434 |
+
$result['message'] = "Success!\n" . "Token Received:" . $token;
|
435 |
+
$result['type'] = 'success';
|
436 |
+
//Mage::getSingleton('adminhtml/session')->addSuccess($result);
|
437 |
+
} else {
|
438 |
+
//Mage::getSingleton('adminhtml/session')->addError($result);
|
439 |
+
}
|
440 |
+
//Mage::app()->getResponse()->setBody($result);
|
441 |
+
Mage::app()->getResponse()
|
442 |
+
->setBody(Mage::helper('core')->jsonEncode($result));
|
443 |
+
}
|
444 |
+
|
445 |
+
public function sendjustoneAction()
|
446 |
+
{
|
447 |
+
$entityToExport = $this->getRequest()->getParam('id', false);
|
448 |
+
$result['message'] = "Nice!";
|
449 |
+
$result['type'] = 'success'; //success, error, warn, notice
|
450 |
+
if ($entityToExport) {
|
451 |
+
$queueModel = Mage::getModel('advancedexport/queue');
|
452 |
+
//$queueModel->addToQueue($entityToExport,$entityId,$action);
|
453 |
+
//send this one record immediately...
|
454 |
+
//$queueModel->getEntitiesToExport(1, $entityToExport); //refactored
|
455 |
+
$queueModel->sendMixCollection(1, $entityToExport);
|
456 |
+
}
|
457 |
+
//Mage::getSingleton('adminhtml/session')->addSuccess('BOOM!');
|
458 |
+
//$this->_redirectReferer();
|
459 |
+
Mage::app()->getResponse()
|
460 |
+
->setBody(Mage::helper('core')->jsonEncode($result));
|
461 |
+
}
|
462 |
+
|
463 |
+
public function batchSendAction()
|
464 |
+
{
|
465 |
+
$idsToSend = $this->getRequest()->getParam('queue');
|
466 |
+
|
467 |
+
if (!is_array($idsToSend)) {
|
468 |
+
Mage::getSingleton('adminhtml/session')
|
469 |
+
->addError($this->__('Please select record(s) to send.'));
|
470 |
+
} else {
|
471 |
+
try {
|
472 |
+
//$model = Mage::getSingleton('my_ads/listing');
|
473 |
+
$queueModel = Mage::getModel('advancedexport/queue');
|
474 |
+
//$model->load($adId)->delete();
|
475 |
+
$numOfIdsToSend = count($idsToSend);
|
476 |
+
$numLeftToProcess = $numOfIdsToSend;
|
477 |
+
$batchSize = (int) Mage::Helper('advancedexport/queue')
|
478 |
+
->getQueueBatchSize();
|
479 |
+
$counter = 0;
|
480 |
+
$counterForErrors = 0;
|
481 |
+
do {
|
482 |
+
if ($numOfIdsToSend == 0) {
|
483 |
+
break;
|
484 |
+
}
|
485 |
+
$batchToSend = array_slice(
|
486 |
+
$idsToSend,
|
487 |
+
$counter,
|
488 |
+
$batchSize
|
489 |
+
);
|
490 |
+
//$queueModel
|
491 |
+
//->getEntitiesToExport(count($batchToSend), $batchToSend);
|
492 |
+
$queueModel
|
493 |
+
->sendMixCollection(count($batchToSend), $batchToSend);
|
494 |
+
$numLeftToProcess = $numLeftToProcess - count($batchToSend);
|
495 |
+
$counter = $counter + count($batchToSend);
|
496 |
+
if ($queueModel->_transmissionHasError === true)
|
497 |
+
{
|
498 |
+
$counterForErrors += count($batchToSend);
|
499 |
+
}
|
500 |
+
} while ($numLeftToProcess > 0);
|
501 |
+
|
502 |
+
if ($counterForErrors > 0)
|
503 |
+
{
|
504 |
+
Mage::getSingleton('adminhtml/session')
|
505 |
+
->addError(
|
506 |
+
$this->__(
|
507 |
+
'%d record(s) were sent unsuccessfully.',
|
508 |
+
count($counterForErrors)
|
509 |
+
)
|
510 |
+
);
|
511 |
+
} elseif (count($idsToSend) - $counterForErrors > 0) {
|
512 |
+
Mage::getSingleton('adminhtml/session')
|
513 |
+
->addSuccess(
|
514 |
+
$this->__(
|
515 |
+
'Total of %d record(s) were sent.',
|
516 |
+
count($idsToSend) - $counterForErrors
|
517 |
+
)
|
518 |
+
);
|
519 |
+
}
|
520 |
+
} catch (Exception $e) {
|
521 |
+
Mage::getSingleton('adminhtml/session')
|
522 |
+
->addError($e->getMessage());
|
523 |
+
}
|
524 |
+
}
|
525 |
+
$this->_redirect('*/*/');
|
526 |
+
}
|
527 |
+
|
528 |
+
//DE-11662
|
529 |
+
public function batchUpdateAction()
|
530 |
+
{
|
531 |
+
$idsToSend = $this->getRequest()->getParam('queue');
|
532 |
+
|
533 |
+
if (!is_array($idsToSend)) {
|
534 |
+
Mage::getSingleton('adminhtml/session')
|
535 |
+
->addError($this->__('Please select record(s) to send.'));
|
536 |
+
} else {
|
537 |
+
try {
|
538 |
+
//$model = Mage::getSingleton('my_ads/listing');
|
539 |
+
$queueModel = Mage::getModel('advancedexport/queue');
|
540 |
+
foreach ($idsToSend as $entityToExport) {
|
541 |
+
//$model->load($adId)->delete();
|
542 |
+
$queueModel->load($entityToExport);
|
543 |
+
$queueModel->setStatus('sent')->save();
|
544 |
+
}
|
545 |
+
Mage::getSingleton('adminhtml/session')
|
546 |
+
->addSuccess(
|
547 |
+
$this->__(
|
548 |
+
'Total of %d record(s) were updated.',
|
549 |
+
count($idsToSend)
|
550 |
+
)
|
551 |
+
);
|
552 |
+
} catch (Exception $e) {
|
553 |
+
Mage::getSingleton('adminhtml/session')
|
554 |
+
->addError($e->getMessage());
|
555 |
+
}
|
556 |
+
}
|
557 |
+
$this->_redirect('*/*/');
|
558 |
+
}
|
559 |
+
}
|
app/code/community/Freestyle/Advancedexport/controllers/FrontprocessController.php
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_FrontprocessController
|
14 |
+
extends Mage_Core_Controller_Front_Action
|
15 |
+
{
|
16 |
+
|
17 |
+
const MAX_BATCH_SIZE = 1000000;
|
18 |
+
const MAX_SOCKET_TIME_OUT = 9999999;
|
19 |
+
const MAX_PROCESS_TIME_LIMIT = 99999999;
|
20 |
+
|
21 |
+
public $exportErrors;
|
22 |
+
|
23 |
+
public function getHelper()
|
24 |
+
{
|
25 |
+
return Mage::Helper('advancedexport');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function processexportAction()
|
29 |
+
{
|
30 |
+
$helper = Mage::Helper('advancedexport');
|
31 |
+
if (!$helper->getIsExtEnabledForApi()) {
|
32 |
+
return false;
|
33 |
+
}
|
34 |
+
|
35 |
+
// + Execution Time + Memory Limit
|
36 |
+
set_time_limit(99999999);
|
37 |
+
ini_set('memory_limit', $helper->getMemoryLimit() . 'M');
|
38 |
+
|
39 |
+
$entityToExport = $this->getRequest()->getParam('export_entity', false);
|
40 |
+
$batchsize = $this->getRequest()->getParam('batch_size', false);
|
41 |
+
$tempfile = $this->getRequest()->getParam('tempfile', false);
|
42 |
+
$batchesfile = $this->getRequest()->getParam('batchesfile', false);
|
43 |
+
$dateTimeInit = $this->getRequest()->getParam('datetimeinit', '');
|
44 |
+
|
45 |
+
$websiteToExport = $this->getRequest()->getParam('website_id', 1);
|
46 |
+
|
47 |
+
$lastExportedStepInfo = array(
|
48 |
+
'last_entity_value' => $this->getRequest()
|
49 |
+
->getParam('last_entity_value', 0),
|
50 |
+
'last_record_value' => $this->getRequest()
|
51 |
+
->getParam('last_record_value', 0),
|
52 |
+
);
|
53 |
+
|
54 |
+
$fatal = false;
|
55 |
+
|
56 |
+
try {
|
57 |
+
//Read the temp file to get the data entityids
|
58 |
+
//that need files generated
|
59 |
+
$fileFullPath = Mage::getBaseDir() . DS .
|
60 |
+
$helper->getExportfolder() . DS .
|
61 |
+
'tempFiles' . DS . $tempfile;
|
62 |
+
$fileContent = file_get_contents($fileFullPath);
|
63 |
+
$dataCollection = unserialize($fileContent);
|
64 |
+
|
65 |
+
//Read the temp file to get the where
|
66 |
+
//we write the contents into a file
|
67 |
+
$fileFullPathBatch = Mage::getBaseDir() . DS .
|
68 |
+
$helper->getExportfolder() . DS .
|
69 |
+
'tempFiles' . DS . $batchesfile;
|
70 |
+
$fileContentBatches = file_get_contents($fileFullPathBatch);
|
71 |
+
$batchesFiles = unserialize($fileContentBatches);
|
72 |
+
} catch (Exception $e) {
|
73 |
+
$exportStepResult['error'] =
|
74 |
+
'[EXCEPTION] - Can not create temp Files. '
|
75 |
+
. 'Check Premissins for '
|
76 |
+
. $helper->getExportfolder()
|
77 |
+
. ' and advancedexport/tempFiles Folders. ';
|
78 |
+
$exportStepResult['error_fatal'] = true;
|
79 |
+
$fatal = true;
|
80 |
+
Mage::log(
|
81 |
+
'Can not [CREATE] temp Files. Check permissions for '
|
82 |
+
. $helper->getExportfolder()
|
83 |
+
. ' and advancedexport/tempFiles Folders'
|
84 |
+
. $e->getMessage() . ' '
|
85 |
+
. $e->getFile() . '::'
|
86 |
+
. (string) $e->getLine(),
|
87 |
+
1,
|
88 |
+
'freestyle.log'
|
89 |
+
);
|
90 |
+
}
|
91 |
+
|
92 |
+
if (!$fatal) {
|
93 |
+
//now generate the files
|
94 |
+
$fsAbstract = Mage::getModel(
|
95 |
+
'advancedexport/exportmodels_abstract'
|
96 |
+
);
|
97 |
+
$exportStepResult = $fsAbstract
|
98 |
+
->getExportDataMemoryControll(
|
99 |
+
$entityToExport,
|
100 |
+
$batchsize,
|
101 |
+
$dataCollection,
|
102 |
+
$tempfile,
|
103 |
+
$dateTimeInit,
|
104 |
+
$lastExportedStepInfo,
|
105 |
+
$batchesFiles,
|
106 |
+
$websiteToExport
|
107 |
+
);
|
108 |
+
file_put_contents(
|
109 |
+
$fileFullPathBatch,
|
110 |
+
serialize($exportStepResult['batches_files'])
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
$this->getResponse()->setBody(serialize($exportStepResult));
|
115 |
+
}
|
116 |
+
|
117 |
+
/* Action For Processing Api call */
|
118 |
+
|
119 |
+
public function startApiExportAction()
|
120 |
+
{
|
121 |
+
if (!$this->getHelper()->getIsExtEnabledForApi()) {
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
|
125 |
+
$fatal = false;
|
126 |
+
|
127 |
+
$this->exportErrors = array();
|
128 |
+
$helper = $this->getHelper();
|
129 |
+
|
130 |
+
$entityToExport = $this->getRequest()->getParam('export_entity', false);
|
131 |
+
$startDate = $this->getRequest()->getParam('date_start', false);
|
132 |
+
$endDate = $this->getRequest()->getParam('date_end', false);
|
133 |
+
$idsToExport = (string) $this->getRequest()
|
134 |
+
->getParam('ids_to_export', '');
|
135 |
+
$batchsize = (int) $this->getRequest()
|
136 |
+
->getParam('batch_size', self::MAX_BATCH_SIZE);
|
137 |
+
//$requestId = (int) $this->getRequest()->getParam('requestid', false);
|
138 |
+
|
139 |
+
if (!$batchsize) {
|
140 |
+
$batchsize = self::MAX_BATCH_SIZE;
|
141 |
+
}
|
142 |
+
|
143 |
+
$date = $helper->getCurrentTime();
|
144 |
+
$dateTimeStart = new DateTime();
|
145 |
+
|
146 |
+
$priority = $helper
|
147 |
+
->getParamsPriority($startDate, $endDate, $idsToExport);
|
148 |
+
$fsAbstract = Mage::getModel('advancedexport/exportmodels_abstract');
|
149 |
+
$dataCollection = $fsAbstract
|
150 |
+
->getEntityIdsCollection($entityToExport, $priority)->getData();
|
151 |
+
|
152 |
+
|
153 |
+
$file = 'datatemp' . $date . '.txt';
|
154 |
+
$filesBatchArray = 'batchFiles' . $date . '.txt';
|
155 |
+
|
156 |
+
try {
|
157 |
+
$premissionsResult = $helper->checkFoldersPremissions();
|
158 |
+
if (!$premissionsResult) {
|
159 |
+
$fatal = true;
|
160 |
+
$this->exportErrors[] =
|
161 |
+
'Can Not put File To "tempFiles" or '
|
162 |
+
. '"advancedexport" Folder. Check Premissions';
|
163 |
+
Mage::log(
|
164 |
+
'Can Not put File To "tempFiles" or '
|
165 |
+
. '"advancedexport" Folder. Check Premissions',
|
166 |
+
1,
|
167 |
+
'freestyle.log'
|
168 |
+
);
|
169 |
+
} else {
|
170 |
+
$tempfile = Mage::getBaseDir() . DS .
|
171 |
+
$helper->getExportfolder() . DS .
|
172 |
+
'tempFiles' . DS . $file;
|
173 |
+
$putResult = file_put_contents(
|
174 |
+
$tempfile,
|
175 |
+
serialize($dataCollection)
|
176 |
+
);
|
177 |
+
|
178 |
+
$tempfileBatches = Mage::getBaseDir() . DS .
|
179 |
+
$helper->getExportfolder() . DS .
|
180 |
+
'tempFiles' . DS . $filesBatchArray;
|
181 |
+
$putResult = file_put_contents(
|
182 |
+
$tempfileBatches,
|
183 |
+
serialize(array())
|
184 |
+
);
|
185 |
+
}
|
186 |
+
} catch (Exception $e) {
|
187 |
+
$this->exportErrors[] = 'Can Not put File To "tempFiles" or '
|
188 |
+
. '"advancedexport" Folder. Check permissions';
|
189 |
+
Mage::log(
|
190 |
+
'Can not [WRITE] to "tempFiles" or '
|
191 |
+
. '"advancedexport" Folder. Check permissions',
|
192 |
+
1,
|
193 |
+
'freestyle.log'
|
194 |
+
);
|
195 |
+
$fatal = true;
|
196 |
+
}
|
197 |
+
|
198 |
+
/* + Execution Time + Memory Limit */
|
199 |
+
ini_set('default_socket_timeout', self::MAX_SOCKET_TIME_OUT);
|
200 |
+
set_time_limit(self::MAX_PROCESS_TIME_LIMIT);
|
201 |
+
ini_set('memory_limit', $helper->getMemoryLimit() . 'M');
|
202 |
+
|
203 |
+
$url = Mage::getUrl(
|
204 |
+
'advancedexport/frontprocess/processexport',
|
205 |
+
array('_secure' => true)
|
206 |
+
) . '?export_entity=' . $entityToExport
|
207 |
+
. '&batch_size=' . $batchsize
|
208 |
+
. '&tempfile=' . $file
|
209 |
+
. '&batchesfile=' . $filesBatchArray
|
210 |
+
. '&datetimeinit=' . $date;
|
211 |
+
|
212 |
+
$stepCounter = 0;
|
213 |
+
|
214 |
+
if (!$fatal) {
|
215 |
+
do {
|
216 |
+
$httpResult = file_get_contents($url);
|
217 |
+
$goFromRequests = false;
|
218 |
+
|
219 |
+
if (!$httpResult) {
|
220 |
+
$this->exportErrors[] = 'Server Response Error';
|
221 |
+
Mage::log(
|
222 |
+
'[WARNING] - Server Response Error ' . $e->getMessage()
|
223 |
+
. ' ' .$e->getFile().'::'.(string)$e->getLine(),
|
224 |
+
1,
|
225 |
+
'freestyle.log'
|
226 |
+
);
|
227 |
+
}
|
228 |
+
|
229 |
+
try {
|
230 |
+
$structure = unserialize($httpResult);
|
231 |
+
|
232 |
+
if (isset($structure['error_fatal'])) {
|
233 |
+
if (count($structure['error'])) {
|
234 |
+
foreach ($structure['error'] as $one) {
|
235 |
+
$this->exportErrors[] = $one;
|
236 |
+
Mage::log($one, 1, 'freestyle.log');
|
237 |
+
}
|
238 |
+
}
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
|
242 |
+
if (!$structure['export_finished']) {
|
243 |
+
|
244 |
+
// Add Params To Url For Next Step
|
245 |
+
$url .= '&last_entity_value='
|
246 |
+
. $structure['last_exported_info']['value']
|
247 |
+
. '&last_record_value='
|
248 |
+
. $structure['last_exported_info']
|
249 |
+
['record_number'];
|
250 |
+
Mage::log(
|
251 |
+
'[INFO] - ' . $stepCounter . '. Export Next Step. '
|
252 |
+
. 'Record Start : '
|
253 |
+
. $structure['last_exported_info']['record_number'],
|
254 |
+
1,
|
255 |
+
'freestyle.log'
|
256 |
+
);
|
257 |
+
}
|
258 |
+
|
259 |
+
if (count($structure['error'])) {
|
260 |
+
foreach ($structure['error'] as $one) {
|
261 |
+
$this->exportErrors[] = $one;
|
262 |
+
Mage::log($one, 1, 'freestyle.log');
|
263 |
+
}
|
264 |
+
}
|
265 |
+
} catch (Exception $e) {
|
266 |
+
$this->exportErrors[] = 'Server Response Error';
|
267 |
+
Mage::log(
|
268 |
+
'[EXCEPTION] - Server Response Error '
|
269 |
+
. $e->getMessage(). ' ' .$e->getFile() . '::'
|
270 |
+
. (string)$e->getLine(),
|
271 |
+
1,
|
272 |
+
'freestyle.log'
|
273 |
+
);
|
274 |
+
Mage::log(
|
275 |
+
'[EXCEPTION] - Server Response: ' . $httpResult,
|
276 |
+
1,
|
277 |
+
'freestyle.log'
|
278 |
+
);
|
279 |
+
|
280 |
+
$goFromRequests = true;
|
281 |
+
$structure['action'] = 'end';
|
282 |
+
$structure['export_finished'] = 1;
|
283 |
+
}
|
284 |
+
|
285 |
+
$stepCounter++;
|
286 |
+
} while (($structure['action'] == 'next_step') && (!$structure['export_finished']) && (!$goFromRequests));
|
287 |
+
}
|
288 |
+
|
289 |
+
|
290 |
+
$dateTimeEnd = new DateTime();
|
291 |
+
|
292 |
+
/* Save Export To History */
|
293 |
+
if (isset($structure['zip_file'])) {
|
294 |
+
$fileResult = $structure['zip_file'];
|
295 |
+
} else {
|
296 |
+
$fileResult = array();
|
297 |
+
}
|
298 |
+
|
299 |
+
$historyModel = Mage::getModel('advancedexport/history');
|
300 |
+
$historyData['export_date'] = $dateTimeStart
|
301 |
+
->format('Y-m-d H:i:s');
|
302 |
+
$historyData['export_date_time_start'] = $dateTimeStart
|
303 |
+
->format('Y-m-d H:i:s');
|
304 |
+
$historyData['export_date_time_end'] = $dateTimeEnd
|
305 |
+
->format('Y-m-d H:i:s');
|
306 |
+
$historyData['created_files'] = serialize($fileResult);
|
307 |
+
$historyData['init_from'] = 'API Request';
|
308 |
+
$historyData['export_entity'] = $entityToExport;
|
309 |
+
$historyData['errors'] = serialize($this->exportErrors);
|
310 |
+
$historyModel->setData($historyData);
|
311 |
+
$historyModel->save();
|
312 |
+
|
313 |
+
/* Send Notification To NextGen */
|
314 |
+
$fileLink = 'bad_file';
|
315 |
+
if (isset($fileResult[0])) {
|
316 |
+
if ($fileResult[0]) {
|
317 |
+
$fileLink = $fileResult[0];
|
318 |
+
}
|
319 |
+
}
|
320 |
+
Mage::helper('advancedexport/notificationSender')
|
321 |
+
->setIsApiCall(true)
|
322 |
+
->sendNotification($entityToExport, $entityId = -1, $fileLink);
|
323 |
+
}
|
324 |
+
}
|
app/code/community/Freestyle/Advancedexport/controllers/IndexController.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_IndexController
|
14 |
+
extends Mage_Core_Controller_Front_Action
|
15 |
+
{
|
16 |
+
public function getHelper()
|
17 |
+
{
|
18 |
+
return Mage::Helper('advancedexport');
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getallshipmethAction()
|
22 |
+
{
|
23 |
+
$isEnabled = $this->getHelper()->getIsExtEnabledForApi();
|
24 |
+
if (!$isEnabled) {
|
25 |
+
// extension is not enabled.. redirect to 404
|
26 |
+
Mage::app()->getFrontController()
|
27 |
+
->getResponse()
|
28 |
+
->setHeader('HTTP/1.1', '404 Not Found', true);
|
29 |
+
Mage::app()->getFrontController()
|
30 |
+
->getResponse()
|
31 |
+
->setHeader('Status', '404 File not found', true);
|
32 |
+
|
33 |
+
$pageId = Mage::getStoreConfig('web/default/cms_no_route');
|
34 |
+
//$pageId = Mage::getStoreConfig('cms/index/noRoute');
|
35 |
+
//$url = rtrim(Mage::getUrl($pageId), '/');
|
36 |
+
//$url = Mage::helper('core/url')->getCurrentUrl();
|
37 |
+
//Mage::app()->getFrontController()
|
38 |
+
//->getResponse()
|
39 |
+
//->setRedirect($url,404);
|
40 |
+
if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
|
41 |
+
$this->_forward('defaultNoRoute');
|
42 |
+
}
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
//get ChannelId
|
47 |
+
//$ChannelID = $this->getHelper()->getChanelId();
|
48 |
+
$salesChannelIds = Mage::Helper('advancedexport/website')
|
49 |
+
->getWebsitesUtils(true);
|
50 |
+
$paramChannelID = (string) $this->getRequest()
|
51 |
+
->getPost('channelid', '');
|
52 |
+
|
53 |
+
if (!in_array($paramChannelID, $salesChannelIds)) {
|
54 |
+
//if (1 == 2) {
|
55 |
+
header('Content-type: text/xml');
|
56 |
+
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
57 |
+
'<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
|
58 |
+
. ' xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . "\n";
|
59 |
+
echo '<error>Invalid Parameter</error>';
|
60 |
+
echo "</data>";
|
61 |
+
} else {
|
62 |
+
try {
|
63 |
+
$methods = Mage::getSingleton('shipping/config')
|
64 |
+
->getAllCarriers();
|
65 |
+
} catch (Exception $e) {
|
66 |
+
Mage::log("Unable to call getAllCarriers", 1, "freestyle.log");
|
67 |
+
$methods = false;
|
68 |
+
}
|
69 |
+
|
70 |
+
$xmlstr = "<?xml version='1.0' encoding='UTF-8'?>"
|
71 |
+
. "<data xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
|
72 |
+
. " xmlns:xsd='http://www.w3.org/2001/XMLSchema'></data>";
|
73 |
+
//$shipxml = new SimpleXMLElement($xmlstr);
|
74 |
+
$shipxml =
|
75 |
+
new Freestyle_Advancedexport_Model_Exportmodels_SimpleXMLExtended($xmlstr);
|
76 |
+
|
77 |
+
if ($methods) {
|
78 |
+
foreach ($methods as $ccode => $carrier) {
|
79 |
+
//print "$_ccode => $_carrier\n";
|
80 |
+
try {
|
81 |
+
if ($_methods = $carrier->getAllowedMethods()) {
|
82 |
+
!$titleCheck =
|
83 |
+
Mage::getStoreConfig("carriers/$ccode/title");
|
84 |
+
if ($titleCheck) {
|
85 |
+
$_title = $ccode;
|
86 |
+
}
|
87 |
+
foreach ($_methods as $jmcode => $jmethod) {
|
88 |
+
$ucode = $ccode . '_' . $jmcode;
|
89 |
+
$shippingmethod =
|
90 |
+
$shipxml->addChild('ShippingMethod');
|
91 |
+
$shippingmethod
|
92 |
+
->addChild('magentoID')
|
93 |
+
->addCData($ucode);
|
94 |
+
$shippingmethod
|
95 |
+
->addChild('title')
|
96 |
+
->addCData($jmethod);
|
97 |
+
$shippingmethod
|
98 |
+
->addChild('carrier')
|
99 |
+
->addCData($_title);
|
100 |
+
$shippingmethod->addChild('active', 0);
|
101 |
+
$shippingmethod->addChild('website_id', 1);
|
102 |
+
//->addChild($keyToAdd)->addCData($value)
|
103 |
+
}//foreach ($_methods as $_mcode => $_method)
|
104 |
+
}//if ($_methods = $_carrier->getAllowedMethods())
|
105 |
+
} catch (Exception $e) {
|
106 |
+
Mage::log(
|
107 |
+
"Unable to iterate through shipping methods. "
|
108 |
+
. $e->getMessage(),
|
109 |
+
1,
|
110 |
+
"freestyle.log"
|
111 |
+
);
|
112 |
+
}//try
|
113 |
+
}//foreach ($methods as $_ccode => $_carrier)
|
114 |
+
}
|
115 |
+
|
116 |
+
//get the active shipping methods
|
117 |
+
//find xml and update node;
|
118 |
+
try {
|
119 |
+
$methods = Mage::getSingleton('shipping/config')
|
120 |
+
->getActiveCarriers();
|
121 |
+
} catch (Exception $e) {
|
122 |
+
Mage::log("Unable to call getAllCarriers", 1, "freestyle.log");
|
123 |
+
$methods = false;
|
124 |
+
}
|
125 |
+
|
126 |
+
if ($methods) {
|
127 |
+
foreach ($methods as $ccode => $carrier) {
|
128 |
+
//print "$_ccode => $_carrier\n";
|
129 |
+
try {
|
130 |
+
if ($_methods = $carrier->getAllowedMethods()) {
|
131 |
+
$checkTitle = !$_title
|
132 |
+
= Mage::getStoreConfig("carriers/$ccode/title");
|
133 |
+
if ($checkTitle) {
|
134 |
+
$_title = $ccode;
|
135 |
+
}
|
136 |
+
foreach ($_methods as $jmcode => $jmethod) {
|
137 |
+
$ucode = $ccode . '_' . $jmcode;
|
138 |
+
$pathVal = "/data/ShippingMethod"
|
139 |
+
. "[magentoID = \"$ucode\"]";
|
140 |
+
$result = $shipxml
|
141 |
+
->xpath($pathVal);
|
142 |
+
//print_r($result);
|
143 |
+
$result[0]->active = 1;
|
144 |
+
//echo $result."\n";
|
145 |
+
}
|
146 |
+
}
|
147 |
+
} catch (Exception $e) {
|
148 |
+
Mage::log(
|
149 |
+
"Unable to iterate Active through shipping methods."
|
150 |
+
. " " . $e->getMessage(),
|
151 |
+
1,
|
152 |
+
"freestyle.log"
|
153 |
+
);
|
154 |
+
}//try
|
155 |
+
}//foreach ($methods as $_ccode => $_carrier)
|
156 |
+
}//if($methods)
|
157 |
+
//$methods = Mage::getSingleton('shipping/config')
|
158 |
+
//->getActiveCarriers();
|
159 |
+
header('Content-type: text/xml');
|
160 |
+
echo $shipxml->asXML();
|
161 |
+
//Mage::app()->getResponse()->setBody($result);
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
app/code/community/Freestyle/Advancedexport/controllers/StatusController.php
ADDED
@@ -0,0 +1,436 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_StatusController
|
14 |
+
extends Mage_Core_Controller_Front_Action
|
15 |
+
{
|
16 |
+
|
17 |
+
/**
|
18 |
+
* DE-11782: Health Check Ability
|
19 |
+
*/
|
20 |
+
public function queueAction()
|
21 |
+
{
|
22 |
+
try {
|
23 |
+
$helper = $this->getHelper();
|
24 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
25 |
+
if (!$isEnabled) {
|
26 |
+
// extension is not enabled.. redirect to 404
|
27 |
+
$this->render404();
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
32 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
33 |
+
|
34 |
+
$paramStart = $this->getRequest()->getPost('start', '');
|
35 |
+
$paramEnd = $this->getRequest()->getPost('end', '');
|
36 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
37 |
+
//api credentials check out!
|
38 |
+
$queueModel = Mage::getModel('advancedexport/queue');
|
39 |
+
$siteData = json_encode(
|
40 |
+
$queueModel->getEntityQueue($paramStart, $paramEnd)
|
41 |
+
);
|
42 |
+
header('Content-Type: application/json');
|
43 |
+
echo $siteData;
|
44 |
+
} else {
|
45 |
+
//authentication failed
|
46 |
+
header('Content-type: text/plain');
|
47 |
+
echo "Invalid Parameter.";
|
48 |
+
}
|
49 |
+
} catch (Exception $ex) {
|
50 |
+
Mage::log(
|
51 |
+
"[EXCEPTION] - An Error Occured on "
|
52 |
+
. "Freestyle_Advancedexport_StatusController->queueAction: "
|
53 |
+
. $ex->getMessage(),
|
54 |
+
1,
|
55 |
+
"freestyle.log"
|
56 |
+
);
|
57 |
+
header('Content-type: text/plain');
|
58 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getqueuecollectionAction()
|
63 |
+
{
|
64 |
+
try {
|
65 |
+
$helper = $this->getHelper();
|
66 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
67 |
+
if (!$isEnabled) {
|
68 |
+
// extension is not enabled.. redirect to 404
|
69 |
+
$this->render404();
|
70 |
+
return;
|
71 |
+
}
|
72 |
+
|
73 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
74 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
75 |
+
|
76 |
+
$paramStart = $this->getRequest()->getPost('start', '');
|
77 |
+
$paramEnd = $this->getRequest()->getPost('end', '');
|
78 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
79 |
+
//api credentials check out!
|
80 |
+
$queueModel = Mage::getModel('advancedexport/queue');
|
81 |
+
$siteData = json_encode(
|
82 |
+
$queueModel->getEntityQueue($paramStart, $paramEnd)
|
83 |
+
);
|
84 |
+
header('Content-Type: application/json');
|
85 |
+
echo $siteData;
|
86 |
+
} else {
|
87 |
+
//authentication failed
|
88 |
+
header('Content-type: text/plain');
|
89 |
+
echo "Invalid Parameter.";
|
90 |
+
}
|
91 |
+
} catch (Exception $ex) {
|
92 |
+
Mage::log(
|
93 |
+
"[EXCEPTION] - An Error Occured on "
|
94 |
+
. "Freestyle_Advancedexport_StatusController->queueAction: "
|
95 |
+
. $ex->getMessage(),
|
96 |
+
1,
|
97 |
+
"freestyle.log"
|
98 |
+
);
|
99 |
+
header('Content-type: text/plain');
|
100 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
public function checkcronAction()
|
105 |
+
{
|
106 |
+
try {
|
107 |
+
$helper = $this->getHelper();
|
108 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
109 |
+
if (!$isEnabled) {
|
110 |
+
// extension is not enabled.. redirect to 404
|
111 |
+
$this->render404();
|
112 |
+
return;
|
113 |
+
}
|
114 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
115 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
116 |
+
|
117 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
118 |
+
//api credentials check out!
|
119 |
+
//get the resource model
|
120 |
+
$resource = Mage::getSingleton('core/resource');
|
121 |
+
|
122 |
+
//retrieve the read connection
|
123 |
+
$readConnection = $resource->getConnection('core_read');
|
124 |
+
|
125 |
+
//retrieve the table name
|
126 |
+
$table = $resource->getTableName('cron/schedule');
|
127 |
+
|
128 |
+
//SELECT Statement
|
129 |
+
$query = 'SELECT * FROM ' . $table . ' WHERE `job_code` '
|
130 |
+
. 'like \'advancedexport_%\' AND status != \'success\';';
|
131 |
+
|
132 |
+
//execute the query
|
133 |
+
$result = $readConnection->fetchAll($query);
|
134 |
+
$siteData = json_encode($result);
|
135 |
+
|
136 |
+
header('Content-Type: application/json');
|
137 |
+
echo $siteData;
|
138 |
+
} else {
|
139 |
+
//authentication failed
|
140 |
+
header('Content-type: text/plain');
|
141 |
+
echo "Invalid Parameter.";
|
142 |
+
}
|
143 |
+
} catch (Exception $ex) {
|
144 |
+
Mage::log(
|
145 |
+
"[EXCEPTION] - An Error Occured on "
|
146 |
+
. "Freestyle_Advancedexport_StatusController->checkcronAction: "
|
147 |
+
. $ex->getMessage(),
|
148 |
+
1,
|
149 |
+
"freestyle.log"
|
150 |
+
);
|
151 |
+
header('Content-type: text/plain');
|
152 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
public function readlogAction()
|
157 |
+
{
|
158 |
+
try {
|
159 |
+
$helper = $this->getHelper();
|
160 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
161 |
+
if (!$isEnabled) {
|
162 |
+
// extension is not enabled.. redirect to 404
|
163 |
+
$this->render404();
|
164 |
+
return;
|
165 |
+
}
|
166 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
167 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
168 |
+
|
169 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
170 |
+
//api credentials check out!
|
171 |
+
header('Content-Type: text/plain');
|
172 |
+
echo $helper->readLogFile(true);
|
173 |
+
} else {
|
174 |
+
//authentication failed
|
175 |
+
header('Content-type: text/plain');
|
176 |
+
echo "Invalid Parameter.";
|
177 |
+
}
|
178 |
+
} catch (Exception $ex) {
|
179 |
+
Mage::log(
|
180 |
+
"[EXCEPTION] - An Error Occured on "
|
181 |
+
. "Freestyle_Advancedexport_StatusController->readlogAction: "
|
182 |
+
. $ex->getMessage(),
|
183 |
+
1,
|
184 |
+
"freestyle.log"
|
185 |
+
);
|
186 |
+
header('Content-type: text/plain');
|
187 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
public function checkconfigAction()
|
192 |
+
{
|
193 |
+
try {
|
194 |
+
$helper = $this->getHelper();
|
195 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
196 |
+
if (!$isEnabled) {
|
197 |
+
// extension is not enabled.. redirect to 404
|
198 |
+
$this->render404();
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
202 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
203 |
+
|
204 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
205 |
+
//api credentials check out!
|
206 |
+
//get the resource model
|
207 |
+
$resource = Mage::getSingleton('core/resource');
|
208 |
+
|
209 |
+
//retrieve the read connection
|
210 |
+
$readConnection = $resource->getConnection('core_read');
|
211 |
+
|
212 |
+
//retrieve the table name
|
213 |
+
$table = $resource->getTableName('core/config_data');
|
214 |
+
|
215 |
+
//SELECT Statement
|
216 |
+
$query = 'SELECT * FROM ' . $table
|
217 |
+
. ' WHERE `path` like \'freestyle_advancedexport_%\';';
|
218 |
+
|
219 |
+
//execute the query
|
220 |
+
$result = $readConnection->fetchAll($query);
|
221 |
+
|
222 |
+
$siteData = json_encode($result);
|
223 |
+
|
224 |
+
header('Content-Type: application/json');
|
225 |
+
echo $siteData;
|
226 |
+
} else {
|
227 |
+
//authentication failed
|
228 |
+
header('Content-type: text/plain');
|
229 |
+
echo "Invalid Parameter.";
|
230 |
+
}
|
231 |
+
} catch (Exception $ex) {
|
232 |
+
Mage::log(
|
233 |
+
"[EXCEPTION] - An Error Occured on "
|
234 |
+
. "Freestyle_Advancedexport_StatusController->"
|
235 |
+
. "checkconfigAction: "
|
236 |
+
. $ex->getMessage(),
|
237 |
+
1,
|
238 |
+
"freestyle.log"
|
239 |
+
);
|
240 |
+
header('Content-type: text/plain');
|
241 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
public function checkextensionAction()
|
246 |
+
{
|
247 |
+
try {
|
248 |
+
$helper = $this->getHelper();
|
249 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
250 |
+
if (!$isEnabled) {
|
251 |
+
// extension is not enabled.. redirect to 404
|
252 |
+
$this->render404();
|
253 |
+
return;
|
254 |
+
}
|
255 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
256 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
257 |
+
|
258 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
259 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
260 |
+
$modulesArray = (array) $modules;
|
261 |
+
|
262 |
+
//$siteData = json_encode($modulesArray);
|
263 |
+
//header('Content-Type: application/json');
|
264 |
+
//echo $siteData;
|
265 |
+
header('Content-type: text/plain');
|
266 |
+
while ($myExtension = current($modulesArray)) {
|
267 |
+
if (!strstr(key($modulesArray), "Mage_")) {
|
268 |
+
echo key($modulesArray) . "\n";
|
269 |
+
}
|
270 |
+
next($modulesArray);
|
271 |
+
}
|
272 |
+
} else {
|
273 |
+
//authentication failed
|
274 |
+
header('Content-type: text/plain');
|
275 |
+
echo "Invalid Parameter.";
|
276 |
+
}
|
277 |
+
} catch (Exception $ex) {
|
278 |
+
Mage::log(
|
279 |
+
"[EXCEPTION] - An Error Occured on "
|
280 |
+
. "Freestyle_Advancedexport_StatusController->"
|
281 |
+
. "checkextensionAction: "
|
282 |
+
. $ex->getMessage(),
|
283 |
+
1,
|
284 |
+
"freestyle.log"
|
285 |
+
);
|
286 |
+
header('Content-type: text/plain');
|
287 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
public function magecheckAction()
|
292 |
+
{
|
293 |
+
try {
|
294 |
+
$helper = $this->getHelper();
|
295 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
296 |
+
if (!$isEnabled) {
|
297 |
+
// extension is not enabled.. redirect to 404
|
298 |
+
$this->render404();
|
299 |
+
return;
|
300 |
+
}
|
301 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
302 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
303 |
+
|
304 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
305 |
+
//do the work here
|
306 |
+
header('Content-type: text/plain');
|
307 |
+
echo $this->extension_check(
|
308 |
+
array(
|
309 |
+
'curl',
|
310 |
+
'dom',
|
311 |
+
'gd',
|
312 |
+
'hash',
|
313 |
+
'iconv',
|
314 |
+
'mcrypt',
|
315 |
+
'pcre',
|
316 |
+
'pdo',
|
317 |
+
'pdo_mysql',
|
318 |
+
'simplexml',
|
319 |
+
'soap'
|
320 |
+
)
|
321 |
+
);
|
322 |
+
} else {
|
323 |
+
//authentication failed
|
324 |
+
header('Content-type: text/plain');
|
325 |
+
echo "Invalid Parameter.";
|
326 |
+
}
|
327 |
+
} catch (Exception $ex) {
|
328 |
+
Mage::log(
|
329 |
+
"[EXCEPTION] - An Error Occured on "
|
330 |
+
. "Freestyle_Advancedexport_StatusController->"
|
331 |
+
. "checkextensionAction: " . $ex->getMessage(),
|
332 |
+
1,
|
333 |
+
"freestyle.log"
|
334 |
+
);
|
335 |
+
header('Content-type: text/plain');
|
336 |
+
echo "An Error Occurred. Please review the log files if enabled.";
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
protected function getHelper()
|
341 |
+
{
|
342 |
+
return Mage::Helper('advancedexport');
|
343 |
+
}
|
344 |
+
|
345 |
+
protected function extension_check($extensions)
|
346 |
+
{
|
347 |
+
$fail = '';
|
348 |
+
$pass = '';
|
349 |
+
|
350 |
+
$returnMsg = '';
|
351 |
+
|
352 |
+
if (version_compare(phpversion(), '5.2.0', '<')) {
|
353 |
+
$fail .= '<li>You need<strong> PHP 5.2.0</strong>'
|
354 |
+
. ' (or greater)</li>';
|
355 |
+
} else {
|
356 |
+
$pass .='<li>You have<strong> PHP 5.2.0</strong>'
|
357 |
+
. ' (or greater)</li>';
|
358 |
+
}
|
359 |
+
|
360 |
+
if (!ini_get('safe_mode')) {
|
361 |
+
$pass .='<li>Safe Mode is <strong>off</strong></li>';
|
362 |
+
preg_match(
|
363 |
+
'/[0-9]\.[0-9]+\.[0-9]+/',
|
364 |
+
shell_exec('mysql -V'),
|
365 |
+
$version
|
366 |
+
);
|
367 |
+
|
368 |
+
if (version_compare($version[0], '4.1.20', '<')) {
|
369 |
+
$fail .= '<li>You need<strong> MySQL 4.1.20</strong>'
|
370 |
+
. ' (or greater)</li>';
|
371 |
+
} else {
|
372 |
+
$pass .='<li>You have<strong> MySQL 4.1.20</strong>'
|
373 |
+
. ' (or greater)</li>';
|
374 |
+
}
|
375 |
+
} else {
|
376 |
+
$fail .= '<li>Safe Mode is <strong>on</strong></li>';
|
377 |
+
}
|
378 |
+
|
379 |
+
if (!ini_get('allow_url_fopen')) {
|
380 |
+
$fail .= '<li>You need<strong> allow_url_fopen</strong>'
|
381 |
+
. ' enabled</li>';
|
382 |
+
} else {
|
383 |
+
$pass .='<li>You have<strong> allow_url_fopen</strong>'
|
384 |
+
. ' enabled</li>';
|
385 |
+
}
|
386 |
+
|
387 |
+
if (class_exists('ZipArchive')) {
|
388 |
+
$pass .='<li>You have<strong> ZipArchive</strong> enabled</li>';
|
389 |
+
} else {
|
390 |
+
$fail .= '<li>You need<strong> ZipArchive</strong> enabled</li>';
|
391 |
+
}
|
392 |
+
foreach ($extensions as $extension) {
|
393 |
+
if (!extension_loaded($extension)) {
|
394 |
+
$fail .= '<li> You are missing the <strong>'
|
395 |
+
. $extension . '</strong> extension</li>';
|
396 |
+
} else {
|
397 |
+
$pass .= '<li>You have the <strong>'
|
398 |
+
. $extension . '</strong> extension</li>';
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
if ($fail) {
|
403 |
+
$returnMsg = '<p><strong>Your server does not meet the following'
|
404 |
+
. ' requirements in order to install Magento.</strong>'
|
405 |
+
. '<br>The following requirements failed, please contact '
|
406 |
+
. 'your hosting provider in order to receive assistance '
|
407 |
+
. 'with meeting the system requirements for Magento:'
|
408 |
+
. '<ul>' . $fail . '</ul></p>'
|
409 |
+
. 'The following requirements were successfully met:'
|
410 |
+
. '<ul>' . $pass . '</ul>';
|
411 |
+
} else {
|
412 |
+
$returnMsg = '<p><strong>Congratulations!</strong> '
|
413 |
+
. 'Your server meets the requirements for Magento.</p>'
|
414 |
+
. '<ul>' . $pass . '</ul>';
|
415 |
+
}
|
416 |
+
return $returnMsg;
|
417 |
+
}
|
418 |
+
|
419 |
+
protected function render404()
|
420 |
+
{
|
421 |
+
Mage::app()->getFrontController()
|
422 |
+
->getResponse()
|
423 |
+
->setHeader('HTTP/1.1', '404 Not Found', true);
|
424 |
+
Mage::app()->getFrontController()
|
425 |
+
->getResponse()
|
426 |
+
->setHeader('Status', '404 File not found', true);
|
427 |
+
|
428 |
+
$pageId = Mage::getStoreConfig('web/default/cms_no_route');
|
429 |
+
//$url = rtrim(Mage::getUrl($pageId), '/');
|
430 |
+
|
431 |
+
if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
|
432 |
+
$this->_forward('defaultNoRoute');
|
433 |
+
}
|
434 |
+
return;
|
435 |
+
}
|
436 |
+
}
|
app/code/community/Freestyle/Advancedexport/controllers/WebsiteController.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
|
13 |
+
class Freestyle_Advancedexport_WebsiteController
|
14 |
+
extends Mage_Core_Controller_Front_Action
|
15 |
+
{
|
16 |
+
|
17 |
+
public function syncAction()
|
18 |
+
{
|
19 |
+
$helper = $this->getHelper();
|
20 |
+
$isEnabled = $helper->getIsExtEnabledForApi();
|
21 |
+
if (!$isEnabled) {
|
22 |
+
// extension is not enabled.. redirect to 404
|
23 |
+
Mage::app()->getFrontController()
|
24 |
+
->getResponse()
|
25 |
+
->setHeader('HTTP/1.1', '404 Not Found', true);
|
26 |
+
Mage::app()->getFrontController()
|
27 |
+
->getResponse()
|
28 |
+
->setHeader('Status', '404 File not found', true);
|
29 |
+
|
30 |
+
$pageId = Mage::getStoreConfig('web/default/cms_no_route');
|
31 |
+
//$url = rtrim(Mage::getUrl($pageId), '/');
|
32 |
+
|
33 |
+
if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
|
34 |
+
$this->_forward('defaultNoRoute');
|
35 |
+
}
|
36 |
+
return;
|
37 |
+
}
|
38 |
+
|
39 |
+
//we will have more than 1 channel id
|
40 |
+
//$paramChannelID = (string) $this->getRequest()
|
41 |
+
//->getPost('channelid', '');
|
42 |
+
$paramApiUser = $this->getRequest()->getPost('apiuser', '');
|
43 |
+
$paramApiKey = $this->getRequest()->getPost('apikey', '');
|
44 |
+
|
45 |
+
if ($helper->apiAuthenticate($paramApiUser, $paramApiKey)) {
|
46 |
+
//api credentials check out!
|
47 |
+
$siteData = json_encode(
|
48 |
+
Mage::Helper('advancedexport/website')->getWebsites()
|
49 |
+
);
|
50 |
+
header('Content-Type: application/json');
|
51 |
+
echo $siteData;
|
52 |
+
} else {
|
53 |
+
//we did not find a channel
|
54 |
+
header('Content-type: text/xml');
|
55 |
+
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
|
56 |
+
'<data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
|
57 |
+
. 'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' . "\n";
|
58 |
+
echo '<error>Invalid Parameter</error>';
|
59 |
+
echo "</data>";
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function getHelper()
|
64 |
+
{
|
65 |
+
return Mage::Helper('advancedexport');
|
66 |
+
}
|
67 |
+
}
|
app/code/community/Freestyle/Advancedexport/etc/adminhtml.xml
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<menu>
|
15 |
+
<freestyle_advancedexport translate="title" module="advancedexport">
|
16 |
+
<title>Freestyle</title>
|
17 |
+
<sort_order>70</sort_order>
|
18 |
+
<children>
|
19 |
+
<exportblock translate="title">
|
20 |
+
<title>Advanced Export</title>
|
21 |
+
<!-- <action>advancedexport/adminhtml_index</action> -->
|
22 |
+
<action>adminhtml/advancedexport/index</action>
|
23 |
+
</exportblock>
|
24 |
+
</children>
|
25 |
+
</freestyle_advancedexport>
|
26 |
+
</menu>
|
27 |
+
<acl>
|
28 |
+
<resources>
|
29 |
+
<admin>
|
30 |
+
<children>
|
31 |
+
|
32 |
+
|
33 |
+
<freestyle_advancedexport translate="title" module="advancedexport">
|
34 |
+
<title>Freestyle Menu</title>
|
35 |
+
<sort_order>9999</sort_order>
|
36 |
+
<children>
|
37 |
+
<exportblock translate="title">
|
38 |
+
<title>Advanced Export</title>
|
39 |
+
</exportblock>
|
40 |
+
</children>
|
41 |
+
</freestyle_advancedexport>
|
42 |
+
|
43 |
+
|
44 |
+
<system>
|
45 |
+
<children>
|
46 |
+
<config>
|
47 |
+
<children>
|
48 |
+
<freestyle_advancedexport>
|
49 |
+
<title>Freestyle Advanced Export</title>
|
50 |
+
<sort_order>10</sort_order>
|
51 |
+
</freestyle_advancedexport>
|
52 |
+
</children>
|
53 |
+
</config>
|
54 |
+
</children>
|
55 |
+
</system>
|
56 |
+
</children>
|
57 |
+
</admin>
|
58 |
+
</resources>
|
59 |
+
</acl>
|
60 |
+
|
61 |
+
</config>
|
app/code/community/Freestyle/Advancedexport/etc/api.xml
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<!--
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
-->
|
13 |
+
<api>
|
14 |
+
<resources>
|
15 |
+
<advancedexport translate="title" module="advancedexport">
|
16 |
+
<title>Advanced Export Resource</title>
|
17 |
+
<acl>advancedexport</acl>
|
18 |
+
<model>advancedexport/api</model>
|
19 |
+
<methods>
|
20 |
+
<startexport translate="title" module="advancedexport">
|
21 |
+
<title>Start Export Process</title>
|
22 |
+
<acl>advancedexport/startexport</acl>
|
23 |
+
</startexport>
|
24 |
+
<getentityxml translate="title" module="advancedexport">
|
25 |
+
<title>Gets XML for specific Entity</title>
|
26 |
+
<acl>advancedexport/getentityxml</acl>
|
27 |
+
</getentityxml>
|
28 |
+
<getentityqueue translate="title" module="advancedexport">
|
29 |
+
<title>Gets Entity Queue</title>
|
30 |
+
<acl>advancedexport/getentityqueue</acl>
|
31 |
+
</getentityqueue>
|
32 |
+
<getextensionprofile translate="title" module="advancedexport">
|
33 |
+
<title>Gets Extension Profile</title>
|
34 |
+
<acl>advancedexprt/getextensionprofile</acl>
|
35 |
+
</getextensionprofile>
|
36 |
+
</methods>
|
37 |
+
<faults module="advancedexport">
|
38 |
+
<data_invalid>
|
39 |
+
<code>101</code >
|
40 |
+
<message>Invalid Export parameters. Details in error message.</message>
|
41 |
+
</data_invalid>
|
42 |
+
</faults>
|
43 |
+
</advancedexport>
|
44 |
+
<fsorder translate="title" module="advancedexport">
|
45 |
+
<title>Order Resource</title>
|
46 |
+
<model>freestyle_utilities/order_api</model>
|
47 |
+
<acl>fsorder</acl>
|
48 |
+
<methods>
|
49 |
+
<!-- INDIVIDUAL CALLS -->
|
50 |
+
<!--
|
51 |
+
<caninvoice translate="title" module="order">
|
52 |
+
<title>Check Invoice Availability of an Order</title>
|
53 |
+
<acl>fsorder/caninvoice</acl>
|
54 |
+
</caninvoice>
|
55 |
+
<canship translate="title" module="order">
|
56 |
+
<title>Check Shipping Availability of an Order</title>
|
57 |
+
<acl>fsorder/canship</acl>
|
58 |
+
</canship>
|
59 |
+
<cancreditmemo translate="title" module="order">
|
60 |
+
<title>Check Refund Availability of an Order</title>
|
61 |
+
<acl>fsorder/cancreditmemo</acl>
|
62 |
+
</cancreditmemo>
|
63 |
+
-->
|
64 |
+
<checkactions translate="title" module="advancedexport">
|
65 |
+
<title>Check Invoicing, Shipping, Refund Action Availability of an [Order].</title>
|
66 |
+
<acl>fsorder/checkactions</acl>
|
67 |
+
</checkactions>
|
68 |
+
</methods>
|
69 |
+
<faults module="advancedexport">
|
70 |
+
<data_invalid>
|
71 |
+
<code>100</code>
|
72 |
+
<message>Invalid order data. Details in error message.</message>
|
73 |
+
</data_invalid>
|
74 |
+
<filter_invalid>
|
75 |
+
<code>101</code>
|
76 |
+
<message>Invalid filters specfified. Details in error message.</message>
|
77 |
+
</filter_invalid>
|
78 |
+
<not_exists>
|
79 |
+
<code>102</code>
|
80 |
+
<message>Order does not exist.</message>
|
81 |
+
</not_exists>
|
82 |
+
<not_deleted>
|
83 |
+
<code>103</code>
|
84 |
+
<message>Order was not deleted. Details in error message.</message>
|
85 |
+
</not_deleted>
|
86 |
+
</faults>
|
87 |
+
</fsorder>
|
88 |
+
<fsinvoice>
|
89 |
+
<title>Invoice Resource</title>
|
90 |
+
<acl>fsinvoice</acl>
|
91 |
+
<model>freestyle_utilities/invoice_api</model>
|
92 |
+
<methods>
|
93 |
+
<cancapture translate="title" module="advancedexport">
|
94 |
+
<title>Check Capture Ability of an Invoice</title>
|
95 |
+
<acl>fsinvoice/cancapture</acl>
|
96 |
+
</cancapture>
|
97 |
+
</methods>
|
98 |
+
<faults module="advancedexport">
|
99 |
+
<data_invalid>
|
100 |
+
<code>100</code>
|
101 |
+
<message>Invalid invoice data. Details in error message.</message>
|
102 |
+
</data_invalid>
|
103 |
+
<filter_invalid>
|
104 |
+
<code>101</code>
|
105 |
+
<message>Invalid filters specfified. Details in error message.</message>
|
106 |
+
</filter_invalid>
|
107 |
+
<not_exists>
|
108 |
+
<code>102</code>
|
109 |
+
<message>Invoice does not exist.</message>
|
110 |
+
</not_exists>
|
111 |
+
<not_deleted>
|
112 |
+
<code>103</code>
|
113 |
+
<message>Invoice was not deleted. Details in error message.</message>
|
114 |
+
</not_deleted>
|
115 |
+
</faults>
|
116 |
+
</fsinvoice>
|
117 |
+
</resources>
|
118 |
+
<acl>
|
119 |
+
<resources>
|
120 |
+
<advancedexport translate="title" module="advancedexport">
|
121 |
+
<title>Freestyle</title>
|
122 |
+
<startexport translate="title" module="advancedexport">
|
123 |
+
<title>Start Export</title>
|
124 |
+
</startexport>
|
125 |
+
<getentityxml>
|
126 |
+
<title>Get Entity Xml</title>
|
127 |
+
</getentityxml>
|
128 |
+
<getentityqueue>
|
129 |
+
<title>Get Entity Queue</title>
|
130 |
+
</getentityqueue>
|
131 |
+
<getextensionprofile>
|
132 |
+
<title>Get Extension Profile</title>
|
133 |
+
</getextensionprofile>
|
134 |
+
<sort_order>9997</sort_order>
|
135 |
+
</advancedexport>
|
136 |
+
<fsorder translate="title" module="advancedexport">
|
137 |
+
<title>Freestyle Utilities - Order</title>
|
138 |
+
<!-- INDIVIDUAL CALLS -->
|
139 |
+
<!--
|
140 |
+
<caninvoice translate="title" module="order">
|
141 |
+
<title>Check Invoice Availability of an Order</title>
|
142 |
+
</caninvoice>
|
143 |
+
<canship translate="title" module="order">
|
144 |
+
<title>Check Shipping Availability of an Order</title>
|
145 |
+
</canship>
|
146 |
+
<cancreditmemo translate="title" module="order">
|
147 |
+
<title>Check Refund Availability of an Order</title>
|
148 |
+
</cancreditmemo>
|
149 |
+
-->
|
150 |
+
<checkactions translate="title" module="advancedexport">
|
151 |
+
<title>Check Invoicing, Shipping, Refund Action Availability of an [Order].</title>
|
152 |
+
</checkactions>
|
153 |
+
<sort_order>9998</sort_order>
|
154 |
+
</fsorder>
|
155 |
+
<fsinvoice translate="title" module="advancedexport">
|
156 |
+
<title>Freestyle Utilities - Invoice</title>
|
157 |
+
<cancapture translate="title" module="advancedexport">
|
158 |
+
<title>Check Capture Ability of an Invoice</title>
|
159 |
+
</cancapture>
|
160 |
+
<sort_order>9999</sort_order>
|
161 |
+
</fsinvoice>
|
162 |
+
|
163 |
+
</resources>
|
164 |
+
</acl>
|
165 |
+
</api>
|
166 |
+
</config>
|
app/code/community/Freestyle/Advancedexport/etc/config.xml
ADDED
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<modules>
|
15 |
+
<Freestyle_Advancedexport>
|
16 |
+
<version>1.4.1</version>
|
17 |
+
</Freestyle_Advancedexport>
|
18 |
+
</modules>
|
19 |
+
<adminhtml>
|
20 |
+
<layout>
|
21 |
+
<updates>
|
22 |
+
<advancedexport>
|
23 |
+
<file>advancedexport.xml</file>
|
24 |
+
</advancedexport>
|
25 |
+
</updates>
|
26 |
+
</layout>
|
27 |
+
</adminhtml>
|
28 |
+
<admin>
|
29 |
+
<routers>
|
30 |
+
<!-- modify router so that is Magento like e.g. root/index.php/admin/module/action/ -->
|
31 |
+
<!--
|
32 |
+
<advancedexport>
|
33 |
+
<use>admin</use>
|
34 |
+
<args>
|
35 |
+
<module>Freestyle_Advancedexport</module>
|
36 |
+
<frontName>advancedexport</frontName>
|
37 |
+
</args>
|
38 |
+
</advancedexport>
|
39 |
+
-->
|
40 |
+
<adminhtml>
|
41 |
+
<args>
|
42 |
+
<modules>
|
43 |
+
<Freestyle_Advancedexport after="Mage_Adminhtml">Freestyle_Advancedexport_Adminhtml</Freestyle_Advancedexport>
|
44 |
+
</modules>
|
45 |
+
</args>
|
46 |
+
</adminhtml>
|
47 |
+
</routers>
|
48 |
+
</admin>
|
49 |
+
<crontab>
|
50 |
+
<jobs>
|
51 |
+
<advancedexport_notify>
|
52 |
+
<schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
|
53 |
+
<run><model>advancedexport/cronjob::send</model></run>
|
54 |
+
</advancedexport_notify>
|
55 |
+
<!--
|
56 |
+
<advancedexport_purgequeue>
|
57 |
+
<schedule><cron_expr>0 2 15 * *</cron_expr></schedule>
|
58 |
+
<run><model>advancedexport/cronjob::purge</model></run>
|
59 |
+
</advancedexport_purgequeue>
|
60 |
+
-->
|
61 |
+
</jobs>
|
62 |
+
</crontab>
|
63 |
+
<global>
|
64 |
+
<models>
|
65 |
+
<advancedexport>
|
66 |
+
<class>Freestyle_Advancedexport_Model</class>
|
67 |
+
<resourceModel>advancedexport_mysql4</resourceModel>
|
68 |
+
</advancedexport>
|
69 |
+
<advancedexport_mysql4>
|
70 |
+
<class>Freestyle_Advancedexport_Model_Mysql4</class>
|
71 |
+
<entities>
|
72 |
+
<history>
|
73 |
+
<table>freestyle_advancedexport_history</table>
|
74 |
+
</history>
|
75 |
+
<passivemode>
|
76 |
+
<table>freestyle_advancedexport_passivemode</table>
|
77 |
+
</passivemode>
|
78 |
+
<configuration>
|
79 |
+
<table>freestyle_advancedexport_configuration</table>
|
80 |
+
</configuration>
|
81 |
+
<queue>
|
82 |
+
<table>freestyle_advancedexport_queue</table>
|
83 |
+
</queue>
|
84 |
+
</entities>
|
85 |
+
</advancedexport_mysql4>
|
86 |
+
<importexport>
|
87 |
+
<rewrite>
|
88 |
+
<import_entity_product>Freestyle_Advancedexport_Model_Import_Entity_Product</import_entity_product>
|
89 |
+
</rewrite>
|
90 |
+
</importexport>
|
91 |
+
<importexport>
|
92 |
+
<rewrite>
|
93 |
+
<import_entity_customer>Freestyle_Advancedexport_Model_Import_Entity_Customer</import_entity_customer>
|
94 |
+
</rewrite>
|
95 |
+
</importexport>
|
96 |
+
</models>
|
97 |
+
<blocks>
|
98 |
+
<advancedexport>
|
99 |
+
<class>Freestyle_Advancedexport_Block</class>
|
100 |
+
</advancedexport>
|
101 |
+
</blocks>
|
102 |
+
<helpers>
|
103 |
+
<advancedexport>
|
104 |
+
<class>Freestyle_Advancedexport_Helper</class>
|
105 |
+
</advancedexport>
|
106 |
+
</helpers>
|
107 |
+
<resources>
|
108 |
+
<advancedexport_setup>
|
109 |
+
<setup>
|
110 |
+
<module>Freestyle_Advancedexport</module>
|
111 |
+
</setup>
|
112 |
+
<connection>
|
113 |
+
<use>core_setup</use>
|
114 |
+
</connection>
|
115 |
+
</advancedexport_setup>
|
116 |
+
<advancedexport_write>
|
117 |
+
<connection>
|
118 |
+
<use>core_write</use>
|
119 |
+
</connection>
|
120 |
+
</advancedexport_write>
|
121 |
+
<advancedexport_read>
|
122 |
+
<connection>
|
123 |
+
<use>core_read</use>
|
124 |
+
</connection>
|
125 |
+
</advancedexport_read>
|
126 |
+
</resources>
|
127 |
+
<events>
|
128 |
+
<!--
|
129 |
+
<catalog_product_save_after>
|
130 |
+
<observers>
|
131 |
+
<advancedexport>
|
132 |
+
<class>advancedexport/observer</class>
|
133 |
+
<method>productSaveAfter</method>
|
134 |
+
</advancedexport>
|
135 |
+
</observers>
|
136 |
+
</catalog_product_save_after>
|
137 |
+
-->
|
138 |
+
<catalog_product_save_commit_after>
|
139 |
+
<observers>
|
140 |
+
<advancedexport>
|
141 |
+
<class>advancedexport/observer</class>
|
142 |
+
<method>productSaveAfter</method>
|
143 |
+
</advancedexport>
|
144 |
+
</observers>
|
145 |
+
</catalog_product_save_commit_after>
|
146 |
+
<catalog_product_delete_before>
|
147 |
+
<observers>
|
148 |
+
<advancedexport>
|
149 |
+
<class>advancedexport/observer</class>
|
150 |
+
<method>productDeleteBefore</method>
|
151 |
+
</advancedexport>
|
152 |
+
</observers>
|
153 |
+
</catalog_product_delete_before>
|
154 |
+
<catalog_custom_product_import_finish_before>
|
155 |
+
<observers>
|
156 |
+
<advancedexport>
|
157 |
+
<class>advancedexport/observer</class>
|
158 |
+
<method>productSaveAfterStandartImport</method>
|
159 |
+
</advancedexport>
|
160 |
+
</observers>
|
161 |
+
</catalog_custom_product_import_finish_before>
|
162 |
+
<catalog_category_save_after>
|
163 |
+
<observers>
|
164 |
+
<advancedexport>
|
165 |
+
<class>advancedexport/observer</class>
|
166 |
+
<method>categorySaveAfter</method>
|
167 |
+
</advancedexport>
|
168 |
+
</observers>
|
169 |
+
</catalog_category_save_after>
|
170 |
+
<catalog_category_delete_before>
|
171 |
+
<observers>
|
172 |
+
<advancedexport>
|
173 |
+
<class>advancedexport/observer</class>
|
174 |
+
<method>categoryDeleteBefore</method>
|
175 |
+
</advancedexport>
|
176 |
+
</observers>
|
177 |
+
</catalog_category_delete_before>
|
178 |
+
<customer_save_after>
|
179 |
+
<observers>
|
180 |
+
<advancedexport>
|
181 |
+
<class>advancedexport/observer</class>
|
182 |
+
<method>customerSaveAfter</method>
|
183 |
+
</advancedexport>
|
184 |
+
</observers>
|
185 |
+
</customer_save_after>
|
186 |
+
<customer_delete_before>
|
187 |
+
<observers>
|
188 |
+
<advancedexport>
|
189 |
+
<class>advancedexport/observer</class>
|
190 |
+
<method>customerDeleteBefore</method>
|
191 |
+
</advancedexport>
|
192 |
+
</observers>
|
193 |
+
</customer_delete_before>
|
194 |
+
<!--
|
195 |
+
<customer_address_save_after>
|
196 |
+
<observers>
|
197 |
+
<advancedexport>
|
198 |
+
<class>advancedexport/observer</class>
|
199 |
+
<method>customerAddressSaveAfter</method>
|
200 |
+
</advancedexport>
|
201 |
+
</observers>
|
202 |
+
</customer_address_save_after>
|
203 |
+
<customer_address_delete_after>
|
204 |
+
<observers>
|
205 |
+
<advancedexport>
|
206 |
+
<class>advancedexport/observer</class>
|
207 |
+
<method>customerAddressSaveAfter</method>
|
208 |
+
</advancedexport>
|
209 |
+
</observers>
|
210 |
+
</customer_address_delete_after>
|
211 |
+
-->
|
212 |
+
<customer_custom_import_finish_before>
|
213 |
+
<observers>
|
214 |
+
<advancedexport>
|
215 |
+
<class>advancedexport/observer</class>
|
216 |
+
<method>customerSaveAfterStandartImport</method>
|
217 |
+
</advancedexport>
|
218 |
+
</observers>
|
219 |
+
</customer_custom_import_finish_before>
|
220 |
+
<!--<sales_order_save_after>-->
|
221 |
+
<sales_order_save_commit_after>
|
222 |
+
<observers>
|
223 |
+
<advancedexport>
|
224 |
+
<class>advancedexport/observer</class>
|
225 |
+
<method>orderSaveAfter</method>
|
226 |
+
</advancedexport>
|
227 |
+
</observers>
|
228 |
+
</sales_order_save_commit_after>
|
229 |
+
<customer_group_save_after>
|
230 |
+
<observers>
|
231 |
+
<advancedexport>
|
232 |
+
<class>advancedexport/observer</class>
|
233 |
+
<method>customergroupSaveAfter</method>
|
234 |
+
</advancedexport>
|
235 |
+
</observers>
|
236 |
+
</customer_group_save_after>
|
237 |
+
<customer_group_delete_before>
|
238 |
+
<observers>
|
239 |
+
<advancedexport>
|
240 |
+
<class>advancedexport/observer</class>
|
241 |
+
<method>customergroupDeleteBefore</method>
|
242 |
+
</advancedexport>
|
243 |
+
</observers>
|
244 |
+
</customer_group_delete_before>
|
245 |
+
<admin_system_config_changed_section_customer>
|
246 |
+
<observers>
|
247 |
+
<advancedexport>
|
248 |
+
<class>advancedexport/observer</class>
|
249 |
+
<method>systemConfigChangedSectionCustomer</method>
|
250 |
+
</advancedexport>
|
251 |
+
</observers>
|
252 |
+
</admin_system_config_changed_section_customer>
|
253 |
+
<!--</sales_order_save_after>-->
|
254 |
+
<!-- NEW CODE
|
255 |
+
<order_cancel_after_commit_after>
|
256 |
+
<observers>
|
257 |
+
<advancedexport>
|
258 |
+
<class>advancedexport/observer</class>
|
259 |
+
<method>orderSaveAfter</method>
|
260 |
+
</advancedexport>
|
261 |
+
</observers>
|
262 |
+
</order_cancel_after_commit_after>
|
263 |
+
NEW CODE -->
|
264 |
+
<catalog_product_media_add_image>
|
265 |
+
<observers>
|
266 |
+
<advancedexport>
|
267 |
+
<class>advancedexport/observer</class>
|
268 |
+
<method>mediaSaveAfter</method>
|
269 |
+
</advancedexport>
|
270 |
+
</observers>
|
271 |
+
</catalog_product_media_add_image>
|
272 |
+
</events>
|
273 |
+
</global>
|
274 |
+
<frontend>
|
275 |
+
<events>
|
276 |
+
<!-- prevents multiple files in admin -->
|
277 |
+
<customer_address_save_after>
|
278 |
+
<observers>
|
279 |
+
<advancedexport>
|
280 |
+
<class>advancedexport/observer</class>
|
281 |
+
<method>customerAddressSaveAfter</method>
|
282 |
+
</advancedexport>
|
283 |
+
</observers>
|
284 |
+
</customer_address_save_after>
|
285 |
+
<customer_address_delete_after>
|
286 |
+
<observers>
|
287 |
+
<advancedexport>
|
288 |
+
<class>advancedexport/observer</class>
|
289 |
+
<method>customerAddressSaveAfter</method>
|
290 |
+
</advancedexport>
|
291 |
+
</observers>
|
292 |
+
</customer_address_delete_after>
|
293 |
+
</events>
|
294 |
+
<routers>
|
295 |
+
<advancedexport>
|
296 |
+
<use>standard</use>
|
297 |
+
<args>
|
298 |
+
<module>Freestyle_Advancedexport</module>
|
299 |
+
<frontName>advancedexport</frontName>
|
300 |
+
</args>
|
301 |
+
</advancedexport>
|
302 |
+
</routers>
|
303 |
+
<layout>
|
304 |
+
<updates>
|
305 |
+
<advancedexport>
|
306 |
+
<file>advancedexport.xml</file>
|
307 |
+
</advancedexport>
|
308 |
+
</updates>
|
309 |
+
</layout>
|
310 |
+
</frontend>
|
311 |
+
<default>
|
312 |
+
<freestyle_advancedexport>
|
313 |
+
<settings>
|
314 |
+
<!-- <export_path>advancedexport</export_path> -->
|
315 |
+
<chanel_id>channelId</chanel_id>
|
316 |
+
<chanel_name>channelName</chanel_name>
|
317 |
+
<memory_limit>256</memory_limit>
|
318 |
+
<build_date>(FTT)1.1.63.23.4</build_date>
|
319 |
+
<enable_passive_gui>0</enable_passive_gui>
|
320 |
+
<cutoff_date></cutoff_date>
|
321 |
+
<product_send_images>0</product_send_images>
|
322 |
+
</settings>
|
323 |
+
<queue>
|
324 |
+
<enable_queue>0</enable_queue>
|
325 |
+
<ignore_api>1</ignore_api>
|
326 |
+
<queuebatchsize>50</queuebatchsize>
|
327 |
+
<send_async>1</send_async>
|
328 |
+
<send_order_dependencies>1</send_order_dependencies>
|
329 |
+
</queue>
|
330 |
+
<debug>
|
331 |
+
<curl_verify_peer>1</curl_verify_peer>
|
332 |
+
</debug>
|
333 |
+
</freestyle_advancedexport>
|
334 |
+
</default>
|
335 |
+
</config>
|
app/code/community/Freestyle/Advancedexport/etc/system.xml
ADDED
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
-->
|
13 |
+
<config>
|
14 |
+
<tabs>
|
15 |
+
<freestyle translate="label">
|
16 |
+
<label>Freestyle</label>
|
17 |
+
<sort_order>200</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>1</show_in_store>
|
21 |
+
</freestyle>
|
22 |
+
</tabs>
|
23 |
+
<sections>
|
24 |
+
<freestyle_advancedexport translate="label" module="advancedexport">
|
25 |
+
<label>Advanced Export</label>
|
26 |
+
<tab>freestyle</tab>
|
27 |
+
<frontend_type>text</frontend_type>
|
28 |
+
<sort_order>10</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
<groups>
|
33 |
+
<settings>
|
34 |
+
<label>Settings</label>
|
35 |
+
<frontend_type>text</frontend_type>
|
36 |
+
<sort_order>10</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
<!-- <comment><![CDATA[<span class="notice"><strong>All fields are required</strong></span>]]></comment> -->
|
41 |
+
<fields>
|
42 |
+
<is_enabled>
|
43 |
+
<label>Enable Extension</label>
|
44 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>0</show_in_website>
|
47 |
+
<show_in_store>0</show_in_store>
|
48 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
49 |
+
<frontend_type>select</frontend_type>
|
50 |
+
<sort_order>11</sort_order>
|
51 |
+
</is_enabled>
|
52 |
+
<!--
|
53 |
+
<export_path>
|
54 |
+
<label>Export Folder Path</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>12</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
</export_path>
|
61 |
+
-->
|
62 |
+
<chanel_id>
|
63 |
+
<label><![CDATA[Channel Id <span class="required">*</span>]]></label>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>13</sort_order>
|
66 |
+
<show_in_default>0</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>0</show_in_store>
|
69 |
+
<validate>required-entry</validate>
|
70 |
+
</chanel_id>
|
71 |
+
<chanel_name>
|
72 |
+
<label><![CDATA[Channel Name <span class="required">*</span>]]></label>
|
73 |
+
<frontend_type>text</frontend_type>
|
74 |
+
<sort_order>14</sort_order>
|
75 |
+
<show_in_default>1</show_in_default>
|
76 |
+
<show_in_website>0</show_in_website>
|
77 |
+
<show_in_store>0</show_in_store>
|
78 |
+
<validate>validate-length maximum-length-6 required-entry</validate>
|
79 |
+
<comment><![CDATA[Max Length = 6]]></comment>
|
80 |
+
</chanel_name>
|
81 |
+
<memory_limit>
|
82 |
+
<label><![CDATA[Memory Limit in Megabytes <span class="required">*</span>]]></label>
|
83 |
+
<frontend_type>text</frontend_type>
|
84 |
+
<sort_order>15</sort_order>
|
85 |
+
<show_in_default>1</show_in_default>
|
86 |
+
<show_in_website>0</show_in_website>
|
87 |
+
<show_in_store>0</show_in_store>
|
88 |
+
<validate>validate-digits validate-greater-than-zero required-entry</validate>
|
89 |
+
</memory_limit>
|
90 |
+
<cutoff_date>
|
91 |
+
<label><![CDATA[Order Date Cut Off]]></label>
|
92 |
+
<frontend_type>text</frontend_type>
|
93 |
+
<frontend_model>advancedexport/adminhtml_system_config_date</frontend_model>
|
94 |
+
<sort_order>16</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>1</show_in_website>
|
97 |
+
<show_in_store>0</show_in_store>
|
98 |
+
<validate>validate-date</validate>
|
99 |
+
</cutoff_date>
|
100 |
+
<enable_passive_gui>
|
101 |
+
<label><![CDATA[Show Advanced UI]]></label>
|
102 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
103 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
104 |
+
<frontend_type>select</frontend_type>
|
105 |
+
<sort_order>17</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>0</show_in_website>
|
108 |
+
<show_in_store>0</show_in_store>
|
109 |
+
</enable_passive_gui>
|
110 |
+
<product_send_images>
|
111 |
+
<label><![CDATA[Send Image Data with Products]]></label>
|
112 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
113 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
114 |
+
<frontend_type>select</frontend_type>
|
115 |
+
<sort_order>18</sort_order>
|
116 |
+
<show_in_default>1</show_in_default>
|
117 |
+
<show_in_website>0</show_in_website>
|
118 |
+
<show_in_store>0</show_in_store>
|
119 |
+
</product_send_images>
|
120 |
+
</fields>
|
121 |
+
</settings>
|
122 |
+
<queue>
|
123 |
+
<label>Freestyle Queueing Settings</label>
|
124 |
+
<frontend_type>text</frontend_type>
|
125 |
+
<sort_order>15</sort_order>
|
126 |
+
<show_in_default>1</show_in_default>
|
127 |
+
<show_in_website>1</show_in_website>
|
128 |
+
<show_in_store>1</show_in_store>
|
129 |
+
<fields>
|
130 |
+
<enable_queue>
|
131 |
+
<label>Use Queueing</label>
|
132 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
133 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
134 |
+
<frontend_type>select</frontend_type>
|
135 |
+
<sort_order>16</sort_order>
|
136 |
+
<show_in_default>1</show_in_default>
|
137 |
+
<show_in_website>0</show_in_website>
|
138 |
+
<show_in_store>0</show_in_store>
|
139 |
+
</enable_queue>
|
140 |
+
<send_async>
|
141 |
+
<label>Send Async</label>
|
142 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
143 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
144 |
+
<frontend_type>select</frontend_type>
|
145 |
+
<sort_order>17</sort_order>
|
146 |
+
<show_in_default>1</show_in_default>
|
147 |
+
<show_in_website>0</show_in_website>
|
148 |
+
<show_in_store>0</show_in_store>
|
149 |
+
</send_async>
|
150 |
+
<ignore_api>
|
151 |
+
<label>Ignore Calls to Magento API</label>
|
152 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
153 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
154 |
+
<frontend_type>select</frontend_type>
|
155 |
+
<sort_order>19</sort_order>
|
156 |
+
<show_in_default>1</show_in_default>
|
157 |
+
<show_in_website>0</show_in_website>
|
158 |
+
<show_in_store>0</show_in_store>
|
159 |
+
</ignore_api>
|
160 |
+
<queuebatchsize>
|
161 |
+
<label>Async Queue Batch Size</label>
|
162 |
+
<backend_model>Freestyle_Advancedexport_Model_Queuebatchsize</backend_model>
|
163 |
+
<frontend_type>text</frontend_type>
|
164 |
+
<sort_order>18</sort_order>
|
165 |
+
<show_in_default>1</show_in_default>
|
166 |
+
<show_in_website>0</show_in_website>
|
167 |
+
<show_in_store>0</show_in_store>
|
168 |
+
<validate>validate-digits validate-greater-than-zero required-entry</validate>
|
169 |
+
</queuebatchsize>
|
170 |
+
<queue_service_url>
|
171 |
+
<label><![CDATA[Queue Service URL <span class="required">*</span>]]></label>
|
172 |
+
<frontend_type>text</frontend_type>
|
173 |
+
<sort_order>20</sort_order>
|
174 |
+
<show_in_default>1</show_in_default>
|
175 |
+
<show_in_website>0</show_in_website>
|
176 |
+
<show_in_store>0</show_in_store>
|
177 |
+
<validate>validate-url required-entry</validate>
|
178 |
+
</queue_service_url>
|
179 |
+
<send_order_dependencies>
|
180 |
+
<label>Send Order Dependencies</label>
|
181 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
182 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
183 |
+
<frontend_type>select</frontend_type>
|
184 |
+
<sort_order>21</sort_order>
|
185 |
+
<show_in_default>1</show_in_default>
|
186 |
+
<show_in_website>0</show_in_website>
|
187 |
+
<show_in_store>0</show_in_store>
|
188 |
+
</send_order_dependencies>
|
189 |
+
</fields>
|
190 |
+
</queue>
|
191 |
+
<api>
|
192 |
+
<label>Freestyle Connection Settings</label>
|
193 |
+
<frontend_type>text</frontend_type>
|
194 |
+
<sort_order>13</sort_order>
|
195 |
+
<show_in_default>1</show_in_default>
|
196 |
+
<show_in_website>1</show_in_website>
|
197 |
+
<show_in_store>1</show_in_store>
|
198 |
+
<!-- <comment><![CDATA[<span class="notice"><strong>All fields are required</strong></span>]]></comment> -->
|
199 |
+
<fields>
|
200 |
+
<api_username>
|
201 |
+
<label><![CDATA[Username <span class="required">*</span>]]></label>
|
202 |
+
<frontend_type>text</frontend_type>
|
203 |
+
<sort_order>11</sort_order>
|
204 |
+
<show_in_default>1</show_in_default>
|
205 |
+
<show_in_website>0</show_in_website>
|
206 |
+
<show_in_store>0</show_in_store>
|
207 |
+
<validate>required-entry</validate>
|
208 |
+
</api_username>
|
209 |
+
<api_password>
|
210 |
+
<label><![CDATA[Password <span class="required">*</span>]]></label>
|
211 |
+
<frontend_type>obscure</frontend_type>
|
212 |
+
<!-- <frontend_type>password</frontend_type> -->
|
213 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
214 |
+
<sort_order>12</sort_order>
|
215 |
+
<show_in_default>1</show_in_default>
|
216 |
+
<show_in_website>0</show_in_website>
|
217 |
+
<show_in_store>0</show_in_store>
|
218 |
+
<validate>required-entry</validate>
|
219 |
+
</api_password>
|
220 |
+
<api_authorization_url>
|
221 |
+
<label><![CDATA[Authentication Service URL <span class="required">*</span>]]></label>
|
222 |
+
<frontend_type>text</frontend_type>
|
223 |
+
<sort_order>13</sort_order>
|
224 |
+
<show_in_default>1</show_in_default>
|
225 |
+
<show_in_website>0</show_in_website>
|
226 |
+
<show_in_store>0</show_in_store>
|
227 |
+
<validate>validate-url required-entry</validate>
|
228 |
+
</api_authorization_url>
|
229 |
+
<api_service_url>
|
230 |
+
<label><![CDATA[Notification Service URL <span class="required">*</span>]]></label>
|
231 |
+
<frontend_type>text</frontend_type>
|
232 |
+
<sort_order>14</sort_order>
|
233 |
+
<show_in_default>1</show_in_default>
|
234 |
+
<show_in_website>0</show_in_website>
|
235 |
+
<show_in_store>0</show_in_store>
|
236 |
+
<validate>validate-url required-entry</validate>
|
237 |
+
</api_service_url>
|
238 |
+
<test_connection translate="label">
|
239 |
+
<label><![CDATA[ ]]></label>
|
240 |
+
<frontend_type>button</frontend_type>
|
241 |
+
<frontend_model>advancedexport/adminhtml_system_config_form_button</frontend_model>
|
242 |
+
<sort_order>21</sort_order>
|
243 |
+
<show_in_default>1</show_in_default>
|
244 |
+
<show_in_website>0</show_in_website>
|
245 |
+
<show_in_store>0</show_in_store>
|
246 |
+
</test_connection>
|
247 |
+
<test_notes>
|
248 |
+
<label><![CDATA[ ]]></label>
|
249 |
+
<frontend_type>text</frontend_type>
|
250 |
+
<frontend_model>Freestyle_Advancedexport_Block_Adminhtml_Notes</frontend_model>
|
251 |
+
<sort_order>20</sort_order>
|
252 |
+
<show_in_default>1</show_in_default>
|
253 |
+
<show_in_website>0</show_in_website>
|
254 |
+
<show_in_store>0</show_in_store>
|
255 |
+
</test_notes>
|
256 |
+
</fields>
|
257 |
+
</api>
|
258 |
+
<version_info>
|
259 |
+
<label>Version Info</label>
|
260 |
+
<frontend_type>text</frontend_type>
|
261 |
+
<sort_order>20</sort_order>
|
262 |
+
<show_in_default>1</show_in_default>
|
263 |
+
<show_in_website>1</show_in_website>
|
264 |
+
<show_in_store>1</show_in_store>
|
265 |
+
<fields>
|
266 |
+
<advancedexport_version>
|
267 |
+
<label>Version</label>
|
268 |
+
<frontend_type>text</frontend_type>
|
269 |
+
<frontend_model>Freestyle_Advancedexport_Block_Adminhtml_Version</frontend_model>
|
270 |
+
<sort_order>16</sort_order>
|
271 |
+
<show_in_default>1</show_in_default>
|
272 |
+
<show_in_website>0</show_in_website>
|
273 |
+
<show_in_store>0</show_in_store>
|
274 |
+
</advancedexport_version>
|
275 |
+
<advancedexport_build>
|
276 |
+
<label>Compatible with Freestyle Build:</label>
|
277 |
+
<frontend_type>text</frontend_type>
|
278 |
+
<frontend_model>Freestyle_Advancedexport_Block_Adminhtml_Builddate</frontend_model>
|
279 |
+
<sort_order>17</sort_order>
|
280 |
+
<show_in_default>1</show_in_default>
|
281 |
+
<show_in_website>0</show_in_website>
|
282 |
+
<show_in_store>0</show_in_store>
|
283 |
+
</advancedexport_build>
|
284 |
+
</fields>
|
285 |
+
</version_info>
|
286 |
+
<debug>
|
287 |
+
<label>Debug (WARNING: Developer use only)</label>
|
288 |
+
<frontend_type>text</frontend_type>
|
289 |
+
<sort_order>30</sort_order>
|
290 |
+
<show_in_default>1</show_in_default>
|
291 |
+
<show_in_website>1</show_in_website>
|
292 |
+
<show_in_store>1</show_in_store>
|
293 |
+
<fields>
|
294 |
+
<curl_use_proxy>
|
295 |
+
<label>Enable cURL Proxy</label>
|
296 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
297 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
298 |
+
<frontend_type>select</frontend_type>
|
299 |
+
<sort_order>30</sort_order>
|
300 |
+
<show_in_default>1</show_in_default>
|
301 |
+
<show_in_website>0</show_in_website>
|
302 |
+
<show_in_store>0</show_in_store>
|
303 |
+
</curl_use_proxy>
|
304 |
+
<curl_proxy_ip>
|
305 |
+
<label><![CDATA[Proxy IP]]></label>
|
306 |
+
<frontend_type>text</frontend_type>
|
307 |
+
<sort_order>31</sort_order>
|
308 |
+
<show_in_default>1</show_in_default>
|
309 |
+
<show_in_website>0</show_in_website>
|
310 |
+
<show_in_store>0</show_in_store>
|
311 |
+
</curl_proxy_ip>
|
312 |
+
<curl_proxy_port>
|
313 |
+
<label><![CDATA[Proxy Port]]></label>
|
314 |
+
<frontend_type>text</frontend_type>
|
315 |
+
<sort_order>32</sort_order>
|
316 |
+
<show_in_default>1</show_in_default>
|
317 |
+
<show_in_website>0</show_in_website>
|
318 |
+
<show_in_store>0</show_in_store>
|
319 |
+
</curl_proxy_port>
|
320 |
+
<curl_proxy_login>
|
321 |
+
<label><![CDATA[Proxy Login]]></label>
|
322 |
+
<frontend_type>text</frontend_type>
|
323 |
+
<sort_order>33</sort_order>
|
324 |
+
<show_in_default>1</show_in_default>
|
325 |
+
<show_in_website>0</show_in_website>
|
326 |
+
<show_in_store>0</show_in_store>
|
327 |
+
</curl_proxy_login>
|
328 |
+
<curl_proxy_pass>
|
329 |
+
<label><![CDATA[Proxy Password]]></label>
|
330 |
+
<frontend_type>obscure</frontend_type>
|
331 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
332 |
+
<sort_order>34</sort_order>
|
333 |
+
<show_in_default>1</show_in_default>
|
334 |
+
<show_in_website>0</show_in_website>
|
335 |
+
<show_in_store>0</show_in_store>
|
336 |
+
</curl_proxy_pass>
|
337 |
+
<curl_verify_peer>
|
338 |
+
<label>Verify SSL Peer</label>
|
339 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
340 |
+
<!-- <source_model>adminhtml/system_config_source_enabledisable</source_model> -->
|
341 |
+
<frontend_type>select</frontend_type>
|
342 |
+
<sort_order>35</sort_order>
|
343 |
+
<show_in_default>1</show_in_default>
|
344 |
+
<show_in_website>0</show_in_website>
|
345 |
+
<show_in_store>0</show_in_store>
|
346 |
+
</curl_verify_peer>
|
347 |
+
|
348 |
+
</fields>
|
349 |
+
</debug>
|
350 |
+
</groups>
|
351 |
+
</freestyle_advancedexport>
|
352 |
+
</sections>
|
353 |
+
|
354 |
+
</config>
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$installer->run(
|
7 |
+
"DROP TABLE IF EXISTS {$this->getTable('advancedexport/history')};
|
8 |
+
CREATE TABLE {$this->getTable('advancedexport/history')} (
|
9 |
+
`id` int(11) unsigned NOT NULL auto_increment,
|
10 |
+
`export_date` datetime NOT NULL,
|
11 |
+
`export_date_time_start` datetime NOT NULL,
|
12 |
+
`export_date_time_end` datetime NOT NULL,
|
13 |
+
`created_files` text,
|
14 |
+
`init_from` varchar(255),
|
15 |
+
`export_entity` varchar(30),
|
16 |
+
`errors` text,
|
17 |
+
PRIMARY KEY (`id`)
|
18 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
19 |
+
|
20 |
+
DROP TABLE IF EXISTS {$this->getTable('advancedexport/passivemode')};
|
21 |
+
CREATE TABLE {$this->getTable('advancedexport/passivemode')} (
|
22 |
+
`id` int(11) unsigned NOT NULL auto_increment,
|
23 |
+
`passivemod_enabled` int(2) NOT NULL,
|
24 |
+
`passivemod_start` datetime NOT NULL,
|
25 |
+
`passivemod_end` datetime NOT NULL,
|
26 |
+
`created_files` LONGTEXT,
|
27 |
+
`is_notification_sent` int(2),
|
28 |
+
PRIMARY KEY (`id`)
|
29 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
30 |
+
|
31 |
+
DROP TABLE IF EXISTS {$this->getTable('advancedexport/configuration')};
|
32 |
+
CREATE TABLE {$this->getTable('advancedexport/configuration')} (
|
33 |
+
`id` int(11) unsigned NOT NULL auto_increment,
|
34 |
+
`config_code` varchar(50) NOT NULL,
|
35 |
+
`config_value` varchar(255) NOT NULL,
|
36 |
+
PRIMARY KEY (`id`)
|
37 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
|
38 |
+
);
|
39 |
+
|
40 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.0-1.2.1.php
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// >advancedexport_setup/mysql4-1.2.0-1.2.1.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// get the version of magento!
|
12 |
+
$mageVersion = Mage::getVersion();
|
13 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
14 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
15 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
16 |
+
|
17 |
+
if ($mageEdition == 'ENTERPRISE') {
|
18 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
19 |
+
} else {
|
20 |
+
//we are assuming if you are not enterprise, you are community
|
21 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
//moved IF NOT EXISTS next to CREATE TABLE for CE 1.6.1.0 Compatibility
|
25 |
+
if ($runPureSQL) {
|
26 |
+
$installer->run(
|
27 |
+
"CREATE TABLE IF NOT EXISTS {$this->getTable('advancedexport/queue')} (
|
28 |
+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
29 |
+
`entity_id` varchar(255) NOT NULL,
|
30 |
+
`entity_type` varchar(255) NOT NULL DEFAULT '' COMMENT
|
31 |
+
'Magento Entity Type',
|
32 |
+
`action` varchar(255) NOT NULL DEFAULT '' COMMENT 'Action Type',
|
33 |
+
`create_time` datetime DEFAULT '0000-00-00 00:00:00' COMMENT
|
34 |
+
'Created At',
|
35 |
+
`update_time` datetime DEFAULT '0000-00-00 00:00:00' COMMENT
|
36 |
+
'Modified At',
|
37 |
+
`status` varchar(255) NOT NULL DEFAULT '' COMMENT 'Status Description',
|
38 |
+
PRIMARY KEY (`id`),
|
39 |
+
KEY `IDX_FREESTYLE_ADVANCEDEXPORT_QUEUE_ENTITY_TYPE` (`entity_type`),
|
40 |
+
KEY `IDX_FREESTYLE_ADVANCEDEXPORT_QUEUE_STATUS` (`status`),
|
41 |
+
KEY `IDX_FREESTYLE_ADVANCEDEXPORT_QUEUE_ENTITY_ID` (`entity_id`)
|
42 |
+
) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8 COMMENT=
|
43 |
+
'Freestyle Message Queue'"
|
44 |
+
);
|
45 |
+
} else {
|
46 |
+
$tableName = $installer->getTable('advancedexport/queue');
|
47 |
+
//create the message queue table
|
48 |
+
if (!$installer->getConnection()->isTableExists($tableName)) {
|
49 |
+
$table = $installer->getConnection()->newTable($tableName)
|
50 |
+
->addColumn(
|
51 |
+
'id',
|
52 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
53 |
+
null,
|
54 |
+
array(
|
55 |
+
'unsigned' => true,
|
56 |
+
'nullable' => false,
|
57 |
+
'primary' => true,
|
58 |
+
'identity' => true,
|
59 |
+
),
|
60 |
+
'ID'
|
61 |
+
)
|
62 |
+
->addColumn(
|
63 |
+
'entity_id',
|
64 |
+
Varien_Db_Ddl_Table::TYPE_INTEGER,
|
65 |
+
null,
|
66 |
+
array(
|
67 |
+
'unsigned' => true,
|
68 |
+
'nullable' => false,
|
69 |
+
'primary' => false,
|
70 |
+
'identity' => false,
|
71 |
+
),
|
72 |
+
'Magento Entity ID'
|
73 |
+
)
|
74 |
+
->addColumn(
|
75 |
+
'entity_type',
|
76 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
77 |
+
'255',
|
78 |
+
array(
|
79 |
+
'nullable' => false,
|
80 |
+
'default' => '',
|
81 |
+
),
|
82 |
+
'Magento Entity Type'
|
83 |
+
)
|
84 |
+
->addColumn(
|
85 |
+
'action',
|
86 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
87 |
+
'255',
|
88 |
+
array(
|
89 |
+
'nullable' => false,
|
90 |
+
'default' => '',
|
91 |
+
),
|
92 |
+
'Action Type'
|
93 |
+
)
|
94 |
+
->addColumn(
|
95 |
+
'create_time',
|
96 |
+
Varien_Db_Ddl_Table::TYPE_DATETIME,
|
97 |
+
null,
|
98 |
+
array(
|
99 |
+
'nullable' => true,
|
100 |
+
'default' => $installer
|
101 |
+
->getConnection()
|
102 |
+
->getSuggestedZeroDate(),
|
103 |
+
),
|
104 |
+
'Created At'
|
105 |
+
)
|
106 |
+
->addColumn(
|
107 |
+
'update_time',
|
108 |
+
Varien_Db_Ddl_Table::TYPE_DATETIME,
|
109 |
+
null,
|
110 |
+
array(
|
111 |
+
'nullable' => true,
|
112 |
+
'default' => $installer
|
113 |
+
->getConnection()
|
114 |
+
->getSuggestedZeroDate(),
|
115 |
+
),
|
116 |
+
'Modified At'
|
117 |
+
)
|
118 |
+
->addColumn(
|
119 |
+
'status',
|
120 |
+
Varien_Db_Ddl_Table::TYPE_TEXT,
|
121 |
+
'255',
|
122 |
+
array(
|
123 |
+
'nullable' => false,
|
124 |
+
'default' => '',
|
125 |
+
),
|
126 |
+
'Status Description'
|
127 |
+
)
|
128 |
+
->addIndex(
|
129 |
+
$installer->getIdxName(
|
130 |
+
$tableName,
|
131 |
+
array('entity_type')
|
132 |
+
),
|
133 |
+
array('entity_type'),
|
134 |
+
array(
|
135 |
+
'type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
|
136 |
+
)
|
137 |
+
)
|
138 |
+
->addIndex(
|
139 |
+
$installer->getIdxName(
|
140 |
+
$tableName,
|
141 |
+
array('status')
|
142 |
+
),
|
143 |
+
array('status'),
|
144 |
+
array(
|
145 |
+
'type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
|
146 |
+
)
|
147 |
+
)
|
148 |
+
->addIndex(
|
149 |
+
$installer->getIdxName(
|
150 |
+
$tableName,
|
151 |
+
array('entity_id')
|
152 |
+
),
|
153 |
+
array('entity_id'),
|
154 |
+
array(
|
155 |
+
'type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX
|
156 |
+
)
|
157 |
+
)
|
158 |
+
->setComment('Freestyle Message Queue');
|
159 |
+
|
160 |
+
$installer->getConnection()->createTable($table);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.1-1.2.2.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/Advancedexport/sql/
|
4 |
+
// >advancedexport_setup/mysql4-upgrade-1.2.1-1.2.2.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// get the version of magento!
|
12 |
+
$mageVersion = Mage::getVersion();
|
13 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
14 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
15 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
16 |
+
|
17 |
+
if ($mageEdition == 'ENTERPRISE') {
|
18 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
19 |
+
} else {
|
20 |
+
//we are assuming if you are not enterprise, you are community
|
21 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($runPureSQL) {
|
25 |
+
$installer->run(
|
26 |
+
"ALTER TABLE {$this->getTable('advancedexport/queue')} MODIFY COLUMN"
|
27 |
+
. " `entity_id` VARCHAR(255) NOT NULL COLLATE utf8_general_ci;"
|
28 |
+
. "ALTER TABLE {$this->getTable('advancedexport/queue')}"
|
29 |
+
. " ADD COLUMN `error_msg` VARCHAR(255) NOT NULL COLLATE "
|
30 |
+
. "utf8_general_ci,"
|
31 |
+
. " ADD COLUMN `entity_value` VARCHAR(255) NOT NULL COLLATE "
|
32 |
+
. "utf8_general_ci;"
|
33 |
+
);
|
34 |
+
} else {
|
35 |
+
$tableName = $installer->getTable('advancedexport/queue');
|
36 |
+
|
37 |
+
$table = $installer->getConnection();
|
38 |
+
if ($installer->getConnection()->isTableExists($tableName)) {
|
39 |
+
$table->modifyColumn(
|
40 |
+
$tableName,
|
41 |
+
'entity_id',
|
42 |
+
'VARCHAR(255) NOT NULL COLLATE utf8_general_ci'
|
43 |
+
);
|
44 |
+
$table->addColumn(
|
45 |
+
$tableName,
|
46 |
+
'error_msg',
|
47 |
+
'VARCHAR(255) NOT NULL COLLATE utf8_general_ci'
|
48 |
+
);
|
49 |
+
$table->addColumn(
|
50 |
+
$tableName,
|
51 |
+
'entity_value',
|
52 |
+
'VARCHAR(255) NOT NULL COLLATE utf8_general_ci'
|
53 |
+
);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.11-1.3.0.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// >advancedexport_setup/mysql4-upgrade-1.2.6-1.2.9.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// get the version of magento!
|
12 |
+
$mageVersion = Mage::getVersion();
|
13 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
14 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
15 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
16 |
+
|
17 |
+
if ($mageEdition == 'ENTERPRISE') {
|
18 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
19 |
+
} else {
|
20 |
+
//we are assuming if you are not enterprise, you are community
|
21 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($runPureSQL) {
|
25 |
+
$installer->run(
|
26 |
+
"ALTER TABLE {$this->getTable('advancedexport/queue')} "
|
27 |
+
. " ADD COLUMN `scope` VARCHAR(255) NOT NULL COLLATE "
|
28 |
+
. "utf8_general_ci COMMENT 'Scope', "
|
29 |
+
. " ADD COLUMN `scope_value` VARCHAR(255) NOT NULL COLLATE "
|
30 |
+
. "utf8_general_ci COMMENT 'Scope Value';"
|
31 |
+
);
|
32 |
+
$installer->run(
|
33 |
+
"CREATE INDEX IDX_FREESTYLE_ADVANCEDEXPORT_QUEUE_SCOPE_VALUE"
|
34 |
+
. " ON {$this->getTable('advancedexport/queue')} (scope_value);"
|
35 |
+
);
|
36 |
+
$installer->run(
|
37 |
+
"UPDATE {$this->getTable('advancedexport/queue')} SET scope='website',"
|
38 |
+
. " scope_value='1' WHERE scope_value IS NULL"
|
39 |
+
);
|
40 |
+
} else {
|
41 |
+
$tableName = $installer->getTable('advancedexport/queue');
|
42 |
+
|
43 |
+
$table = $installer->getConnection();
|
44 |
+
if ($installer->getConnection()->isTableExists($tableName)) {
|
45 |
+
$table->addColumn(
|
46 |
+
$tableName,
|
47 |
+
'scope',
|
48 |
+
"VARCHAR(255) NOT NULL COLLATE utf8_general_ci DEFAULT 'website'"
|
49 |
+
);
|
50 |
+
$table->addColumn(
|
51 |
+
$tableName,
|
52 |
+
'scope_value',
|
53 |
+
"VARCHAR(255) NOT NULL COLLATE utf8_general_ci DEFAULT '1'"
|
54 |
+
);
|
55 |
+
$table->addIndex(
|
56 |
+
$tableName,
|
57 |
+
$installer->getIdxName(
|
58 |
+
$tableName,
|
59 |
+
array('scope_value')
|
60 |
+
),
|
61 |
+
'scope_value'
|
62 |
+
);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
//convert the current config from default to website
|
66 |
+
$installer->run(
|
67 |
+
"UPDATE {$this->getTable('core_config_data')} SET `scope` = 'websites',"
|
68 |
+
. " `scope_id` = 1 WHERE `path`="
|
69 |
+
. "'freestyle_advancedexport/settings/chanel_id' "
|
70 |
+
. "AND `scope`='default' AND `scope_id`=0;"
|
71 |
+
);
|
72 |
+
|
73 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.2-1.2.3.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.3-1.2.4.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// >advancedexport_setup/mysql4-upgrade-1.2.3-1.2.4.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// get the version of magento!
|
12 |
+
$mageVersion = Mage::getVersion();
|
13 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
14 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
15 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
16 |
+
|
17 |
+
if ($mageEdition == 'ENTERPRISE') {
|
18 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
19 |
+
} else {
|
20 |
+
//we are assuming if you are not enterprise, you are community
|
21 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($runPureSQL) {
|
25 |
+
$installer->run(
|
26 |
+
"CREATE INDEX IDX_FREESTYLE_ADVANCEDEXPORT_QUEUE_CREATE_TIME "
|
27 |
+
. "ON {$this->getTable('advancedexport/queue')} (create_time);"
|
28 |
+
. "CREATE INDEX IDX_FREESTYLE_ADVANCEDEXPORT_QUEUE_UPDATE_TIME "
|
29 |
+
. "ON {$this->getTable('advancedexport/queue')} (update_time);"
|
30 |
+
);
|
31 |
+
} else {
|
32 |
+
$tableName = $installer->getTable('advancedexport/queue');
|
33 |
+
$table = $installer->getConnection();
|
34 |
+
|
35 |
+
/** add index on create_time and update_time **/
|
36 |
+
if ($table->isTableExists($tableName)) {
|
37 |
+
$table->addIndex(
|
38 |
+
$tableName,
|
39 |
+
$installer->getIdxName(
|
40 |
+
$tableName,
|
41 |
+
array('create_time')
|
42 |
+
),
|
43 |
+
'create_time'
|
44 |
+
);
|
45 |
+
$table->addIndex(
|
46 |
+
$tableName,
|
47 |
+
$installer->getIdxName(
|
48 |
+
$tableName,
|
49 |
+
array('update_time')
|
50 |
+
),
|
51 |
+
'update_time'
|
52 |
+
);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.4-1.2.6.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// >advancedexport_setup/mysql4-upgrade-1.2.3-1.2.4.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
// get the version of magento!
|
12 |
+
$mageVersion = Mage::getVersion();
|
13 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
14 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
15 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
16 |
+
|
17 |
+
if ($mageEdition == 'ENTERPRISE') {
|
18 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
19 |
+
} else {
|
20 |
+
//we are assuming if you are not enterprise, you are community
|
21 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($runPureSQL) {
|
25 |
+
|
26 |
+
} else {
|
27 |
+
//conversion process.. copy configuration
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.6-1.2.8.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.8-1.2.11.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.8-1.2.9.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.2.9-1.2.10.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.0-1.3.1.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.1-1.3.2.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.2-1.3.3.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.3-1.3.4.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.4-1.3.5.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.2.2-1.2.3.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.5-1.3.6.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.3.5-1.3.6.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code').DS.'core'.DS.'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.6-1.3.7.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/sql/
|
4 |
+
// advancedexport_setup/mysql4-1.3.5-1.3.6.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code') . DS . 'core' . DS . 'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.7-1.3.8.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/
|
4 |
+
// sql/advancedexport_setup/mysql4-1.3.5-1.3.6.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code') . DS . 'core' . DS . 'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.3.8-1.4.0.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/
|
4 |
+
// sql/advancedexport_setup/mysql4-1.3.5-1.3.6.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code') . DS . 'core' . DS . 'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Freestyle/Advancedexport/sql/advancedexport_setup/mysql4-upgrade-1.4.0-1.4.1.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// app/code/community/Freestyle/AdvancedExport/
|
4 |
+
// sql/advancedexport_setup/mysql4-1.3.5-1.3.6.php
|
5 |
+
|
6 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
7 |
+
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
// get the version of magento!
|
11 |
+
$mageVersion = Mage::getVersion();
|
12 |
+
//$mageEdition = strtoupper(Mage::getEdition());
|
13 |
+
$enterpriseFolder = Mage::getBaseDir('code') . DS . 'core' . DS . 'Enterprise';
|
14 |
+
$mageEdition = is_dir($enterpriseFolder) ? "ENTERPRISE" : "COMMUNITY";
|
15 |
+
|
16 |
+
if ($mageEdition == 'ENTERPRISE') {
|
17 |
+
$runPureSQL = version_compare($mageVersion, '1.12.0.0') <= 0;
|
18 |
+
} else {
|
19 |
+
//we are assuming if you are not enterprise, you are community
|
20 |
+
$runPureSQL = version_compare($mageVersion, '1.7.0.0') <= 0;
|
21 |
+
}
|
22 |
+
|
23 |
+
if ($runPureSQL) {
|
24 |
+
//$installer->run("");
|
25 |
+
} else {
|
26 |
+
//
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/advancedexport.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/************************************************************************
|
4 |
+
© 2013,2014, 2015 Freestyle Solutions. All rights reserved.
|
5 |
+
FREESTYLE SOLUTIONS, DYDACOMP, FREESTYLE COMMERCE, and all related logos
|
6 |
+
and designs are trademarks of Freestyle Solutions (formerly known as Dydacomp)
|
7 |
+
or its affiliates.
|
8 |
+
All other product and company names mentioned herein are used for
|
9 |
+
identification purposes only, and may be trademarks of
|
10 |
+
their respective companies.
|
11 |
+
************************************************************************/
|
12 |
+
-->
|
13 |
+
<layout version="0.1.0">
|
14 |
+
<advancedexport_adminhtml_index_index>
|
15 |
+
<reference name="left">
|
16 |
+
<block type="advancedexport/adminhtml_form_export_tabs" name="advancedexport_tabs"></block>
|
17 |
+
</reference>
|
18 |
+
<reference name="content">
|
19 |
+
<block type="advancedexport/adminhtml_form_export_edit" name="advancedexport.edit" ></block>
|
20 |
+
</reference>
|
21 |
+
</advancedexport_adminhtml_index_index>
|
22 |
+
</layout>
|
app/design/adminhtml/default/default/template/advancedexport/export_tab_content.phtml
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$lastExportData = $this->getLastExportData();
|
3 |
+
//echo '<pre>'; print_r($lastExportData->getData()); echo '</pre>';
|
4 |
+
$isPassiveEnabled = $this->getIsPassiveEnabled();
|
5 |
+
$helper = Mage::Helper('advancedexport');
|
6 |
+
$cShowPassiveGui = $helper->getEnablePassiveGui();
|
7 |
+
?>
|
8 |
+
<?php echo $this->getForm()->toHtml(); ?>
|
9 |
+
<div class="entry-edit-head">
|
10 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Process Actions</h4>
|
11 |
+
</div>
|
12 |
+
<div class="fieldset" id="generalProcess">
|
13 |
+
<div class="hor-scroll">
|
14 |
+
<table cellspacing="0" class="form-list exportTable">
|
15 |
+
<tbody>
|
16 |
+
<tr>
|
17 |
+
<td>
|
18 |
+
<button id="generateButton" title="Submit" type="button" onclick="submitExport()" class="scalable">
|
19 |
+
<span>Generate Export Files</span>
|
20 |
+
</button>
|
21 |
+
</td>
|
22 |
+
<td>
|
23 |
+
<div style="text-align: center; display:none;" id="waitExport">
|
24 |
+
<img width="20px" height="20px" src="<?php echo $this->getSkinUrl() . 'advancedexport/wait.gif' ?>" />
|
25 |
+
<br>
|
26 |
+
<span><strong>Please Wait... Don't close this page.</strong></span>
|
27 |
+
</div>
|
28 |
+
</td>
|
29 |
+
<td>
|
30 |
+
<button id="deleteFilesButton" title="Submit" type="button" onclick="deleteConfirm('Are you sure you want to do this?', '<?php echo $this->getDeleteUrl() ?>')" class="scalable delete">
|
31 |
+
<span>Delete All Files In Export Folder</span>
|
32 |
+
</button>
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
+
</tbody>
|
36 |
+
</table>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
<div class="entry-edit-head">
|
40 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Files from the Last Export : Date <?php echo $lastExportData->getExportDate() ?></h4>
|
41 |
+
</div>
|
42 |
+
<div class="fieldset" id="generalProcess">
|
43 |
+
<div class="hor-scroll">
|
44 |
+
<table cellspacing="0" class="form-list historyTable">
|
45 |
+
<tbody>
|
46 |
+
<tr>
|
47 |
+
<td colspan="2">
|
48 |
+
<table id="orderFiles" class="areaOrderFiles">
|
49 |
+
<?php
|
50 |
+
$counter = 1;
|
51 |
+
$oneThere = false;
|
52 |
+
if ($lastExportData->getCreatedFiles()) {
|
53 |
+
$baseUrl = Mage::getStoreConfig('web/secure/base_url');
|
54 |
+
foreach ($lastExportData->getCreatedFiles() as $one) {
|
55 |
+
$fileName = trim($one);
|
56 |
+
if ($helper->getIsFileExist($fileName)) {
|
57 |
+
$oneThere = true;
|
58 |
+
echo '<tr><td>';
|
59 |
+
echo $counter++ . '. <a href="' . $baseUrl . $helper->getExportfolder() . DS . $fileName . '">' . $fileName . '</a>';
|
60 |
+
echo ' [To Save File: Right-click the link >> Save As]</td></tr>';
|
61 |
+
}else
|
62 |
+
$oneThere = false;
|
63 |
+
}
|
64 |
+
} else {
|
65 |
+
echo 'No file(s) created. Please check \'Errors\' column in Export History Tab';
|
66 |
+
}
|
67 |
+
if (!$oneThere) {
|
68 |
+
echo 'No file(s) created. Might have been deleted.';
|
69 |
+
}
|
70 |
+
unset($baseUrl);
|
71 |
+
?>
|
72 |
+
</table>
|
73 |
+
</td>
|
74 |
+
</tr>
|
75 |
+
</tbody>
|
76 |
+
</table>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
|
80 |
+
<div class="entry-edit-head">
|
81 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Resend Order To Freestyle</h4>
|
82 |
+
</div>
|
83 |
+
<div class="fieldset" id="orderResendNotify">
|
84 |
+
<div class="hor-scroll">
|
85 |
+
<table cellspacing="0" class="form-list historyTable">
|
86 |
+
<tbody>
|
87 |
+
<tr>
|
88 |
+
<td>
|
89 |
+
<input type="text" id="notifyIncrementId" name="notifyIncrementId" value="">
|
90 |
+
<input type="hidden" id="resendnotification" name="resendnotification" value="no_action">
|
91 |
+
<label for="notifyIncrementId">Magento Order Increment ID</label>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
+
<tr>
|
95 |
+
<td>
|
96 |
+
<button id="passiveEnBtn" title="Submit" type="button" onclick="ResendNotitfication()" >
|
97 |
+
<span style="">Resend Notification To Freestyle</span>
|
98 |
+
</button>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
</tbody>
|
102 |
+
</table>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
<?php if($cShowPassiveGui=='1'):?>
|
106 |
+
<div class="entry-edit-head">
|
107 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Log Data:</h4>
|
108 |
+
</div>
|
109 |
+
<div class="fieldset" id="generalProcess">
|
110 |
+
<div class="hor-scroll">
|
111 |
+
<textarea name="logdata" id="logdata" rows="20" cols="145" class="textarea">
|
112 |
+
<?php echo $helper->readLogFile(); ?>
|
113 |
+
</textarea>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
<?php endif; //if($cShowPassiveGui=='1'):?>
|
117 |
+
<div class="entry-edit-head">
|
118 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Version and Build Date:</h4>
|
119 |
+
</div>
|
120 |
+
<div class="fieldset" id="generalProcess">
|
121 |
+
<div class="hor-scroll">
|
122 |
+
<p>Version: <?php echo $helper->getExtensionVersion(); ?> Build Version: <?php echo $helper->getBuildDate(); ?></p>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
|
126 |
+
<script>
|
127 |
+
//<![CDATA[
|
128 |
+
function submitExport() {
|
129 |
+
if (editForm.validate()) {
|
130 |
+
$('edit_form').submit();
|
131 |
+
$('waitExport').show();
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
function SendNotitfication() {
|
136 |
+
|
137 |
+
$('sendnotification').value = 'sendnotify';
|
138 |
+
$('edit_form').submit();
|
139 |
+
$('waitExport').show();
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
function ResendNotitfication() {
|
144 |
+
|
145 |
+
$('resendnotification').value = 'sendnotify';
|
146 |
+
$('edit_form').submit();
|
147 |
+
$('waitExport').show();
|
148 |
+
|
149 |
+
}
|
150 |
+
/*
|
151 |
+
function SendOneQueueItem(idToSend)
|
152 |
+
{
|
153 |
+
new Ajax.Request('<?php echo $helper->getAjaxSendUrl() ?>'+'id/'+idToSend, {
|
154 |
+
method: 'get',
|
155 |
+
onSuccess: function(transport){
|
156 |
+
|
157 |
+
if (transport.responseText){
|
158 |
+
//alert(transport.responseText);
|
159 |
+
//var data = eval("(" + transport.responseText + ")");
|
160 |
+
var data = transport.responseText.evalJSON();
|
161 |
+
showMessage(data.message, data.type);
|
162 |
+
}
|
163 |
+
|
164 |
+
//location.reload();
|
165 |
+
}
|
166 |
+
});
|
167 |
+
}
|
168 |
+
function showMessage(txt, type) {
|
169 |
+
var html = '<ul class="messages"><li class="'+type+'-msg"><ul><li>' + txt + '</li></ul></li></ul>';
|
170 |
+
$('messages').update(html);
|
171 |
+
}
|
172 |
+
*/
|
173 |
+
//]]>
|
174 |
+
</script>
|
175 |
+
|
176 |
+
<style>
|
177 |
+
.exportTable td {
|
178 |
+
padding: 10px 100px 0px 10px;
|
179 |
+
}
|
180 |
+
.historyTable td {
|
181 |
+
padding: 10px 100px 0px 0px;
|
182 |
+
}
|
183 |
+
.areaOrderFiles {
|
184 |
+
width:100%;
|
185 |
+
height: 50px;
|
186 |
+
}
|
187 |
+
|
188 |
+
</style>
|
app/design/adminhtml/default/default/template/advancedexport/system/config/button.phtml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
|
4 |
+
function check() {
|
5 |
+
if(confirm('Please save configuration prior to testing.\n'+'Perform test connection?')){
|
6 |
+
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
7 |
+
method: 'get',
|
8 |
+
onSuccess: function(transport){
|
9 |
+
|
10 |
+
if (transport.responseText){
|
11 |
+
var data = transport.responseText.evalJSON();
|
12 |
+
showMessage(data.message, data.type);
|
13 |
+
}
|
14 |
+
|
15 |
+
//location.reload();
|
16 |
+
}
|
17 |
+
});
|
18 |
+
}
|
19 |
+
}
|
20 |
+
function showMessage(txt, type) {
|
21 |
+
var html = '<ul class="messages"><li class="'+type+'-msg"><ul><li>' + txt + '</li></ul></li></ul>';
|
22 |
+
$('messages').update(html);
|
23 |
+
}
|
24 |
+
//]]>
|
25 |
+
</script>
|
26 |
+
|
27 |
+
<?php echo $this->getButtonHtml() ?>
|
app/etc/modules/Freestyle_Advancedexport.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Freestyle_Advancedexport>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Freestyle_Advancedexport>
|
8 |
+
</modules>
|
9 |
+
</config>
|
freestyleexport/.htaccess
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
############################################
|
2 |
+
## uncomment these lines for CGI mode
|
3 |
+
## make sure to specify the correct cgi php binary file name
|
4 |
+
## it might be /cgi-bin/php-cgi
|
5 |
+
|
6 |
+
# Action php5-cgi /cgi-bin/php5-cgi
|
7 |
+
# AddHandler php5-cgi .php
|
8 |
+
|
9 |
+
############################################
|
10 |
+
## GoDaddy specific options
|
11 |
+
|
12 |
+
# Options -MultiViews
|
13 |
+
|
14 |
+
## you might also need to add this line to php.ini
|
15 |
+
## cgi.fix_pathinfo = 1
|
16 |
+
## if it still doesn't work, rename php.ini to php5.ini
|
17 |
+
|
18 |
+
############################################
|
19 |
+
## this line is specific for 1and1 hosting
|
20 |
+
|
21 |
+
#AddType x-mapp-php5 .php
|
22 |
+
#AddHandler x-mapp-php5 .php
|
23 |
+
|
24 |
+
############################################
|
25 |
+
## default index file
|
26 |
+
|
27 |
+
DirectoryIndex index.php
|
28 |
+
|
29 |
+
<IfModule mod_php5.c>
|
30 |
+
|
31 |
+
############################################
|
32 |
+
## adjust memory limit
|
33 |
+
|
34 |
+
# php_value memory_limit 64M
|
35 |
+
php_value memory_limit 256M
|
36 |
+
php_value max_execution_time 18000
|
37 |
+
|
38 |
+
############################################
|
39 |
+
## disable magic quotes for php request vars
|
40 |
+
|
41 |
+
php_flag magic_quotes_gpc off
|
42 |
+
|
43 |
+
############################################
|
44 |
+
## disable automatic session start
|
45 |
+
## before autoload was initialized
|
46 |
+
|
47 |
+
php_flag session.auto_start off
|
48 |
+
|
49 |
+
############################################
|
50 |
+
## enable resulting html compression
|
51 |
+
|
52 |
+
#php_flag zlib.output_compression on
|
53 |
+
|
54 |
+
###########################################
|
55 |
+
# disable user agent verification to not break multiple image upload
|
56 |
+
|
57 |
+
php_flag suhosin.session.cryptua off
|
58 |
+
|
59 |
+
###########################################
|
60 |
+
# turn off compatibility with PHP4 when dealing with objects
|
61 |
+
|
62 |
+
php_flag zend.ze1_compatibility_mode Off
|
63 |
+
|
64 |
+
</IfModule>
|
65 |
+
|
66 |
+
<IfModule mod_security.c>
|
67 |
+
###########################################
|
68 |
+
# disable POST processing to not break multiple image upload
|
69 |
+
|
70 |
+
SecFilterEngine Off
|
71 |
+
SecFilterScanPOST Off
|
72 |
+
</IfModule>
|
73 |
+
|
74 |
+
<IfModule mod_deflate.c>
|
75 |
+
|
76 |
+
############################################
|
77 |
+
## enable apache served files compression
|
78 |
+
## http://developer.yahoo.com/performance/rules.html#gzip
|
79 |
+
|
80 |
+
# Insert filter on all content
|
81 |
+
###SetOutputFilter DEFLATE
|
82 |
+
# Insert filter on selected content types only
|
83 |
+
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
|
84 |
+
|
85 |
+
# Netscape 4.x has some problems...
|
86 |
+
#BrowserMatch ^Mozilla/4 gzip-only-text/html
|
87 |
+
|
88 |
+
# Netscape 4.06-4.08 have some more problems
|
89 |
+
#BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
90 |
+
|
91 |
+
# MSIE masquerades as Netscape, but it is fine
|
92 |
+
#BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
93 |
+
|
94 |
+
# Don't compress images
|
95 |
+
#SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
|
96 |
+
|
97 |
+
# Make sure proxies don't deliver the wrong content
|
98 |
+
#Header append Vary User-Agent env=!dont-vary
|
99 |
+
|
100 |
+
</IfModule>
|
101 |
+
|
102 |
+
<IfModule mod_ssl.c>
|
103 |
+
|
104 |
+
############################################
|
105 |
+
## make HTTPS env vars available for CGI mode
|
106 |
+
|
107 |
+
SSLOptions StdEnvVars
|
108 |
+
|
109 |
+
</IfModule>
|
110 |
+
|
111 |
+
<IfModule mod_rewrite.c>
|
112 |
+
|
113 |
+
############################################
|
114 |
+
## enable rewrites
|
115 |
+
|
116 |
+
Options +FollowSymLinks -Indexes
|
117 |
+
RewriteEngine on
|
118 |
+
|
119 |
+
############################################
|
120 |
+
## you can put here your magento root folder
|
121 |
+
## path relative to web root
|
122 |
+
|
123 |
+
#RewriteBase /magento/
|
124 |
+
#RewriteBase /
|
125 |
+
|
126 |
+
############################################
|
127 |
+
## workaround for HTTP authorization
|
128 |
+
## in CGI environment
|
129 |
+
|
130 |
+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
131 |
+
|
132 |
+
############################################
|
133 |
+
## always send 404 on missing files in these folders
|
134 |
+
|
135 |
+
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
|
136 |
+
|
137 |
+
############################################
|
138 |
+
## never rewrite for existing files, directories and links
|
139 |
+
|
140 |
+
RewriteCond %{REQUEST_FILENAME} !-f
|
141 |
+
RewriteCond %{REQUEST_FILENAME} !-d
|
142 |
+
RewriteCond %{REQUEST_FILENAME} !-l
|
143 |
+
|
144 |
+
############################################
|
145 |
+
## rewrite everything else to index.php
|
146 |
+
|
147 |
+
RewriteRule .* index.php [L]
|
148 |
+
|
149 |
+
</IfModule>
|
150 |
+
|
151 |
+
|
152 |
+
############################################
|
153 |
+
## Prevent character encoding issues from server overrides
|
154 |
+
## If you still have problems, use the second line instead
|
155 |
+
|
156 |
+
AddDefaultCharset Off
|
157 |
+
#AddDefaultCharset UTF-8
|
158 |
+
|
159 |
+
<IfModule mod_expires.c>
|
160 |
+
|
161 |
+
############################################
|
162 |
+
## Add default Expires header
|
163 |
+
## http://developer.yahoo.com/performance/rules.html#expires
|
164 |
+
|
165 |
+
ExpiresDefault "access plus 1 year"
|
166 |
+
|
167 |
+
</IfModule>
|
168 |
+
|
169 |
+
############################################
|
170 |
+
## By default allow all access
|
171 |
+
|
172 |
+
Order allow,deny
|
173 |
+
Allow from all
|
174 |
+
|
175 |
+
###########################################
|
176 |
+
## Deny access to release notes to prevent disclosure of the installed Magento version
|
177 |
+
|
178 |
+
<Files RELEASE_NOTES.txt>
|
179 |
+
order allow,deny
|
180 |
+
deny from all
|
181 |
+
</Files>
|
182 |
+
|
183 |
+
############################################
|
184 |
+
## If running in cluster environment, uncomment this
|
185 |
+
## http://developer.yahoo.com/performance/rules.html#etags
|
186 |
+
|
187 |
+
#FileETag none
|
freestyleexport/delete.me
ADDED
File without changes
|
freestyleexport/tempFiles/delete.me
ADDED
File without changes
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>FreestyleMagento</name>
|
4 |
+
<version>1.4.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.freestylesolutions.com/freestyle-commerce-subscription-agreement/">Custom License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Integrates Magento to Freestyle SaaS platform</summary>
|
10 |
+
<description>This extension provides Magento admin console users with an "Export" option. This "Export" provides functionality to export magento data for use with Freestyle. The Freestyle Advancedexport is a free must have extension for anyone working with Magento and Freestyle.</description>
|
11 |
+
<notes>Works with the latest version of Freestyle</notes>
|
12 |
+
<authors><author><name>John Canare</name><user>dydacompdev</user><email>developer@freestylesolutions.com</email></author></authors>
|
13 |
+
<date>2015-04-02</date>
|
14 |
+
<time>20:42:00</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Freestyle"><dir name="Advancedexport"><dir name="Block"><dir name="Adminhtml"><file name="Builddate.php" hash="08fe361315b777171321e494df803646"/><dir name="Form"><dir name="Edit"><file name="Form.php" hash="9cc7a746c077d5a88ac42eceebd197fd"/><dir name="Tab"><file name="ErrorsRender.php" hash="9aca6f070a45568a44e202ca619e0545"/><file name="FilesPassiveRender.php" hash="0e1e4de430f10d39d9dd8b9a49f5d230"/><file name="FilesRender.php" hash="e20979544a71a470e56968aa1170e731"/><file name="General.php" hash="a22d667813b2f5b91e958d5c2691aed3"/><file name="History.php" hash="c79666fb367cc6dce2fcf5acbafdaf07"/><file name="Passive.php" hash="a5f43e27f524e0cb0d0e5d5046916785"/><file name="Queue.php" hash="3279d2091fe5789ec5fafb56636cec0d"/><file name="UpdatetimeRender.php" hash="1db35a2341ec67b25ef46a44c107a976"/></dir><file name="Tabs.php" hash="56c664cae93e4dd71d9088eeb8cef45a"/></dir><file name="Edit.php" hash="01cc3dbcd81be4e8deb9e6127e853352"/></dir><file name="Notes.php" hash="d31a63fa2f1b513cc1c980eec056eea7"/><dir name="System"><dir name="Config"><file name="Date.php" hash="5a7b7ff9c41823f29caf0498c17ebaab"/><dir name="Form"><file name="Button.php" hash="a5c5a0dde09fdfafcb063ba6fd13da0e"/></dir></dir></dir><file name="Version.php" hash="bb077e744dee4bd6aaeea8e92784b972"/></dir></dir><dir name="Helper"><file name="Curl.php" hash="bad253fc991a51f61a17c11399eb3132"/><file name="Data.php" hash="c97f0a8842dc12c7f9bd7ee69d0f37e7"/><file name="Debug.php" hash="5852c513eef856241cabbc7d0a8f433c"/><file name="NotificationSender.php" hash="d3eb0df7b68f3c56f5a4d768d8d5faac"/><file name="Queue.php" hash="5ce841c8a59a74131c61d5d259f6a6d0"/><file name="Website.php" hash="1b2705c545143bcdd2742dfcab96d78f"/></dir><dir name="Model"><file name="Api.php" hash="7ffcba98b3947af9efe8d611996495a3"/><file name="Configuration.php" hash="e26bd7668dfc8dca06e41ead6477d7eb"/><file name="Cronjob.php" hash="dade2f3c1bb0bc4da8f5621fadb07f5e"/><dir name="Exportmodels"><file name="Abstract.php" hash="79088c0d0bdf3b6abd51a56bc9c6f1a4"/><file name="Category.php" hash="9380a71a03d697d6d16536040b274c98"/><file name="Customer.php" hash="3cb09a4a3792b4e1e8d2bdd92927101d"/><file name="Customergroup.php" hash="e428d491f5c5a7ebc5bd76f4765808d7"/><file name="Order.php" hash="78766d828920e24c65d4614be1c12857"/><file name="Product.php" hash="5bad9563fcc4d496ac7933e621249f0a"/><file name="SimpleXMLExtended.php" hash="638de7e3a590ebfce74c5dcbe965639b"/></dir><file name="History.php" hash="00bfb42bc1d8c86a73ec41a10191458a"/><dir name="Import"><dir name="Entity"><file name="Customer.php" hash="b2f1fecfbd39b2634cc389368ef66b44"/><file name="Product.php" hash="1b31624ba81415bd880bf6c3c84fc7a6"/></dir></dir><dir name="Invoice"><file name="Api.php" hash="e04e5f27e56d5297d0c29fed09f3a5e4"/></dir><dir name="Mysql4"><dir name="Configuration"><file name="Collection.php" hash="0d739ad41a263ae1e67d49f943e87b57"/></dir><file name="Configuration.php" hash="92123cbd5a308880bd8c4a6c50f4bc00"/><dir name="History"><file name="Collection.php" hash="4f6217bc233b24e981384e63971a7471"/></dir><file name="History.php" hash="d425f9f5629b6623a0c10bcde035b545"/><dir name="Passivemode"><file name="Collection.php" hash="aa1d0eb67df09498591dc94b9dd68f30"/></dir><file name="Passivemode.php" hash="8c25108d17cc79da64569065302d0201"/><dir name="Queue"><file name="Collection.php" hash="51324737e38ba8dd1b50df1b8b772efe"/></dir><file name="Queue.php" hash="0981b1549e662074af9f59e28b33ffbe"/></dir><file name="Observer.php" hash="11eb8fa7c2966cdd952d5613586e8b29"/><dir name="Order"><file name="Api.php" hash="b34edbf48ccd5e8daf3ea869fc5faa3e"/><file name="V2.php" hash="49ab537bb4ed23835be8e020842a6426"/></dir><file name="Order.php" hash="5459ba64c8b5852070b68fdfe6e57fff"/><file name="Passivemode.php" hash="393e60259d17746db9ceff819612a811"/><file name="Queue.php" hash="70e21b92dba661bf8769abf7a8e4335a"/><file name="Queuebatchsize.php" hash="2abd75111acb1de73b31aa8104f7ad45"/><file name="Resend.php" hash="4b0f8bfa0acda09a622a950340d94cc2"/><file name="Website.php" hash="b6bcad455b9ba66cb7cee7916e4c1b07"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AdvancedexportController.php" hash="c78091ed1445cc483d867b9d14d6c84d"/></dir><file name="FrontprocessController.php" hash="b96fbb3430862dc189ad5652e3e64d41"/><file name="IndexController.php" hash="8a7dc0ba6b221b0d5bcc3bcf95faa6ea"/><file name="StatusController.php" hash="bda8819211353a91c201bdc5d697cd55"/><file name="WebsiteController.php" hash="a6ee710cd5183bd78af2cacaa73a571f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="51c36f27b0e2e269f2e5223858fd7bb9"/><file name="api.xml" hash="4a7d00fd45d48d13e95ceea0a4b1924c"/><file name="config.xml" hash="a1c91fcf357d74ec32e0c35808245258"/><file name="system.xml" hash="58f32bd2c92efcdefa65dfe1f9b92aaf"/></dir><dir name="sql"><dir name="advancedexport_setup"><file name="mysql4-install-0.0.1.php" hash="c1096957085f9930a793b700077f5afd"/><file name="mysql4-upgrade-1.2.0-1.2.1.php" hash="64cf0247c1eab29330a2642b723ecac3"/><file name="mysql4-upgrade-1.2.1-1.2.2.php" hash="e9d7fc462268d3796e50296198fbda41"/><file name="mysql4-upgrade-1.2.11-1.3.0.php" hash="c48139c0b5c16cf89be3bdcea0868aa7"/><file name="mysql4-upgrade-1.2.2-1.2.3.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.2.3-1.2.4.php" hash="64861d8d3d5779c37efe582f4a8cb485"/><file name="mysql4-upgrade-1.2.4-1.2.6.php" hash="90b7737761f22bdf18b827e36a260206"/><file name="mysql4-upgrade-1.2.6-1.2.8.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.2.8-1.2.11.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.2.8-1.2.9.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.2.9-1.2.10.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.3.0-1.3.1.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.3.1-1.3.2.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.3.2-1.3.3.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.3.3-1.3.4.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.3.4-1.3.5.php" hash="2eb5732ba62e8a1bab990dd318e01a1b"/><file name="mysql4-upgrade-1.3.5-1.3.6.php" hash="2550819bb0fccb5e52f05e36f05ede3e"/><file name="mysql4-upgrade-1.3.6-1.3.7.php" hash="421e56d80e408afe96a04fef8705630f"/><file name="mysql4-upgrade-1.3.7-1.3.8.php" hash="8bdda723e5c1bbefafa4babcfdf98415"/><file name="mysql4-upgrade-1.3.8-1.4.0.php" hash="8bdda723e5c1bbefafa4babcfdf98415"/><file name="mysql4-upgrade-1.4.0-1.4.1.php" hash="8bdda723e5c1bbefafa4babcfdf98415"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Freestyle_Advancedexport.xml" hash="3b06a6c188d7f6f8e3f1a799fb85362d"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="advancedexport.xml" hash="06f702733cff6435493c2e72b10c517f"/></dir><dir name="template"><dir name="advancedexport"><file name="export_tab_content.phtml" hash="b244978529353044a292ecbe0a3db7d7"/><dir name="system"><dir name="config"><file name="button.phtml" hash="611fa4beb8d0986f28e0b72247bf36a0"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="advancedexport"><file name="wait.gif" hash="d7f40e28681760feec4d3be76cb29aa3"/></dir></dir><dir name="enterprise"><dir name="advancedexport"><file name="wait.gif" hash="d7f40e28681760feec4d3be76cb29aa3"/></dir></dir></dir></dir></target><target name="mage"><dir name="freestyleexport"><file name="delete.me" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="tempFiles"><file name="delete.me" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><file name=".htaccess" hash="1b3ffe987853dfbcb25ae5220d37945b"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/adminhtml/default/default/advancedexport/wait.gif
ADDED
Binary file
|
skin/adminhtml/default/enterprise/advancedexport/wait.gif
ADDED
Binary file
|