Version Notes
This is stable version of this extension and has been tested on various version of community editions. In this particular version we are supporting it to run on PHP V 5.5.X.
Download this release
Release Info
Developer | Rave Infosys |
Extension | Raveinfosys_OrderExporter |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.6
- app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter.php +12 -9
- app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit.php +11 -9
- app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit/Form.php +16 -14
- app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit/Tab/Form.php +69 -71
- app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit/Tabs.php +19 -18
- app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Grid.php +45 -47
- app/code/community/Raveinfosys/Exporter/Block/Exporter.php +9 -7
- app/code/community/Raveinfosys/Exporter/Block/Sales/Order/Form/Form.php +10 -7
- app/code/community/Raveinfosys/Exporter/Block/Sales/Order/Items.php +10 -7
- app/code/community/Raveinfosys/Exporter/Helper/Data.php +61 -63
- app/code/community/Raveinfosys/Exporter/Model/Createorder.php +421 -432
- app/code/community/Raveinfosys/Exporter/Model/Exporter.php +83 -95
- app/code/community/Raveinfosys/Exporter/Model/Exportorders.php +193 -201
- app/code/community/Raveinfosys/Exporter/Model/Importorders.php +249 -269
- app/code/community/Raveinfosys/Exporter/Model/Operations/Creditmemo.php +73 -78
- app/code/community/Raveinfosys/Exporter/Model/Operations/Invoice.php +41 -42
- app/code/community/Raveinfosys/Exporter/Model/Operations/Shipment.php +43 -46
- app/code/community/Raveinfosys/Exporter/controllers/Adminhtml/ExporterController.php +50 -50
- app/code/community/Raveinfosys/Exporter/controllers/Adminhtml/ImporterController.php +40 -42
- package.xml +6 -7
app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter.php
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
<?php
|
|
|
2 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
}
|
|
|
|
1 |
<?php
|
2 |
+
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_controller = 'adminhtml_exporter';
|
9 |
+
$this->_blockGroup = 'exporter';
|
10 |
+
$this->_headerText = Mage::helper('exporter')->__('Order Export');
|
11 |
+
$this->_addButtonLabel = Mage::helper('exporter')->__('Export All Orders');
|
12 |
+
parent::__construct();
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit.php
CHANGED
@@ -2,22 +2,23 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
{
|
|
|
5 |
public function __construct()
|
6 |
{
|
7 |
parent::__construct();
|
8 |
-
|
9 |
$this->_objectId = 'id';
|
10 |
$this->_blockGroup = 'exporter';
|
11 |
$this->_controller = 'adminhtml_exporter';
|
12 |
-
|
13 |
$this->_updateButton('save', 'label', Mage::helper('exporter')->__('Save Item'));
|
14 |
$this->_updateButton('delete', 'label', Mage::helper('exporter')->__('Delete Item'));
|
15 |
-
|
16 |
$this->_addButton('saveandcontinue', array(
|
17 |
-
'label'
|
18 |
-
'onclick'
|
19 |
-
'class'
|
20 |
-
|
21 |
|
22 |
$this->_formScripts[] = "
|
23 |
function toggleEditor() {
|
@@ -36,10 +37,11 @@ class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit extends Mage_Adminhtml_
|
|
36 |
|
37 |
public function getHeaderText()
|
38 |
{
|
39 |
-
if(
|
40 |
return Mage::helper('exporter')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('exporter_data')->getTitle()));
|
41 |
} else {
|
42 |
return Mage::helper('exporter')->__('Add Item');
|
43 |
}
|
44 |
}
|
45 |
-
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
{
|
5 |
+
|
6 |
public function __construct()
|
7 |
{
|
8 |
parent::__construct();
|
9 |
+
|
10 |
$this->_objectId = 'id';
|
11 |
$this->_blockGroup = 'exporter';
|
12 |
$this->_controller = 'adminhtml_exporter';
|
13 |
+
|
14 |
$this->_updateButton('save', 'label', Mage::helper('exporter')->__('Save Item'));
|
15 |
$this->_updateButton('delete', 'label', Mage::helper('exporter')->__('Delete Item'));
|
16 |
+
|
17 |
$this->_addButton('saveandcontinue', array(
|
18 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
19 |
+
'onclick' => 'saveAndContinueEdit()',
|
20 |
+
'class' => 'save',
|
21 |
+
), -100);
|
22 |
|
23 |
$this->_formScripts[] = "
|
24 |
function toggleEditor() {
|
37 |
|
38 |
public function getHeaderText()
|
39 |
{
|
40 |
+
if (Mage::registry('exporter_data') && Mage::registry('exporter_data')->getId()) {
|
41 |
return Mage::helper('exporter')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('exporter_data')->getTitle()));
|
42 |
} else {
|
43 |
return Mage::helper('exporter')->__('Add Item');
|
44 |
}
|
45 |
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit/Form.php
CHANGED
@@ -2,18 +2,20 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
{
|
5 |
-
protected function _prepareForm()
|
6 |
-
{
|
7 |
-
$form = new Varien_Data_Form(array(
|
8 |
-
'id' => 'edit_form',
|
9 |
-
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
-
'method' => 'post',
|
11 |
-
'enctype' => 'multipart/form-data'
|
12 |
-
)
|
13 |
-
);
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
protected function _prepareForm()
|
7 |
+
{
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
11 |
+
'method' => 'post',
|
12 |
+
'enctype' => 'multipart/form-data'
|
13 |
+
)
|
14 |
+
);
|
15 |
+
|
16 |
+
$form->setUseContainer(true);
|
17 |
+
$this->setForm($form);
|
18 |
+
return parent::_prepareForm();
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit/Tab/Form.php
CHANGED
@@ -2,75 +2,73 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
),
|
50 |
-
),
|
51 |
-
));
|
52 |
-
|
53 |
-
$fieldset->addField('order_csv', 'file', array(
|
54 |
-
'label' => Mage::helper('exporter')->__('Orders CSV File : '),
|
55 |
-
'required' => true,
|
56 |
-
'name' => 'order_csv',
|
57 |
-
'after_element_html' => '</br>Note : <small>Strictly recommend to use the csv file which has been generated by the same module.</small>',
|
58 |
-
));
|
59 |
-
|
60 |
-
$fieldset->addField('submit', 'submit', array(
|
61 |
-
'value' => 'Import',
|
62 |
-
'after_element_html' => '<small></small>',
|
63 |
-
'class' => 'form-button',
|
64 |
-
'tabindex' => 1
|
65 |
));
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
{
|
5 |
+
|
6 |
+
protected function _prepareForm()
|
7 |
+
{
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'config_form',
|
10 |
+
'action' => $this->getUrl('*/*/importOrders'),
|
11 |
+
'method' => 'post',
|
12 |
+
'enctype' => 'multipart/form-data'
|
13 |
+
));
|
14 |
+
$form->setUseContainer(true);
|
15 |
+
$this->setForm($form);
|
16 |
+
$fieldset = $form->addFieldset('exporter_form', array('legend' => Mage::helper('exporter')->__('Import Orders')));
|
17 |
+
|
18 |
+
$fieldset->addField('store_id', 'select', array(
|
19 |
+
'name' => 'store_id',
|
20 |
+
'label' => Mage::helper('exporter')->__('Store View'),
|
21 |
+
'title' => Mage::helper('exporter')->__('Store View'),
|
22 |
+
'required' => true,
|
23 |
+
'values' => Mage::getModel('exporter/exporter')->getStoreIds(),
|
24 |
+
));
|
25 |
+
|
26 |
+
|
27 |
+
$fieldset->addField('import_limit', 'select', array(
|
28 |
+
'label' => Mage::helper('exporter')->__('Order Import Limit'),
|
29 |
+
'name' => 'import_limit',
|
30 |
+
'required' => true,
|
31 |
+
'values' => array(
|
32 |
+
array(
|
33 |
+
'value' => '50',
|
34 |
+
'label' => Mage::helper('exporter')->__('50'),
|
35 |
+
),
|
36 |
+
array(
|
37 |
+
'value' => '100',
|
38 |
+
'label' => Mage::helper('exporter')->__('100'),
|
39 |
+
),
|
40 |
+
array(
|
41 |
+
'value' => '150',
|
42 |
+
'label' => Mage::helper('exporter')->__('150'),
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'value' => '200',
|
46 |
+
'label' => Mage::helper('exporter')->__('200'),
|
47 |
+
),
|
48 |
+
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
));
|
50 |
+
|
51 |
+
$fieldset->addField('order_csv', 'file', array(
|
52 |
+
'label' => Mage::helper('exporter')->__('Orders CSV File : '),
|
53 |
+
'required' => true,
|
54 |
+
'name' => 'order_csv',
|
55 |
+
'after_element_html' => '</br>Note : <small>Strictly recommend to use the csv file which has been generated by the same module.</small>',
|
56 |
+
));
|
57 |
+
|
58 |
+
$fieldset->addField('submit', 'submit', array(
|
59 |
+
'value' => 'Import',
|
60 |
+
'after_element_html' => '<small></small>',
|
61 |
+
'class' => 'form-button',
|
62 |
+
'tabindex' => 1
|
63 |
+
));
|
64 |
+
|
65 |
+
if (Mage::getSingleton('adminhtml/session')->getExporterData()) {
|
66 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getExporterData());
|
67 |
+
Mage::getSingleton('adminhtml/session')->setExporterData(null);
|
68 |
+
} elseif (Mage::registry('exporter_data')) {
|
69 |
+
$form->setValues(Mage::registry('exporter_data')->getData());
|
70 |
+
}
|
71 |
+
return parent::_prepareForm();
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Edit/Tabs.php
CHANGED
@@ -3,22 +3,23 @@
|
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
{
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
{
|
5 |
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('exporter_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('exporter')->__('Import Orders'));
|
12 |
+
}
|
13 |
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('exporter')->__('Import Orders'),
|
18 |
+
'title' => Mage::helper('exporter')->__('Import Orders'),
|
19 |
+
'content' => $this->getLayout()->createBlock('exporter/adminhtml_exporter_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Adminhtml/Exporter/Grid.php
CHANGED
@@ -2,8 +2,9 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
{
|
5 |
-
|
6 |
-
|
|
|
7 |
parent::__construct();
|
8 |
$this->setId('sales_order_export_grid');
|
9 |
$this->setUseAjax(true);
|
@@ -33,18 +34,18 @@ class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_
|
|
33 |
{
|
34 |
|
35 |
$this->addColumn('real_order_id', array(
|
36 |
-
'header'=> Mage::helper('sales')->__('Order #'),
|
37 |
'width' => '80px',
|
38 |
-
'type'
|
39 |
'index' => 'increment_id',
|
40 |
));
|
41 |
|
42 |
if (!Mage::app()->isSingleStoreMode()) {
|
43 |
$this->addColumn('store_id', array(
|
44 |
-
'header'
|
45 |
-
'index'
|
46 |
-
'type'
|
47 |
-
'store_view'=> true,
|
48 |
'display_deleted' => true,
|
49 |
));
|
50 |
}
|
@@ -69,46 +70,45 @@ class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_
|
|
69 |
$this->addColumn('base_grand_total', array(
|
70 |
'header' => Mage::helper('sales')->__('G.T. (Base)'),
|
71 |
'index' => 'base_grand_total',
|
72 |
-
'type'
|
73 |
'currency' => 'base_currency_code',
|
74 |
));
|
75 |
|
76 |
$this->addColumn('grand_total', array(
|
77 |
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
|
78 |
'index' => 'grand_total',
|
79 |
-
'type'
|
80 |
'currency' => 'order_currency_code',
|
81 |
));
|
82 |
|
83 |
$this->addColumn('status', array(
|
84 |
'header' => Mage::helper('sales')->__('Status'),
|
85 |
'index' => 'status',
|
86 |
-
'type'
|
87 |
'width' => '70px',
|
88 |
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
89 |
));
|
90 |
|
91 |
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
92 |
-
$this->addColumn('action',
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
'is_system' => true,
|
109 |
));
|
110 |
}
|
111 |
-
|
112 |
|
113 |
return parent::_prepareColumns();
|
114 |
}
|
@@ -120,24 +120,22 @@ class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_
|
|
120 |
$this->getMassactionBlock()->setUseSelectAll(false);
|
121 |
|
122 |
$this->getMassactionBlock()->addItem('export_order', array(
|
123 |
-
|
124 |
-
|
125 |
));
|
126 |
-
|
127 |
-
|
128 |
return $this;
|
129 |
}
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Block_Adminhtml_Exporter_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
parent::__construct();
|
9 |
$this->setId('sales_order_export_grid');
|
10 |
$this->setUseAjax(true);
|
34 |
{
|
35 |
|
36 |
$this->addColumn('real_order_id', array(
|
37 |
+
'header' => Mage::helper('sales')->__('Order #'),
|
38 |
'width' => '80px',
|
39 |
+
'type' => 'text',
|
40 |
'index' => 'increment_id',
|
41 |
));
|
42 |
|
43 |
if (!Mage::app()->isSingleStoreMode()) {
|
44 |
$this->addColumn('store_id', array(
|
45 |
+
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
|
46 |
+
'index' => 'store_id',
|
47 |
+
'type' => 'store',
|
48 |
+
'store_view' => true,
|
49 |
'display_deleted' => true,
|
50 |
));
|
51 |
}
|
70 |
$this->addColumn('base_grand_total', array(
|
71 |
'header' => Mage::helper('sales')->__('G.T. (Base)'),
|
72 |
'index' => 'base_grand_total',
|
73 |
+
'type' => 'currency',
|
74 |
'currency' => 'base_currency_code',
|
75 |
));
|
76 |
|
77 |
$this->addColumn('grand_total', array(
|
78 |
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
|
79 |
'index' => 'grand_total',
|
80 |
+
'type' => 'currency',
|
81 |
'currency' => 'order_currency_code',
|
82 |
));
|
83 |
|
84 |
$this->addColumn('status', array(
|
85 |
'header' => Mage::helper('sales')->__('Status'),
|
86 |
'index' => 'status',
|
87 |
+
'type' => 'options',
|
88 |
'width' => '70px',
|
89 |
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
90 |
));
|
91 |
|
92 |
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
93 |
+
$this->addColumn('action', array(
|
94 |
+
'header' => Mage::helper('sales')->__('Action'),
|
95 |
+
'width' => '50px',
|
96 |
+
'type' => 'action',
|
97 |
+
'getter' => 'getId',
|
98 |
+
'actions' => array(
|
99 |
+
array(
|
100 |
+
'caption' => Mage::helper('sales')->__('View'),
|
101 |
+
'url' => array('base' => 'adminhtml/sales_order/view'),
|
102 |
+
'field' => 'order_id'
|
103 |
+
)
|
104 |
+
),
|
105 |
+
'filter' => false,
|
106 |
+
'sortable' => false,
|
107 |
+
'index' => 'stores',
|
108 |
+
'is_system' => true,
|
|
|
109 |
));
|
110 |
}
|
111 |
+
|
112 |
|
113 |
return parent::_prepareColumns();
|
114 |
}
|
120 |
$this->getMassactionBlock()->setUseSelectAll(false);
|
121 |
|
122 |
$this->getMassactionBlock()->addItem('export_order', array(
|
123 |
+
'label' => Mage::helper('sales')->__('Export Orders'),
|
124 |
+
'url' => $this->getUrl('*/*/exportCsv'),
|
125 |
));
|
126 |
+
|
127 |
+
|
128 |
return $this;
|
129 |
}
|
130 |
+
|
131 |
+
public function getGridUrl()
|
132 |
+
{
|
133 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
134 |
+
}
|
135 |
+
|
136 |
+
public function getRowUrl($row)
|
137 |
+
{
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
|
|
|
app/code/community/Raveinfosys/Exporter/Block/Exporter.php
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
<?php
|
|
|
2 |
class Raveinfosys_Exporter_Block_Exporter extends Mage_Core_Block_Template
|
3 |
{
|
4 |
-
|
|
|
5 |
{
|
6 |
-
|
7 |
}
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
if (!$this->hasData('exporter')) {
|
12 |
$this->setData('exporter', Mage::registry('exporter'));
|
13 |
}
|
14 |
return $this->getData('exporter');
|
15 |
-
|
16 |
}
|
17 |
-
|
|
1 |
<?php
|
2 |
+
|
3 |
class Raveinfosys_Exporter_Block_Exporter extends Mage_Core_Block_Template
|
4 |
{
|
5 |
+
|
6 |
+
public function _prepareLayout()
|
7 |
{
|
8 |
+
return parent::_prepareLayout();
|
9 |
}
|
10 |
+
|
11 |
+
public function getExporter()
|
12 |
+
{
|
13 |
if (!$this->hasData('exporter')) {
|
14 |
$this->setData('exporter', Mage::registry('exporter'));
|
15 |
}
|
16 |
return $this->getData('exporter');
|
|
|
17 |
}
|
18 |
+
|
19 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Sales/Order/Form/Form.php
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
<?php
|
|
|
2 |
class Raveinfosys_Exporter_Block_Sales_Order_Form_Form extends Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form
|
3 |
{
|
4 |
-
|
|
|
5 |
{
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
}
|
12 |
-
|
|
1 |
<?php
|
2 |
+
|
3 |
class Raveinfosys_Exporter_Block_Sales_Order_Form_Form extends Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form
|
4 |
{
|
5 |
+
|
6 |
+
public function canCreateShippingLabel()
|
7 |
{
|
8 |
+
$shippingCarrier = $this->getOrder()->getShippingCarrier();
|
9 |
+
if ($shippingCarrier)
|
10 |
+
return $shippingCarrier && $shippingCarrier->isShippingLabelsAvailable();
|
11 |
+
else
|
12 |
+
return $shippingCarrier;
|
13 |
}
|
14 |
+
|
15 |
+
}
|
app/code/community/Raveinfosys/Exporter/Block/Sales/Order/Items.php
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
<?php
|
|
|
2 |
class Raveinfosys_Exporter_Block_Sales_Order_Items extends Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items
|
3 |
{
|
4 |
-
|
|
|
5 |
{
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
}
|
12 |
-
|
|
1 |
<?php
|
2 |
+
|
3 |
class Raveinfosys_Exporter_Block_Sales_Order_Items extends Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Items
|
4 |
{
|
5 |
+
|
6 |
+
public function canCreateShippingLabel()
|
7 |
{
|
8 |
+
$shippingCarrier = $this->getOrder()->getShippingCarrier();
|
9 |
+
if ($shippingCarrier)
|
10 |
+
return $shippingCarrier && $shippingCarrier->isShippingLabelsAvailable();
|
11 |
+
else
|
12 |
+
return $shippingCarrier;
|
13 |
}
|
14 |
+
|
15 |
+
}
|
app/code/community/Raveinfosys/Exporter/Helper/Data.php
CHANGED
@@ -2,97 +2,95 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
|
|
|
7 |
public function __construct()
|
8 |
{
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
}
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
$message = $exception->getMessage();
|
17 |
$code = $exception->getCode();
|
18 |
$file = $exception->getFile();
|
19 |
$line = $exception->getLine();
|
20 |
$trace = $exception->getTraceAsString();
|
21 |
$date = date('M d, Y h:iA');
|
22 |
-
|
23 |
-
|
24 |
$log_message = "<p><strong>Order Id:</strong> {$order_id}
|
25 |
<p><strong>Error Message:</strong> {$message}</p>
|
26 |
<p><strong>Line Number:</strong> {$line_nuber}</p>";
|
27 |
-
|
28 |
-
|
29 |
-
$log_message = "<p><strong>Invoice Error : </strong></p>
|
30 |
<p><strong>Order Id:</strong> {$order_id}</p>
|
31 |
<p><strong>Error Message:</strong> {$message}</p>";
|
32 |
-
|
33 |
-
|
34 |
-
$log_message = "<p><strong>Shipment Error : </strong></p>
|
35 |
<p><strong>Order Id:</strong> {$order_id}</p>
|
36 |
<p><strong>Error Message:</strong> {$message}</p>";
|
37 |
-
|
38 |
-
|
39 |
-
$log_message = "<p><strong>Creditmemo Error : </strong></p>
|
40 |
<p><strong>Order Id:</strong> {$order_id}</p>
|
41 |
<p><strong>Error Message:</strong> {$message}</p>";
|
42 |
-
|
43 |
-
|
44 |
-
if(
|
45 |
file_put_contents($this->error_file, '');
|
46 |
}
|
47 |
-
|
48 |
$content = file_get_contents($this->error_file);
|
49 |
-
file_put_contents($this->error_file, $content
|
50 |
}
|
51 |
-
|
52 |
-
|
53 |
{
|
54 |
$message = "Order id already exist";
|
55 |
$log_message = "<p><strong>Order Id:</strong> {$order_id}</p>
|
56 |
<p><strong>Error Message:</strong> {$message}</p>
|
57 |
<p><strong>Line Number:</strong> {$line_nuber}</p>";
|
58 |
-
|
59 |
-
|
60 |
file_put_contents($this->error_file, '');
|
61 |
}
|
62 |
$content = file_get_contents($this->error_file);
|
63 |
-
file_put_contents($this->error_file, $content
|
64 |
}
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
+
|
6 |
+
public $error_file = '';
|
7 |
+
|
8 |
public function __construct()
|
9 |
{
|
10 |
+
$this->error_file = Mage::getBaseDir('var') . '/raveinfosys/exporter/order_exception_log.htm';
|
11 |
+
$handle = fopen($this->error_file, "a+");
|
12 |
+
chmod($this->error_file, 0777);
|
13 |
}
|
14 |
+
|
15 |
+
public function logException(Exception $exception, $order_id, $type, $line_nuber = '')
|
16 |
+
{
|
17 |
$message = $exception->getMessage();
|
18 |
$code = $exception->getCode();
|
19 |
$file = $exception->getFile();
|
20 |
$line = $exception->getLine();
|
21 |
$trace = $exception->getTraceAsString();
|
22 |
$date = date('M d, Y h:iA');
|
23 |
+
|
24 |
+
if ($type == 'order') {
|
25 |
$log_message = "<p><strong>Order Id:</strong> {$order_id}
|
26 |
<p><strong>Error Message:</strong> {$message}</p>
|
27 |
<p><strong>Line Number:</strong> {$line_nuber}</p>";
|
28 |
+
} else if ($type == 'invoice') {
|
29 |
+
$log_message = "<p><strong>Invoice Error : </strong></p>
|
|
|
30 |
<p><strong>Order Id:</strong> {$order_id}</p>
|
31 |
<p><strong>Error Message:</strong> {$message}</p>";
|
32 |
+
} else if ($type == 'shipment') {
|
33 |
+
$log_message = "<p><strong>Shipment Error : </strong></p>
|
|
|
34 |
<p><strong>Order Id:</strong> {$order_id}</p>
|
35 |
<p><strong>Error Message:</strong> {$message}</p>";
|
36 |
+
} else if ($type == 'creditmemo') {
|
37 |
+
$log_message = "<p><strong>Creditmemo Error : </strong></p>
|
|
|
38 |
<p><strong>Order Id:</strong> {$order_id}</p>
|
39 |
<p><strong>Error Message:</strong> {$message}</p>";
|
40 |
+
}
|
41 |
+
|
42 |
+
if (is_file($this->error_file) === false) {
|
43 |
file_put_contents($this->error_file, '');
|
44 |
}
|
45 |
+
|
46 |
$content = file_get_contents($this->error_file);
|
47 |
+
file_put_contents($this->error_file, $content . $log_message);
|
48 |
}
|
49 |
+
|
50 |
+
public function logAvailable($order_id, $type, $line_nuber)
|
51 |
{
|
52 |
$message = "Order id already exist";
|
53 |
$log_message = "<p><strong>Order Id:</strong> {$order_id}</p>
|
54 |
<p><strong>Error Message:</strong> {$message}</p>
|
55 |
<p><strong>Line Number:</strong> {$line_nuber}</p>";
|
56 |
+
|
57 |
+
if (is_file($this->error_file) === false) {
|
58 |
file_put_contents($this->error_file, '');
|
59 |
}
|
60 |
$content = file_get_contents($this->error_file);
|
61 |
+
file_put_contents($this->error_file, $content . $log_message);
|
62 |
}
|
63 |
+
|
64 |
+
public function header()
|
65 |
+
{
|
66 |
+
file_put_contents($this->error_file, '<h3 style="text-align:center;">Error information:</h3><hr /><br />');
|
67 |
+
}
|
68 |
+
|
69 |
+
public function isPrintable()
|
70 |
+
{
|
71 |
+
if (filesize($this->error_file) > 67)
|
72 |
+
return true;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function footer()
|
76 |
+
{
|
77 |
+
$content = file_get_contents($this->error_file);
|
78 |
+
file_put_contents($this->error_file, $content . '<br /><hr /><br /><br />');
|
79 |
+
}
|
80 |
+
|
81 |
+
public function unlinkFile()
|
82 |
+
{
|
83 |
+
unlink($this->error_file);
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getVersion()
|
87 |
+
{
|
88 |
+
$m = new Mage;
|
89 |
+
$version = $m->getVersion();
|
90 |
+
if (in_array($version, array('1.5.0.0', '1.5.0.1', '1.5.1.0', '1.6.0.0', '1.9.1.1', '1.10.0.2', '1.10.1.1', '1.11.0.0')))
|
91 |
+
return true;
|
92 |
+
else
|
93 |
+
return false;
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
app/code/community/Raveinfosys/Exporter/Model/Createorder.php
CHANGED
@@ -2,443 +2,432 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Createorder extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
public $
|
7 |
-
public $
|
8 |
-
public $
|
9 |
-
public $
|
10 |
-
public $
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
public $parent_id_flag = 0;
|
17 |
public $parent_id = 0;
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
public function _construct()
|
23 |
{
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
public function setItemData()
|
28 |
{
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
//To create order
|
93 |
-
public function createOrder($sales_order_arr,$sales_order_item_arr,$store_id)
|
94 |
{
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
return $this->setPaymentReview();
|
283 |
-
|
284 |
-
return 1;
|
285 |
-
}
|
286 |
-
else
|
287 |
-
return 3;
|
288 |
-
|
289 |
}
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
Mage::getModel('sales/order_status_history')->load($history->getId())->delete()->save()->unsetData();
|
443 |
-
}
|
444 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Createorder extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
+
|
6 |
+
public $last_order_increment_id = null;
|
7 |
+
public $order_items = array();
|
8 |
+
public $shipped_item = array();
|
9 |
+
public $invoiced_item = array();
|
10 |
+
public $credit_item = array();
|
11 |
+
public $canceled_item = array();
|
12 |
+
public $partial_shipped = false;
|
13 |
+
public $partial_credited = false;
|
14 |
+
public $partial_invoiced = false;
|
15 |
+
public $order_status = null;
|
16 |
+
public $order_detai_arr = null;
|
17 |
public $parent_id_flag = 0;
|
18 |
public $parent_id = 0;
|
19 |
+
public $store_id = 0;
|
20 |
+
public $invoice_created_at = '';
|
21 |
+
public $shipment_created_at = '';
|
22 |
+
|
23 |
public function _construct()
|
24 |
{
|
25 |
+
$this->setLastOrderItemId();
|
26 |
+
}
|
27 |
+
|
28 |
public function setItemData()
|
29 |
{
|
30 |
+
$order = $this->getOrderModel($this->last_order_increment_id);
|
31 |
+
$shipped_item = array();
|
32 |
+
$invoiced_item = array();
|
33 |
+
$credit_item = array();
|
34 |
+
$canceled_item = array();
|
35 |
+
$itemCount = 0;
|
36 |
+
$orderItems = $this->order_items;
|
37 |
+
foreach ($order->getAllItems() as $item) {
|
38 |
+
$shipped_item[$item->getItemId()] = $orderItems[$itemCount]['qty_shipped'];
|
39 |
+
$invoiced_item[$item->getItemId()] = $orderItems[$itemCount]['qty_invoiced'];
|
40 |
+
$credit_item[$item->getItemId()] = $orderItems[$itemCount]['qty_refunded'];
|
41 |
+
$canceled_item[$item->getItemId()] = $orderItems[$itemCount]['qty_canceled'];
|
42 |
+
|
43 |
+
if ($orderItems[$itemCount]['qty_shipped'] > 0)
|
44 |
+
$this->partial_shipped = true;
|
45 |
+
|
46 |
+
if ($orderItems[$itemCount]['qty_invoiced'] > 0)
|
47 |
+
$this->partial_invoiced = true;
|
48 |
+
|
49 |
+
if ($orderItems[$itemCount]['qty_refunded'] > 0)
|
50 |
+
$this->partial_credited = true;
|
51 |
+
|
52 |
+
$itemCount++;
|
53 |
+
}
|
54 |
+
|
55 |
+
$this->invoiced_item = $invoiced_item;
|
56 |
+
$this->shipped_item = $shipped_item;
|
57 |
+
$this->credit_item = $credit_item;
|
58 |
+
$this->canceled_item = $canceled_item;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function setGlobalData($last_order_increment_id, $order_items, $sales_order_arr)
|
62 |
+
{
|
63 |
+
$this->last_order_increment_id = $last_order_increment_id;
|
64 |
+
$this->order_items = $order_items;
|
65 |
+
$this->order_detai_arr = $sales_order_arr;
|
66 |
+
$this->order_status = $sales_order_arr['order_state'];
|
67 |
+
$this->invoice_created_at = $sales_order_arr['invoice_created_at'];
|
68 |
+
$this->shipment_created_at = $sales_order_arr['shipment_created_at'];
|
69 |
+
$this->setTime($last_order_increment_id, $sales_order_arr);
|
70 |
+
$this->setItemData();
|
71 |
+
}
|
72 |
+
|
73 |
+
public function setTime($last_order_increment_id, $sales_order_arr)
|
74 |
+
{
|
75 |
+
Mage::getModel('sales/order')->loadByIncrementId($last_order_increment_id)
|
76 |
+
->setCreatedAt($sales_order_arr['created_at'])
|
77 |
+
->setUpdatedAt($sales_order_arr['updated_at'])
|
78 |
+
->save()
|
79 |
+
->unsetData();
|
80 |
+
}
|
81 |
+
|
82 |
+
public function setLastOrderItemId()
|
83 |
+
{
|
84 |
+
$resource = Mage::getSingleton('core/resource');
|
85 |
+
$conn = $resource->getConnection('core_read');
|
86 |
+
$results = $conn->query("SHOW TABLE STATUS LIKE '" . $resource->getTableName('sales/order_item') . "'")->fetchAll();
|
87 |
+
foreach ($results as $data)
|
88 |
+
$this->parent_id_flag = $data['Auto_increment'] - 1;
|
89 |
+
}
|
90 |
+
|
91 |
+
//To create order
|
92 |
+
public function createOrder($sales_order_arr, $sales_order_item_arr, $store_id)
|
|
|
|
|
93 |
{
|
94 |
+
$this->store_id = $store_id;
|
95 |
+
if (!$this->orderIdStatus($sales_order_arr['increment_id']))
|
96 |
+
return 2;
|
97 |
+
|
98 |
+
$transaction = Mage::getSingleton('core/resource_transaction');
|
99 |
+
$order = Mage::getModel('sales/order')
|
100 |
+
->setIncrementId($sales_order_arr['increment_id'])
|
101 |
+
->setStoreId($this->store_id)
|
102 |
+
->setStatus($sales_order_arr['order_status'])
|
103 |
+
->setHoldBeforeState($sales_order_arr['hold_before_state'])
|
104 |
+
->setHoldBeforeStatus($sales_order_arr['hold_before_status'])
|
105 |
+
->setIsVirtual($sales_order_arr['is_virtual'])
|
106 |
+
->setBaseCurrencyCode($sales_order_arr['base_currency_code'])
|
107 |
+
->setStoreCurrencyCode($sales_order_arr['store_currency_code'])
|
108 |
+
->setGlobalCurrencyCode($sales_order_arr['store_currency_code'])
|
109 |
+
->setOrderCurrencyCode($sales_order_arr['order_currency_code']);
|
110 |
+
|
111 |
+
// Set Customer data
|
112 |
+
|
113 |
+
$custm_detail = $this->getCustomerInfo($sales_order_arr['customer_email']);
|
114 |
+
|
115 |
+
if ($custm_detail) {
|
116 |
+
$order->setCustomerEmail($custm_detail['email'])
|
117 |
+
->setCustomerFirstname($custm_detail['firstname'])
|
118 |
+
->setCustomerLastname($custm_detail['lastname'])
|
119 |
+
->setCustomerId($custm_detail['entity_id'])
|
120 |
+
->setCustomerGroupId($custm_detail['group_id']);
|
121 |
+
} else {
|
122 |
+
$order->setCustomerEmail($sales_order_arr['customer_email'])
|
123 |
+
->setCustomerFirstname($sales_order_arr['customer_firstname'])
|
124 |
+
->setCustomerLastname($sales_order_arr['customer_lasttname'])
|
125 |
+
->setCustomerIsGuest(1)
|
126 |
+
->setCustomerGroupId(0);
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
// Set Billing Address
|
131 |
+
$billingAddress = Mage::getModel('sales/order_address')
|
132 |
+
->setStoreId($this->store_id)
|
133 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
|
134 |
+
->setCustomerAddressId($sales_order_arr['billing_address']['customer_address_id'])
|
135 |
+
->setPrefix($sales_order_arr['billing_address']['prefix'])
|
136 |
+
->setFirstname($sales_order_arr['billing_address']['firstname'])
|
137 |
+
->setMiddlename($sales_order_arr['billing_address']['middlename'])
|
138 |
+
->setLastname($sales_order_arr['billing_address']['lastname'])
|
139 |
+
->setSuffix($sales_order_arr['billing_address']['suffix'])
|
140 |
+
->setCompany($sales_order_arr['billing_address']['company'])
|
141 |
+
->setStreet($sales_order_arr['billing_address']['street'])
|
142 |
+
->setCity($sales_order_arr['billing_address']['city'])
|
143 |
+
->setCountryId($sales_order_arr['billing_address']['country_id'])
|
144 |
+
->setRegion($sales_order_arr['billing_address']['region'])
|
145 |
+
->setPostcode($sales_order_arr['billing_address']['postcode'])
|
146 |
+
->setTelephone($sales_order_arr['billing_address']['telephone'])
|
147 |
+
->setFax($sales_order_arr['billing_address']['fax']);
|
148 |
+
$order->setBillingAddress($billingAddress);
|
149 |
+
|
150 |
+
// Set Shipping Address
|
151 |
+
$shippingAddress = Mage::getModel('sales/order_address')
|
152 |
+
->setStoreId($this->store_id)
|
153 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
|
154 |
+
->setCustomerAddressId($sales_order_arr['shipping_address']['customer_address_id'])
|
155 |
+
->setPrefix($sales_order_arr['shipping_address']['prefix'])
|
156 |
+
->setFirstname($sales_order_arr['shipping_address']['firstname'])
|
157 |
+
->setMiddlename($sales_order_arr['shipping_address']['middlename'])
|
158 |
+
->setLastname($sales_order_arr['shipping_address']['lastname'])
|
159 |
+
->setSuffix($sales_order_arr['shipping_address']['suffix'])
|
160 |
+
->setCompany($sales_order_arr['shipping_address']['company'])
|
161 |
+
->setStreet($sales_order_arr['shipping_address']['street'])
|
162 |
+
->setCity($sales_order_arr['shipping_address']['city'])
|
163 |
+
->setCountry_id($sales_order_arr['shipping_address']['country_id'])
|
164 |
+
->setRegion($sales_order_arr['shipping_address']['region'])
|
165 |
+
->setPostcode($sales_order_arr['shipping_address']['postcode'])
|
166 |
+
->setTelephone($sales_order_arr['shipping_address']['telephone'])
|
167 |
+
->setFax($sales_order_arr['shipping_address']['fax']);
|
168 |
+
|
169 |
+
if (!$sales_order_arr['is_virtual']) {
|
170 |
+
$order->setShippingAddress($shippingAddress)
|
171 |
+
->setShippingMethod($sales_order_arr['shipping_method'])
|
172 |
+
->setShippingDescription($sales_order_arr['shipping_method']);
|
173 |
+
}
|
174 |
+
|
175 |
+
$orderPayment = Mage::getModel('sales/order_payment')
|
176 |
+
->setStoreId($this->store_id)
|
177 |
+
->setCustomerPaymentId(0)
|
178 |
+
->setMethod('checkmo')
|
179 |
+
->setPoNumber(' - ');
|
180 |
+
$order->setPayment($orderPayment);
|
181 |
+
|
182 |
+
$flag = 1;
|
183 |
+
foreach ($sales_order_item_arr as $product) {
|
184 |
+
$orderItem = Mage::getModel('sales/order_item')
|
185 |
+
->setStoreId($this->store_id)
|
186 |
+
->setQuoteItemId(0)
|
187 |
+
->setQuoteParentItemId(NULL)
|
188 |
+
->setSku($product['product_sku'])
|
189 |
+
->setProductType($product['product_type'])
|
190 |
+
->setProductOptions(unserialize($product['product_option']))
|
191 |
+
->setQtyBackordered(NULL)
|
192 |
+
->setTotalQtyOrdered($product['qty_ordered'])
|
193 |
+
->setQtyOrdered($product['qty_ordered'])
|
194 |
+
->setName($product['product_name'])
|
195 |
+
->setPrice($product['original_price'])
|
196 |
+
->setBasePrice($product['base_original_price'])
|
197 |
+
->setOriginalPrice($product['original_price'])
|
198 |
+
->setBaseOriginalPrice($product['base_original_price'])
|
199 |
+
->setRowWeight($product['row_weight'])
|
200 |
+
->setPriceInclTax($product['price_incl_tax'])
|
201 |
+
->setBasePriceInclTax($product['base_price_incl_tax'])
|
202 |
+
->setTaxAmount($product['product_tax_amount'])
|
203 |
+
->setBaseTaxAmount($product['product_base_tax_amount'])
|
204 |
+
->setTaxPercent($product['product_tax_percent'])
|
205 |
+
->setDiscountAmount($product['product_discount'])
|
206 |
+
->setBaseDiscountAmount($product['product_base_discount'])
|
207 |
+
->setDiscountPercent($product['product_discount_percent'])
|
208 |
+
->setRowTotal($product['row_total'])
|
209 |
+
->setBaseRowTotal($product['base_row_total']);
|
210 |
+
|
211 |
+
if ($product['is_child'] == 'yes')
|
212 |
+
$orderItem->setParentItemId($this->parent_id);
|
213 |
+
|
214 |
+
else if ($product['is_child'] == 'no')
|
215 |
+
$this->parent_id = $this->parent_id_flag + $flag;
|
216 |
+
|
217 |
+
$order->addItem($orderItem);
|
218 |
+
|
219 |
+
$flag++;
|
220 |
+
}
|
221 |
+
|
222 |
+
|
223 |
+
$order->setShippingAmount($sales_order_arr['shipping_amount']);
|
224 |
+
$order->setBaseShippingAmount($sales_order_arr['base_shipping_amount']);
|
225 |
+
|
226 |
+
//Apply Discount
|
227 |
+
$order->setBaseDiscountAmount($sales_order_arr['base_discount_amount']);
|
228 |
+
$order->setDiscountAmount($sales_order_arr['discount_amount']);
|
229 |
+
|
230 |
+
//Apply Tax
|
231 |
+
$order->setBaseTaxAmount($sales_order_arr['base_tax_amount']);
|
232 |
+
$order->setTaxAmount($sales_order_arr['tax_amount']);
|
233 |
+
|
234 |
+
$order->setSubtotal($sales_order_arr['subtotal'])
|
235 |
+
->setBaseSubtotal($sales_order_arr['base_subtotal'])
|
236 |
+
->setGrandTotal($sales_order_arr['grand_total'])
|
237 |
+
->setBaseGrandTotal($sales_order_arr['base_grand_total'])
|
238 |
+
->setShippingTaxAmount($sales_order_arr['shipping_tax_amount'])
|
239 |
+
->setBaseShippingTaxAmount($sales_order_arr['base_shipping_tax_amount'])
|
240 |
+
->setBaseToGlobalRate($sales_order_arr['base_to_global_rate'])
|
241 |
+
->setBaseToOrderRate($sales_order_arr['base_to_order_rate'])
|
242 |
+
->setStoreToBaseRate($sales_order_arr['store_to_base_rate'])
|
243 |
+
->setStoreToOrderRate($sales_order_arr['store_to_order_rate'])
|
244 |
+
->setSubtotalInclTax($sales_order_arr['subtotal_incl_tax'])
|
245 |
+
->setBaseSubtotalInclTax($sales_order_arr['base_subtotal_incl_tax'])
|
246 |
+
->setCouponCode($sales_order_arr['coupon_code'])
|
247 |
+
->setDiscountDescription($sales_order_arr['coupon_code'])
|
248 |
+
->setShippingInclTax($sales_order_arr['shipping_incl_tax'])
|
249 |
+
->setBaseShippingInclTax($sales_order_arr['base_shipping_incl_tax'])
|
250 |
+
->setTotalQtyOrdered($sales_order_arr['total_qty_ordered'])
|
251 |
+
->setRemoteIp($sales_order_arr['remote_ip']);
|
252 |
+
|
253 |
+
$transaction->addObject($order);
|
254 |
+
$transaction->addCommitCallback(array($order, 'place'));
|
255 |
+
$transaction->addCommitCallback(array($order, 'save'));
|
256 |
+
|
257 |
+
if ($transaction->save()) {
|
258 |
+
$this->setLastOrderItemId();
|
259 |
+
$last_order_increment_id = Mage::getSingleton("sales/order")->getCollection()->getLastItem()->getIncrementId();
|
260 |
+
|
261 |
+
$this->setGlobalData($last_order_increment_id, $sales_order_item_arr, $sales_order_arr);
|
262 |
+
|
263 |
+
if ($sales_order_arr['order_state'] == 'processing' || $sales_order_arr['order_state'] == 'complete')
|
264 |
+
return $this->setProcessing();
|
265 |
+
|
266 |
+
if ($sales_order_arr['order_state'] == 'canceled')
|
267 |
+
return $this->setCanceled();
|
268 |
+
|
269 |
+
if ($sales_order_arr['order_state'] == 'closed')
|
270 |
+
return $this->setClosed();
|
271 |
+
|
272 |
+
if ($sales_order_arr['order_state'] == 'holded')
|
273 |
+
return $this->setHolded();
|
274 |
+
|
275 |
+
if ($sales_order_arr['order_state'] == 'payment_review')
|
276 |
+
return $this->setPaymentReview();
|
277 |
+
|
278 |
+
return 1;
|
279 |
+
} else
|
280 |
+
return 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
}
|
282 |
+
|
283 |
+
public function setProcessing()
|
284 |
+
{
|
285 |
+
if ($this->partial_invoiced)
|
286 |
+
$resp = $this->getInvoiceObj()->createInvoice($this->last_order_increment_id, $this->invoiced_item, $this->invoice_created_at);
|
287 |
+
|
288 |
+
if ($this->partial_shipped)
|
289 |
+
$resp = $this->getShipmentObj()->createShipment($this->last_order_increment_id, $this->shipped_item, $this->shipment_created_at);
|
290 |
+
|
291 |
+
if ($this->partial_credited)
|
292 |
+
$resp = $this->getCreditmemoObj()->createCreditMemo($this->last_order_increment_id, $this->credit_item, $this->order_detai_arr);
|
293 |
+
|
294 |
+
$this->unsetAllData();
|
295 |
+
return 1;
|
296 |
+
}
|
297 |
+
|
298 |
+
public function setHolded()
|
299 |
+
{
|
300 |
+
try {
|
301 |
+
if ($this->setProcessing() == 1) {
|
302 |
+
$order = $this->getOrderModel($this->last_order_increment_id);
|
303 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
|
304 |
+
$order->unsetData();
|
305 |
+
return 1;
|
306 |
+
}
|
307 |
+
} catch (Exception $e) {
|
308 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'order');
|
309 |
+
Mage::helper('exporter')->footer();
|
310 |
+
return 1;
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
public function setPaymentReview()
|
315 |
+
{
|
316 |
+
try {
|
317 |
+
if ($this->setProcessing() == 1) {
|
318 |
+
$order = $this->getOrderModel($this->last_order_increment_id);
|
319 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true)->save();
|
320 |
+
$order->unsetData();
|
321 |
+
return 1;
|
322 |
+
}
|
323 |
+
} catch (Exception $e) {
|
324 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'order');
|
325 |
+
Mage::helper('exporter')->footer();
|
326 |
+
return 1;
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
public function setCanceled()
|
331 |
+
{
|
332 |
+
try {
|
333 |
+
if ($this->setProcessing() == 1) {
|
334 |
+
$this->updateCanceledQTY();
|
335 |
+
$order = $this->getOrderModel($this->last_order_increment_id);
|
336 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
337 |
+
$order->unsetData();
|
338 |
+
return 1;
|
339 |
+
}
|
340 |
+
} catch (Exception $e) {
|
341 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'order');
|
342 |
+
Mage::helper('exporter')->footer();
|
343 |
+
return 1;
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
public function setClosed()
|
348 |
+
{
|
349 |
+
try {
|
350 |
+
if ($this->setProcessing() == 1) {
|
351 |
+
$order = $this->getOrderModel($this->last_order_increment_id);
|
352 |
+
$order->setStatus(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();
|
353 |
+
$order->unsetData();
|
354 |
+
return 1;
|
355 |
+
}
|
356 |
+
} catch (Exception $e) {
|
357 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'order');
|
358 |
+
Mage::helper('exporter')->footer();
|
359 |
+
return 1;
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
public function updateCanceledQTY()
|
364 |
+
{
|
365 |
+
$items = $this->canceled_item;
|
366 |
+
foreach ($items as $itemid => $itemqty) {
|
367 |
+
$orderItem = Mage::getModel('sales/order_item')->load($itemid);
|
368 |
+
$orderItem->setQtyCanceled($itemqty)->save();
|
369 |
+
$orderItem->unsetData();
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
public function getOrderModel($last_order_increment_id)
|
374 |
+
{
|
375 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($last_order_increment_id);
|
376 |
+
return $order;
|
377 |
+
}
|
378 |
+
|
379 |
+
public function orderIdStatus($last_order_increment_id)
|
380 |
+
{
|
381 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($last_order_increment_id);
|
382 |
+
|
383 |
+
if ($order->getId())
|
384 |
+
return false;
|
385 |
+
else
|
386 |
+
return true;
|
387 |
+
}
|
388 |
+
|
389 |
+
public function unsetAllData()
|
390 |
+
{
|
391 |
+
$this->shipped_item = array();
|
392 |
+
$this->invoiced_item = array();
|
393 |
+
$this->credit_item = array();
|
394 |
+
$this->canceled_item = array();
|
395 |
+
$this->partial_shipped = false;
|
396 |
+
$this->partial_credited = false;
|
397 |
+
$this->partial_invoiced = false;
|
398 |
+
$this->order_detai_arr = false;
|
399 |
+
}
|
400 |
+
|
401 |
+
public function getInvoiceObj()
|
402 |
+
{
|
403 |
+
return Mage::getModel('exporter/operations_invoice');
|
404 |
+
}
|
405 |
+
|
406 |
+
public function getShipmentObj()
|
407 |
+
{
|
408 |
+
return Mage::getModel('exporter/operations_shipment');
|
409 |
+
}
|
410 |
+
|
411 |
+
public function getCreditmemoObj()
|
412 |
+
{
|
413 |
+
return Mage::getModel('exporter/operations_creditmemo');
|
414 |
+
}
|
415 |
+
|
416 |
+
public function getCustomerInfo($email)
|
417 |
+
{
|
418 |
+
$customer = Mage::getModel("customer/customer");
|
419 |
+
$customer->setWebsiteId(Mage::getModel('core/store')->load($this->store_id)->getWebsiteId());
|
420 |
+
if ($customer->loadByEmail($email))
|
421 |
+
return $customer->getData();
|
422 |
+
else
|
423 |
+
return false;
|
424 |
+
}
|
425 |
+
|
426 |
+
public function removeOrderStatusHistory()
|
427 |
+
{
|
428 |
+
$coll = Mage::getModel('sales/order_status_history')->getCollection()->addFieldToFilter('parent_id', Mage::getSingleton("sales/order")->getCollection()->getLastItem()->getId());
|
429 |
+
foreach ($coll as $history)
|
430 |
+
Mage::getModel('sales/order_status_history')->load($history->getId())->delete()->save()->unsetData();
|
431 |
+
}
|
432 |
+
|
433 |
+
}
|
|
|
|
|
|
app/code/community/Raveinfosys/Exporter/Model/Exporter.php
CHANGED
@@ -2,28 +2,27 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Exporter extends Mage_Core_Model_Abstract
|
4 |
{
|
|
|
5 |
public function getPaymentMethod($order)
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
}
|
19 |
|
20 |
public function getShippingMethod($order)
|
21 |
{
|
22 |
if (!$order->getIsVirtual() && $order->getShippingDescription()) {
|
23 |
return $order->getShippingDescription();
|
24 |
-
}
|
25 |
-
|
26 |
-
return $order->getShippingMethod();
|
27 |
}
|
28 |
return '';
|
29 |
}
|
@@ -39,98 +38,87 @@ class Raveinfosys_Exporter_Model_Exporter extends Mage_Core_Model_Abstract
|
|
39 |
public function formatText($string)
|
40 |
{
|
41 |
$string = str_replace(',', ' ', $string);
|
42 |
-
|
43 |
}
|
44 |
-
|
45 |
-
|
46 |
{
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
return $store_ids;
|
57 |
}
|
58 |
-
|
59 |
-
|
60 |
{
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
$collection = $order->getCreditmemosCollection();
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
return $credit_detail;
|
90 |
-
|
91 |
}
|
92 |
-
|
93 |
-
|
94 |
{
|
95 |
-
|
96 |
$collection = $order->getInvoiceCollection();
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
return $date;
|
104 |
-
|
105 |
}
|
106 |
-
|
107 |
-
|
108 |
{
|
109 |
-
|
110 |
$collection = $order->getShipmentsCollection();
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
return $date;
|
118 |
-
|
119 |
}
|
120 |
-
|
121 |
-
|
122 |
{
|
123 |
-
|
124 |
$collection = $order->getCreditmemosCollection();
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
return $date;
|
132 |
-
|
133 |
}
|
134 |
|
135 |
-
|
136 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Exporter extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
+
|
6 |
public function getPaymentMethod($order)
|
7 |
+
{
|
8 |
+
return $order->getPayment()->getMethod();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getChildInfo($item)
|
12 |
+
{
|
13 |
+
|
14 |
+
if ($item->getParentItemId())
|
15 |
+
return 'yes';
|
16 |
+
else
|
17 |
+
return 'no';
|
18 |
+
}
|
|
|
19 |
|
20 |
public function getShippingMethod($order)
|
21 |
{
|
22 |
if (!$order->getIsVirtual() && $order->getShippingDescription()) {
|
23 |
return $order->getShippingDescription();
|
24 |
+
} else if (!$order->getIsVirtual() && $order->getShippingMethod()) {
|
25 |
+
return $order->getShippingMethod();
|
|
|
26 |
}
|
27 |
return '';
|
28 |
}
|
38 |
public function formatText($string)
|
39 |
{
|
40 |
$string = str_replace(',', ' ', $string);
|
41 |
+
return $string;
|
42 |
}
|
43 |
+
|
44 |
+
public function getStoreIds()
|
45 |
{
|
46 |
+
$collection = Mage::getModel('core/store')->getCollection();
|
47 |
+
$store_ids = array();
|
48 |
+
$i = 0;
|
49 |
+
foreach ($collection as $data) {
|
50 |
+
$store_ids[$i]['label'] = $data['name'];
|
51 |
+
$store_ids[$i]['value'] = $data['store_id'];
|
52 |
+
$i++;
|
53 |
+
}
|
54 |
+
return $store_ids;
|
|
|
55 |
}
|
56 |
+
|
57 |
+
public function getCreditMemoDetail($order)
|
58 |
{
|
59 |
+
$credit_detail['adjustment_positive'] = 0;
|
60 |
+
$credit_detail['adjustment_negative'] = 0;
|
61 |
+
$credit_detail['shipping_amount'] = 0;
|
62 |
+
$credit_detail['base_shipping_amount'] = 0;
|
63 |
+
$credit_detail['subtotal'] = 0;
|
64 |
+
$credit_detail['base_subtotal'] = 0;
|
65 |
+
$credit_detail['tax_amount'] = 0;
|
66 |
+
$credit_detail['base_tax_amount'] = 0;
|
67 |
+
$credit_detail['discount_amount'] = 0;
|
68 |
+
$credit_detail['base_discount_amount'] = 0;
|
69 |
$collection = $order->getCreditmemosCollection();
|
70 |
+
if (count($collection)) {
|
71 |
+
foreach ($collection as $data) {
|
72 |
+
$credit_detail['adjustment_positive'] += $data->getData('adjustment_positive');
|
73 |
+
$credit_detail['adjustment_negative'] += $data->getData('adjustment_negative');
|
74 |
+
$credit_detail['shipping_amount'] += $data->getData('shipping_amount');
|
75 |
+
$credit_detail['base_shipping_amount'] += $data->getData('base_shipping_amount');
|
76 |
+
$credit_detail['subtotal'] += $data->getData('subtotal');
|
77 |
+
$credit_detail['base_subtotal'] += $data->getData('base_subtotal');
|
78 |
+
$credit_detail['tax_amount'] += $data->getData('tax_amount');
|
79 |
+
$credit_detail['base_tax_amount'] += $data->getData('base_tax_amount');
|
80 |
+
$credit_detail['discount_amount'] += $data->getData('discount_amount');
|
81 |
+
$credit_detail['base_discount_amount'] += $data->getData('base_discount_amount');
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
return $credit_detail;
|
|
|
|
|
|
|
86 |
}
|
87 |
+
|
88 |
+
public function getInvoiceDate($order)
|
89 |
{
|
90 |
+
$date = '';
|
91 |
$collection = $order->getInvoiceCollection();
|
92 |
+
if (count($collection)) {
|
93 |
+
foreach ($collection as $data)
|
94 |
+
$date = $data->getData('created_at');
|
95 |
+
}
|
96 |
+
|
97 |
+
return $date;
|
|
|
|
|
98 |
}
|
99 |
+
|
100 |
+
public function getShipmentDate($order)
|
101 |
{
|
102 |
+
$date = '';
|
103 |
$collection = $order->getShipmentsCollection();
|
104 |
+
if (count($collection)) {
|
105 |
+
foreach ($collection as $data)
|
106 |
+
$date = $data->getData('created_at');
|
107 |
+
}
|
108 |
+
|
109 |
+
return $date;
|
|
|
|
|
110 |
}
|
111 |
+
|
112 |
+
public function getCreditmemoDate($order)
|
113 |
{
|
114 |
+
$date = '';
|
115 |
$collection = $order->getCreditmemosCollection();
|
116 |
+
if (count($collection)) {
|
117 |
+
foreach ($collection as $data)
|
118 |
+
$date = $data->getData('created_at');
|
119 |
+
}
|
120 |
+
|
121 |
+
return $date;
|
|
|
|
|
122 |
}
|
123 |
|
124 |
+
}
|
|
app/code/community/Raveinfosys/Exporter/Model/Exportorders.php
CHANGED
@@ -2,18 +2,18 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model_Exporter
|
4 |
{
|
|
|
5 |
const ENCLOSURE = '"';
|
6 |
const DELIMITER = ',';
|
7 |
|
8 |
-
|
9 |
public function exportOrders($orders)
|
10 |
{
|
11 |
-
$fileName = 'order_export_'.date("Ymd_His").'.csv';
|
12 |
-
$fp = fopen(Mage::getBaseDir('export').'/'
|
13 |
|
14 |
$this->writeHeadRow($fp);
|
15 |
foreach ($orders as $order) {
|
16 |
-
|
17 |
$this->writeOrder($order, $fp);
|
18 |
}
|
19 |
|
@@ -22,135 +22,128 @@ class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model
|
|
22 |
return $fileName;
|
23 |
}
|
24 |
|
25 |
-
|
26 |
protected function writeHeadRow($fp)
|
27 |
{
|
28 |
fputcsv($fp, $this->getHeadRowValues(), self::DELIMITER, self::ENCLOSURE);
|
29 |
}
|
30 |
|
31 |
-
|
32 |
protected function writeOrder($order, $fp)
|
33 |
{
|
34 |
$common = $this->getCommonOrderValues($order);
|
35 |
$blank = $this->getBlankOrderValues($order);
|
36 |
-
|
37 |
$itemInc = 0;
|
38 |
-
|
39 |
-
|
40 |
-
foreach ($orderItems as $item)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
$record = array_merge($blank, $this->getOrderItemValues($item, $order, ++$itemInc));
|
50 |
-
fputcsv($fp, $record, self::DELIMITER, self::ENCLOSURE);
|
51 |
-
}
|
52 |
-
$count++;
|
53 |
}
|
54 |
-
|
55 |
}
|
56 |
|
57 |
protected function getHeadRowValues()
|
58 |
{
|
59 |
return array(
|
60 |
"order_id",
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
"qty_invoiced",
|
155 |
"qty_shipped",
|
156 |
"qty_refunded",
|
@@ -163,30 +156,29 @@ class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model
|
|
163 |
"row_weight",
|
164 |
"price_incl_tax",
|
165 |
"base_price_incl_tax",
|
166 |
-
|
167 |
-
|
168 |
"product_tax_percent",
|
169 |
"product_discount",
|
170 |
"product_base_discount",
|
171 |
"product_discount_percent",
|
172 |
"is_child",
|
173 |
-
|
174 |
-
|
175 |
-
);
|
176 |
}
|
177 |
|
178 |
//Common orders value
|
179 |
-
|
180 |
protected function getCommonOrderValues($order)
|
181 |
{
|
182 |
$shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
$order->getIncrementId(),
|
190 |
$order->getData('customer_email'),
|
191 |
$this->formatText($order->getData('customer_firstname')),
|
192 |
$this->formatText($order->getData('customer_lastname')),
|
@@ -214,42 +206,42 @@ class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model
|
|
214 |
$order->getData('coupon_code'),
|
215 |
$order->getData('shipping_incl_tax'),
|
216 |
$order->getData('base_shipping_incl_tax'),
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
$this->formatText($order->getBillingAddress()->getData('firstname')),
|
254 |
$this->formatText($order->getBillingAddress()->getData('middlename')),
|
255 |
$this->formatText($order->getBillingAddress()->getData('lastname')),
|
@@ -262,7 +254,7 @@ class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model
|
|
262 |
$order->getBillingAddress()->getData('telephone'),
|
263 |
$this->formatText($order->getBillingAddress()->getData('company')),
|
264 |
$order->getBillingAddress()->getData('fax'),
|
265 |
-
|
266 |
$shippingAddress->getData('prefix'),
|
267 |
$this->formatText($shippingAddress->getData('firstname')),
|
268 |
$this->formatText($shippingAddress->getData('middlename')),
|
@@ -277,45 +269,45 @@ class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model
|
|
277 |
$this->formatText($shippingAddress->getData('company')),
|
278 |
$shippingAddress->getData('fax'),
|
279 |
$this->getPaymentMethod($order)
|
280 |
-
|
281 |
}
|
282 |
-
|
283 |
-
|
284 |
{
|
285 |
-
|
286 |
-
'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',
|
287 |
-
'','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','',
|
288 |
-
|
289 |
}
|
290 |
|
291 |
//To return the array of ordered items
|
292 |
-
protected function getOrderItemValues($item, $order, $itemInc=1)
|
293 |
{
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
}
|
320 |
-
|
321 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Exportorders extends Raveinfosys_Exporter_Model_Exporter
|
4 |
{
|
5 |
+
|
6 |
const ENCLOSURE = '"';
|
7 |
const DELIMITER = ',';
|
8 |
|
|
|
9 |
public function exportOrders($orders)
|
10 |
{
|
11 |
+
$fileName = 'order_export_' . date("Ymd_His") . '.csv';
|
12 |
+
$fp = fopen(Mage::getBaseDir('export') . '/' . $fileName, 'w');
|
13 |
|
14 |
$this->writeHeadRow($fp);
|
15 |
foreach ($orders as $order) {
|
16 |
+
$order = Mage::getModel('sales/order')->load($order);
|
17 |
$this->writeOrder($order, $fp);
|
18 |
}
|
19 |
|
22 |
return $fileName;
|
23 |
}
|
24 |
|
|
|
25 |
protected function writeHeadRow($fp)
|
26 |
{
|
27 |
fputcsv($fp, $this->getHeadRowValues(), self::DELIMITER, self::ENCLOSURE);
|
28 |
}
|
29 |
|
|
|
30 |
protected function writeOrder($order, $fp)
|
31 |
{
|
32 |
$common = $this->getCommonOrderValues($order);
|
33 |
$blank = $this->getBlankOrderValues($order);
|
34 |
+
$orderItems = $order->getItemsCollection();
|
35 |
$itemInc = 0;
|
36 |
+
$data = array();
|
37 |
+
$count = 0;
|
38 |
+
foreach ($orderItems as $item) {
|
39 |
+
if ($count == 0) {
|
40 |
+
$record = array_merge($common, $this->getOrderItemValues($item, $order, ++$itemInc));
|
41 |
+
fputcsv($fp, $record, self::DELIMITER, self::ENCLOSURE);
|
42 |
+
} else {
|
43 |
+
$record = array_merge($blank, $this->getOrderItemValues($item, $order, ++$itemInc));
|
44 |
+
fputcsv($fp, $record, self::DELIMITER, self::ENCLOSURE);
|
45 |
+
}
|
46 |
+
$count++;
|
|
|
|
|
|
|
|
|
47 |
}
|
|
|
48 |
}
|
49 |
|
50 |
protected function getHeadRowValues()
|
51 |
{
|
52 |
return array(
|
53 |
"order_id",
|
54 |
+
"email",
|
55 |
+
"firstname",
|
56 |
+
"lastname",
|
57 |
+
"prefix",
|
58 |
+
"middlename",
|
59 |
+
"suffix",
|
60 |
+
"taxvat",
|
61 |
+
"created_at",
|
62 |
+
"updated_at",
|
63 |
+
"invoice_created_at",
|
64 |
+
"shipment_created_at",
|
65 |
+
"creditmemo_created_at",
|
66 |
+
"tax_amount",
|
67 |
+
"base_tax_amount",
|
68 |
+
"discount_amount",
|
69 |
+
"base_discount_amount",
|
70 |
+
"shipping_tax_amount",
|
71 |
+
"base_shipping_tax_amount",
|
72 |
+
"base_to_global_rate",
|
73 |
+
"base_to_order_rate",
|
74 |
+
"store_to_base_rate",
|
75 |
+
"store_to_order_rate",
|
76 |
+
"subtotal_incl_tax",
|
77 |
+
"base_subtotal_incl_tax",
|
78 |
+
"coupon_code",
|
79 |
+
"shipping_incl_tax",
|
80 |
+
"base_shipping_incl_tax",
|
81 |
+
"shipping_method",
|
82 |
+
"shipping_amount",
|
83 |
+
"subtotal",
|
84 |
+
"base_subtotal",
|
85 |
+
"grand_total",
|
86 |
+
"base_grand_total",
|
87 |
+
"base_shipping_amount",
|
88 |
+
"adjustment_positive",
|
89 |
+
"adjustment_negative",
|
90 |
+
"refunded_shipping_amount",
|
91 |
+
"base_refunded_shipping_amount",
|
92 |
+
"refunded_subtotal",
|
93 |
+
"base_refunded_subtotal",
|
94 |
+
"refunded_tax_amount",
|
95 |
+
"base_refunded_tax_amount",
|
96 |
+
"refunded_discount_amount",
|
97 |
+
"base_refunded_discount_amount",
|
98 |
+
"store_id",
|
99 |
+
"order_status",
|
100 |
+
"order_state",
|
101 |
+
"hold_before_state",
|
102 |
+
"hold_before_status",
|
103 |
+
"store_currency_code",
|
104 |
+
"base_currency_code",
|
105 |
+
"order_currency_code",
|
106 |
+
"total_paid",
|
107 |
+
"base_total_paid",
|
108 |
+
"is_virtual",
|
109 |
+
"total_qty_ordered",
|
110 |
+
"remote_ip",
|
111 |
+
"total_refunded",
|
112 |
+
"base_total_refunded",
|
113 |
+
"total_canceled",
|
114 |
+
"total_invoiced",
|
115 |
+
"customer_id",
|
116 |
+
"billing_prefix",
|
117 |
+
"billing_firstname",
|
118 |
+
"billing_middlename",
|
119 |
+
"billing_lastname",
|
120 |
+
"billing_suffix",
|
121 |
+
"billing_street_full",
|
122 |
+
"billing_city",
|
123 |
+
"billing_region",
|
124 |
+
"billing_country",
|
125 |
+
"billing_postcode",
|
126 |
+
"billing_telephone",
|
127 |
+
"billing_company",
|
128 |
+
"billing_fax",
|
129 |
+
"customer_id",
|
130 |
+
"shipping_prefix",
|
131 |
+
"shipping_firstname",
|
132 |
+
"shipping_middlename",
|
133 |
+
"shipping_lastname",
|
134 |
+
"shipping_suffix",
|
135 |
+
"shipping_street_full",
|
136 |
+
"shipping_city",
|
137 |
+
"shipping_region",
|
138 |
+
"shipping_country",
|
139 |
+
"shipping_postcode",
|
140 |
+
"shipping_telephone",
|
141 |
+
"shipping_company",
|
142 |
+
"shipping_fax",
|
143 |
+
"payment_method",
|
144 |
+
"product_sku",
|
145 |
+
"product_name",
|
146 |
+
"qty_ordered",
|
147 |
"qty_invoiced",
|
148 |
"qty_shipped",
|
149 |
"qty_refunded",
|
156 |
"row_weight",
|
157 |
"price_incl_tax",
|
158 |
"base_price_incl_tax",
|
159 |
+
"product_tax_amount",
|
160 |
+
"product_base_tax_amount",
|
161 |
"product_tax_percent",
|
162 |
"product_discount",
|
163 |
"product_base_discount",
|
164 |
"product_discount_percent",
|
165 |
"is_child",
|
166 |
+
"product_option"
|
167 |
+
);
|
|
|
168 |
}
|
169 |
|
170 |
//Common orders value
|
171 |
+
|
172 |
protected function getCommonOrderValues($order)
|
173 |
{
|
174 |
$shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
|
175 |
+
$billingAddress = $order->getBillingAddress();
|
176 |
+
if (!$shippingAddress)
|
177 |
+
$shippingAddress = $billingAddress;
|
178 |
+
|
179 |
+
$credit_detail = $this->getCreditMemoDetail($order);
|
180 |
+
return array(
|
181 |
+
$order->getIncrementId(),
|
182 |
$order->getData('customer_email'),
|
183 |
$this->formatText($order->getData('customer_firstname')),
|
184 |
$this->formatText($order->getData('customer_lastname')),
|
206 |
$order->getData('coupon_code'),
|
207 |
$order->getData('shipping_incl_tax'),
|
208 |
$order->getData('base_shipping_incl_tax'),
|
209 |
+
$this->getShippingMethod($order),
|
210 |
+
$order->getData('shipping_amount'),
|
211 |
+
$order->getData('subtotal'),
|
212 |
+
$order->getData('base_subtotal'),
|
213 |
+
$order->getData('grand_total'),
|
214 |
+
$order->getData('base_grand_total'),
|
215 |
+
$order->getData('base_shipping_amount'),
|
216 |
+
$credit_detail['adjustment_positive'],
|
217 |
+
$credit_detail['adjustment_negative'],
|
218 |
+
$credit_detail['shipping_amount'],
|
219 |
+
$credit_detail['base_shipping_amount'],
|
220 |
+
$credit_detail['subtotal'],
|
221 |
+
$credit_detail['base_subtotal'],
|
222 |
+
$credit_detail['tax_amount'],
|
223 |
+
$credit_detail['base_tax_amount'],
|
224 |
+
$credit_detail['discount_amount'],
|
225 |
+
$credit_detail['base_discount_amount'],
|
226 |
+
$order->getData('store_id'),
|
227 |
+
$order->getStatus(),
|
228 |
+
$order->getState(),
|
229 |
+
$order->getHoldBeforeState(),
|
230 |
+
$order->getHoldBeforeStatus(),
|
231 |
+
$order->getData('store_currency_code'),
|
232 |
+
$order->getData('base_currency_code'),
|
233 |
+
$order->getData('order_currency_code'),
|
234 |
+
$order->getData('total_paid'),
|
235 |
+
$order->getData('base_total_paid'),
|
236 |
+
$order->getData('is_virtual'),
|
237 |
+
$order->getData('total_qty_ordered'),
|
238 |
+
$order->getData('remote_ip'),
|
239 |
+
$order->getData('total_refunded'),
|
240 |
+
$order->getData('base_total_refunded'),
|
241 |
+
$order->getData('total_canceled'),
|
242 |
+
$order->getData('total_invoiced'),
|
243 |
+
$order->getData('customer_id'),
|
244 |
+
$this->formatText($order->getBillingAddress()->getData('prefix')),
|
245 |
$this->formatText($order->getBillingAddress()->getData('firstname')),
|
246 |
$this->formatText($order->getBillingAddress()->getData('middlename')),
|
247 |
$this->formatText($order->getBillingAddress()->getData('lastname')),
|
254 |
$order->getBillingAddress()->getData('telephone'),
|
255 |
$this->formatText($order->getBillingAddress()->getData('company')),
|
256 |
$order->getBillingAddress()->getData('fax'),
|
257 |
+
$order->getData('customer_id'),
|
258 |
$shippingAddress->getData('prefix'),
|
259 |
$this->formatText($shippingAddress->getData('firstname')),
|
260 |
$this->formatText($shippingAddress->getData('middlename')),
|
269 |
$this->formatText($shippingAddress->getData('company')),
|
270 |
$shippingAddress->getData('fax'),
|
271 |
$this->getPaymentMethod($order)
|
272 |
+
);
|
273 |
}
|
274 |
+
|
275 |
+
protected function getBlankOrderValues($order)
|
276 |
{
|
277 |
+
return array(
|
278 |
+
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
279 |
+
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
280 |
+
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');
|
281 |
}
|
282 |
|
283 |
//To return the array of ordered items
|
284 |
+
protected function getOrderItemValues($item, $order, $itemInc = 1)
|
285 |
{
|
286 |
+
return array(
|
287 |
+
$this->getItemSku($item),
|
288 |
+
$this->formatText($item->getName()),
|
289 |
+
(int) $item->getQtyOrdered(),
|
290 |
+
(int) $item->getQtyInvoiced(),
|
291 |
+
(int) $item->getQtyShipped(),
|
292 |
+
(int) $item->getQtyRefunded(),
|
293 |
+
(int) $item->getQtyCanceled(),
|
294 |
+
$item->getProductType(),
|
295 |
+
$item->getOriginalPrice(),
|
296 |
+
$item->getBaseOriginalPrice(),
|
297 |
+
$item->getRowTotal(),
|
298 |
+
$item->getBaseRowTotal(),
|
299 |
+
$item->getRowWeight(),
|
300 |
+
$item->getPriceInclTax(),
|
301 |
+
$item->getBasePriceInclTax(),
|
302 |
+
$item->getTaxAmount(),
|
303 |
+
$item->getBaseTaxAmount(),
|
304 |
+
$item->getTaxPercent(),
|
305 |
+
$item->getDiscountAmount(),
|
306 |
+
$item->getBaseDiscountAmount(),
|
307 |
+
$item->getDiscountPercent(),
|
308 |
+
$this->getChildInfo($item),
|
309 |
+
$item->getdata('product_options')
|
310 |
+
);
|
311 |
}
|
312 |
+
|
313 |
+
}
|
app/code/community/Raveinfosys/Exporter/Model/Importorders.php
CHANGED
@@ -2,279 +2,259 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Importorders extends Mage_Core_Model_Abstract
|
4 |
{
|
|
|
5 |
public $order_info = array();
|
6 |
public $order_item_info = array();
|
7 |
public $order_item_flag = 0;
|
8 |
public $store_id = 0;
|
9 |
public $import_limit = 0;
|
10 |
-
|
11 |
-
|
12 |
-
public function readCSV($csvFile,$data)
|
13 |
{
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
'customer_address_id',
|
229 |
-
'prefix',
|
230 |
-
'firstname',
|
231 |
-
'middlename',
|
232 |
-
'lastname' ,
|
233 |
-
'suffix',
|
234 |
-
'street',
|
235 |
-
'city',
|
236 |
-
'region',
|
237 |
-
'country_id',
|
238 |
-
'postcode',
|
239 |
-
'telephone' ,
|
240 |
-
'company',
|
241 |
-
'fax');
|
242 |
-
}
|
243 |
-
|
244 |
-
|
245 |
-
public function getSalesPayment()
|
246 |
-
{
|
247 |
-
return array('method');
|
248 |
-
}
|
249 |
-
|
250 |
-
|
251 |
-
public function getSalesItem()
|
252 |
-
{
|
253 |
-
return array(
|
254 |
-
'product_sku',
|
255 |
-
'product_name',
|
256 |
-
'qty_ordered',
|
257 |
-
'qty_invoiced',
|
258 |
-
'qty_shipped',
|
259 |
-
'qty_refunded',
|
260 |
-
'qty_canceled',
|
261 |
-
'product_type',
|
262 |
-
'original_price',
|
263 |
-
'base_original_price',
|
264 |
-
'row_total',
|
265 |
-
'base_row_total',
|
266 |
-
'row_weight',
|
267 |
-
'price_incl_tax',
|
268 |
-
'base_price_incl_tax',
|
269 |
-
'product_tax_amount',
|
270 |
-
'product_base_tax_amount',
|
271 |
-
'product_tax_percent',
|
272 |
-
'product_discount',
|
273 |
-
'product_base_discount',
|
274 |
-
'product_discount_percent',
|
275 |
-
'is_child',
|
276 |
-
'product_option' );
|
277 |
-
}
|
278 |
-
|
279 |
-
|
280 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Importorders extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
+
|
6 |
public $order_info = array();
|
7 |
public $order_item_info = array();
|
8 |
public $order_item_flag = 0;
|
9 |
public $store_id = 0;
|
10 |
public $import_limit = 0;
|
11 |
+
|
12 |
+
public function readCSV($csvFile, $data)
|
|
|
13 |
{
|
14 |
+
$this->import_limit = $data['import_limit'];
|
15 |
+
$this->store_id = $data['store_id'];
|
16 |
+
$file_handle = fopen($csvFile, 'r');
|
17 |
+
$i = 0;
|
18 |
+
$decline = array();
|
19 |
+
$available = array();
|
20 |
+
$success = 0;
|
21 |
+
$parent_flag = 0;
|
22 |
+
$invalid = 0;
|
23 |
+
$line_number = 2;
|
24 |
+
$total_order = 0;
|
25 |
+
Mage::helper('exporter')->unlinkFile();
|
26 |
+
Mage::helper('exporter')->header();
|
27 |
+
while (!feof($file_handle)) {
|
28 |
+
$line_of_text[] = fgetcsv($file_handle);
|
29 |
+
|
30 |
+
if ($i != 0) {
|
31 |
+
if ($line_of_text[$i][0] != '' && $parent_flag == 0) {
|
32 |
+
$this->insertOrderData($line_of_text[$i]);
|
33 |
+
$parent_flag = 1;
|
34 |
+
$total_order++;
|
35 |
+
} else if ($line_of_text[$i][91] != '' && $parent_flag == 1 && $line_of_text[$i][0] == '') {
|
36 |
+
$this->insertOrderItem($line_of_text[$i]);
|
37 |
+
} else if ($parent_flag == 1) {
|
38 |
+
try {
|
39 |
+
$message = Mage::getModel('exporter/createorder')->createOrder($this->order_info, $this->order_item_info, $this->store_id);
|
40 |
+
Mage::getModel('exporter/createorder')->removeOrderStatusHistory();
|
41 |
+
} catch (Exception $e) {
|
42 |
+
Mage::helper('exporter')->logException($e, $this->order_info['increment_id'], 'order', $line_number);
|
43 |
+
Mage::helper('exporter')->footer();
|
44 |
+
$decline[] = $this->order_info['increment_id'];
|
45 |
+
$message = 0;
|
46 |
+
}
|
47 |
+
|
48 |
+
if ($message == 1)
|
49 |
+
$success++;
|
50 |
+
|
51 |
+
if ($message == 2) {
|
52 |
+
Mage::helper('exporter')->logAvailable($this->order_info['increment_id'], 'order', $line_number);
|
53 |
+
Mage::helper('exporter')->footer();
|
54 |
+
$decline[] = $this->order_info['increment_id'];
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->order_info = array();
|
58 |
+
$this->order_item_info = array();
|
59 |
+
$this->order_item_flag = 0;
|
60 |
+
|
61 |
+
if (is_array($line_of_text[$i])) {
|
62 |
+
$this->insertOrderData($line_of_text[$i]);
|
63 |
+
$parent_flag = 1;
|
64 |
+
$line_number = $i + 1;
|
65 |
+
$total_order++;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
$i++;
|
71 |
+
|
72 |
+
if ($this->import_limit < $total_order)
|
73 |
+
break;
|
74 |
+
}
|
75 |
+
$isPrintable = Mage::helper('exporter')->isPrintable();
|
76 |
+
if ($success)
|
77 |
+
Mage::getModel('core/session')->addSuccess(Mage::helper('exporter')->__('Total ' . $success . ' order(s) imported successfully!'));
|
78 |
+
|
79 |
+
if ($decline || $isPrintable)
|
80 |
+
Mage::getModel('core/session')->addError(Mage::helper('exporter')->__('Click <a href="' . Mage::helper("adminhtml")->getUrl("*/exporter/exportLog") . '">here</a> to view the error log'));
|
81 |
+
|
82 |
+
fclose($file_handle);
|
83 |
+
|
84 |
+
return array($success, $decline);
|
85 |
+
}
|
86 |
+
|
87 |
+
public function insertOrderData($orders_data)
|
88 |
+
{
|
89 |
+
$sales_order_arr = array();
|
90 |
+
$sales_order_item_arr = array();
|
91 |
+
$sales_order = $this->getSalesTable();
|
92 |
+
$sales_payment = $this->getSalesPayment();
|
93 |
+
$sales_shipping = $this->getSalesBilling();
|
94 |
+
$sales_billing = $this->getSalesBilling();
|
95 |
+
$sales_order_item = $this->getSalesItem();
|
96 |
+
$model = Mage::getModel('sales/order');
|
97 |
+
$i = 0;
|
98 |
+
$j = 0;
|
99 |
+
$k = 0;
|
100 |
+
$l = 0;
|
101 |
+
$m = 0;
|
102 |
+
|
103 |
+
foreach ($orders_data as $order) {
|
104 |
+
if (count($sales_order) > $i) {
|
105 |
+
$sales_order_arr[$sales_order[$i]] = $order;
|
106 |
+
} else if (count($sales_billing) > $j) {
|
107 |
+
$sales_billing[$j] . $sales_order_arr['billing_address'][$sales_billing[$j]] = $order;
|
108 |
+
$j++;
|
109 |
+
} else if (count($sales_shipping) > $k) {
|
110 |
+
$sales_order_arr['shipping_address'][$sales_shipping[$k]] = $order;
|
111 |
+
$k++;
|
112 |
+
} else if (count($sales_payment) > $l) {
|
113 |
+
$sales_order_arr['payment'][$sales_payment[$l]] = $order;
|
114 |
+
$l++;
|
115 |
+
} else if (count($sales_order_item) > $m) {
|
116 |
+
$sales_order_item_arr[$sales_order_item[$m]] = $order;
|
117 |
+
$m++;
|
118 |
+
}
|
119 |
+
$i++;
|
120 |
+
}
|
121 |
+
|
122 |
+
$this->order_info = $sales_order_arr;
|
123 |
+
$this->order_item_info[$this->order_item_flag] = $sales_order_item_arr;
|
124 |
+
$this->order_item_flag++;
|
125 |
}
|
126 |
+
|
127 |
+
public function insertOrderItem($orders_data)
|
128 |
+
{
|
129 |
+
$sales_order_item_arr = array();
|
130 |
+
$sales_order_item = $this->getSalesItem();
|
131 |
+
$i = 0;
|
132 |
+
for ($j = 91; $j < count($orders_data); $j++) {
|
133 |
+
if (count($sales_order_item) > $i)
|
134 |
+
$sales_order_item_arr[$sales_order_item[$i]] = $orders_data[$j];
|
135 |
+
$i++;
|
136 |
+
}
|
137 |
+
$this->order_item_info[$this->order_item_flag] = $sales_order_item_arr;
|
138 |
+
$this->order_item_flag++;
|
139 |
+
}
|
140 |
+
|
141 |
+
public function getSalesTable()
|
142 |
+
{
|
143 |
+
return array(
|
144 |
+
'increment_id',
|
145 |
+
'customer_email',
|
146 |
+
'customer_firstname',
|
147 |
+
'customer_lasttname',
|
148 |
+
'customer_prefix',
|
149 |
+
'customer_middlename',
|
150 |
+
'customer_suffix',
|
151 |
+
'taxvat',
|
152 |
+
'created_at',
|
153 |
+
'updated_at',
|
154 |
+
'invoice_created_at',
|
155 |
+
'shipment_created_at',
|
156 |
+
'creditmemo_created_at',
|
157 |
+
'tax_amount',
|
158 |
+
'base_tax_amount',
|
159 |
+
'discount_amount',
|
160 |
+
'base_discount_amount',
|
161 |
+
'shipping_tax_amount',
|
162 |
+
'base_shipping_tax_amount',
|
163 |
+
'base_to_global_rate',
|
164 |
+
'base_to_order_rate',
|
165 |
+
'store_to_base_rate',
|
166 |
+
'store_to_order_rate',
|
167 |
+
'subtotal_incl_tax',
|
168 |
+
'base_subtotal_incl_tax',
|
169 |
+
'coupon_code',
|
170 |
+
'shipping_incl_tax',
|
171 |
+
'base_shipping_incl_tax',
|
172 |
+
'shipping_method',
|
173 |
+
'shipping_amount',
|
174 |
+
'subtotal',
|
175 |
+
'base_subtotal',
|
176 |
+
'grand_total',
|
177 |
+
'base_grand_total',
|
178 |
+
'base_shipping_amount',
|
179 |
+
'adjustment_positive',
|
180 |
+
'adjustment_negative',
|
181 |
+
'refunded_shipping_amount',
|
182 |
+
'base_refunded_shipping_amount',
|
183 |
+
'refunded_subtotal',
|
184 |
+
'base_refunded_subtotal',
|
185 |
+
'refunded_tax_amount',
|
186 |
+
'base_refunded_tax_amount',
|
187 |
+
'refunded_discount_amount',
|
188 |
+
'base_refunded_discount_amount',
|
189 |
+
'store_id',
|
190 |
+
'order_status',
|
191 |
+
'order_state',
|
192 |
+
'hold_before_state',
|
193 |
+
'hold_before_status',
|
194 |
+
'store_currency_code',
|
195 |
+
'base_currency_code',
|
196 |
+
'order_currency_code',
|
197 |
+
'total_paid',
|
198 |
+
'base_total_paid',
|
199 |
+
'is_virtual',
|
200 |
+
'total_qty_ordered',
|
201 |
+
'remote_ip',
|
202 |
+
'total_refunded',
|
203 |
+
'base_total_refunded',
|
204 |
+
'total_canceled',
|
205 |
+
'total_invoiced');
|
206 |
+
}
|
207 |
+
|
208 |
+
public function getSalesBilling()
|
209 |
+
{
|
210 |
+
return array(
|
211 |
+
'customer_address_id',
|
212 |
+
'prefix',
|
213 |
+
'firstname',
|
214 |
+
'middlename',
|
215 |
+
'lastname',
|
216 |
+
'suffix',
|
217 |
+
'street',
|
218 |
+
'city',
|
219 |
+
'region',
|
220 |
+
'country_id',
|
221 |
+
'postcode',
|
222 |
+
'telephone',
|
223 |
+
'company',
|
224 |
+
'fax');
|
225 |
+
}
|
226 |
+
|
227 |
+
public function getSalesPayment()
|
228 |
+
{
|
229 |
+
return array('method');
|
230 |
+
}
|
231 |
+
|
232 |
+
public function getSalesItem()
|
233 |
+
{
|
234 |
+
return array(
|
235 |
+
'product_sku',
|
236 |
+
'product_name',
|
237 |
+
'qty_ordered',
|
238 |
+
'qty_invoiced',
|
239 |
+
'qty_shipped',
|
240 |
+
'qty_refunded',
|
241 |
+
'qty_canceled',
|
242 |
+
'product_type',
|
243 |
+
'original_price',
|
244 |
+
'base_original_price',
|
245 |
+
'row_total',
|
246 |
+
'base_row_total',
|
247 |
+
'row_weight',
|
248 |
+
'price_incl_tax',
|
249 |
+
'base_price_incl_tax',
|
250 |
+
'product_tax_amount',
|
251 |
+
'product_base_tax_amount',
|
252 |
+
'product_tax_percent',
|
253 |
+
'product_discount',
|
254 |
+
'product_base_discount',
|
255 |
+
'product_discount_percent',
|
256 |
+
'is_child',
|
257 |
+
'product_option');
|
258 |
+
}
|
259 |
+
|
260 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Raveinfosys/Exporter/Model/Operations/Creditmemo.php
CHANGED
@@ -2,85 +2,80 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Operations_Creditmemo extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
$order = $this->getOrderModel($order_id);
|
8 |
-
try{
|
9 |
-
$data = array('qtys' => $credit_item ,'shipping_amount'=>$creditDetail['refunded_shipping_amount'],
|
10 |
-
'adjustment_positive'=>$creditDetail['adjustment_positive'],'adjustment_negative'=>$creditDetail['adjustment_negative']);
|
11 |
-
if(Mage::helper('exporter')->getVersion())
|
12 |
-
{
|
13 |
-
$service = Mage::getModel('sales/service_order', $order);
|
14 |
-
$creditMemo = $service->prepareCreditmemo($data);
|
15 |
-
$creditMemo = $creditMemo->setState(2)->save();
|
16 |
-
$this->updateStatus($order_id,$creditDetail);
|
17 |
-
}
|
18 |
-
else
|
19 |
-
{
|
20 |
-
$creditMemo = Mage::getModel('sales/order_creditmemo_api')
|
21 |
-
->create($order_id, $data ,null ,0,0);
|
22 |
-
}
|
23 |
-
|
24 |
-
$model = Mage::getSingleton("sales/order_creditmemo");
|
25 |
-
$credit_id = $model->getCollection()->getLastItem()->getId();
|
26 |
-
$model->load($credit_id)
|
27 |
-
->setCreatedAt($creditDetail['creditmemo_created_at'])
|
28 |
-
->setUpdatedAt($creditDetail['creditmemo_created_at'])
|
29 |
-
->save()
|
30 |
-
->unsetData();
|
31 |
-
|
32 |
-
$this->updateCreditQTY($credit_item);
|
33 |
-
|
34 |
-
}catch (Exception $e) {
|
35 |
-
|
36 |
-
Mage::helper('exporter')->logException($e,$order->getIncrementId(),'creditmemo');
|
37 |
-
Mage::helper('exporter')->footer();
|
38 |
-
return true;
|
39 |
-
}
|
40 |
-
$order->unsetData();
|
41 |
-
return true;
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
public function updateCreditQTY($credit_item)
|
47 |
-
{
|
48 |
-
foreach($credit_item as $itemid => $itemqty)
|
49 |
-
{
|
50 |
-
$orderItem = Mage::getModel('sales/order_item')->load($itemid);
|
51 |
-
$orderItem->setQtyRefunded($itemqty)->save();
|
52 |
-
$orderItem->unsetData();
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
public function updateStatus($order_id,$refunded)
|
57 |
{
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
-
|
81 |
-
|
82 |
{
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
85 |
}
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Operations_Creditmemo extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
+
|
6 |
+
public function createCreditMemo($order_id, $credit_item, $creditDetail)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
{
|
8 |
+
$order = $this->getOrderModel($order_id);
|
9 |
+
try {
|
10 |
+
$data = array('qtys' => $credit_item, 'shipping_amount' => $creditDetail['refunded_shipping_amount'],
|
11 |
+
'adjustment_positive' => $creditDetail['adjustment_positive'], 'adjustment_negative' => $creditDetail['adjustment_negative']);
|
12 |
+
if (Mage::helper('exporter')->getVersion()) {
|
13 |
+
$service = Mage::getModel('sales/service_order', $order);
|
14 |
+
$creditMemo = $service->prepareCreditmemo($data);
|
15 |
+
$creditMemo = $creditMemo->setState(2)->save();
|
16 |
+
$this->updateStatus($order_id, $creditDetail);
|
17 |
+
} else {
|
18 |
+
$creditMemo = Mage::getModel('sales/order_creditmemo_api')
|
19 |
+
->create($order_id, $data, null, 0, 0);
|
20 |
+
}
|
21 |
+
|
22 |
+
$model = Mage::getSingleton("sales/order_creditmemo");
|
23 |
+
$credit_id = $model->getCollection()->getLastItem()->getId();
|
24 |
+
$model->load($credit_id)
|
25 |
+
->setCreatedAt($creditDetail['creditmemo_created_at'])
|
26 |
+
->setUpdatedAt($creditDetail['creditmemo_created_at'])
|
27 |
+
->save()
|
28 |
+
->unsetData();
|
29 |
+
|
30 |
+
$this->updateCreditQTY($credit_item);
|
31 |
+
} catch (Exception $e) {
|
32 |
+
|
33 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'creditmemo');
|
34 |
+
Mage::helper('exporter')->footer();
|
35 |
+
return true;
|
36 |
+
}
|
37 |
+
$order->unsetData();
|
38 |
+
return true;
|
39 |
}
|
40 |
+
|
41 |
+
public function updateCreditQTY($credit_item)
|
42 |
{
|
43 |
+
foreach ($credit_item as $itemid => $itemqty) {
|
44 |
+
$orderItem = Mage::getModel('sales/order_item')->load($itemid);
|
45 |
+
$orderItem->setQtyRefunded($itemqty)->save();
|
46 |
+
$orderItem->unsetData();
|
47 |
+
}
|
48 |
}
|
49 |
+
|
50 |
+
public function updateStatus($order_id, $refunded)
|
51 |
+
{
|
52 |
+
$order = $this->getOrderModel($order_id);
|
53 |
+
|
54 |
+
//set creditmemo data
|
55 |
+
$order->setSubtotalRefunded($refunded['refunded_subtotal'])
|
56 |
+
->setBaseSubtotalRefunded($refunded['refunded_subtotal'])
|
57 |
+
->setTaxRefunded($refunded['refunded_tax_amount'])
|
58 |
+
->setBaseTaxRefunded($refunded['base_refunded_tax_amount'])
|
59 |
+
->setDiscountRefunded($refunded['refunded_discount_amount'])
|
60 |
+
->setBaseDiscountRefunded($refunded['base_refunded_discount_amount'])
|
61 |
+
->setShippingRefunded($refunded['refunded_shipping_amount'])
|
62 |
+
->setBaseShippingRefunded($refunded['base_refunded_shipping_amount'])
|
63 |
+
->setTotalRefunded($refunded['total_refunded'])
|
64 |
+
->setBaseTotalRefunded($refunded['base_total_refunded'])
|
65 |
+
->setTotalOfflineRefunded($refunded['total_refunded'])
|
66 |
+
->setBaseTotalOfflineRefunded($refunded['base_total_refunded'])
|
67 |
+
->setAdjustmentNegative($refunded['adjustment_positive'])
|
68 |
+
->setBaseAdjustmentNegative($refunded['adjustment_positive'])
|
69 |
+
->setAdjustmentPositive($refunded['adjustment_negative'])
|
70 |
+
->setBaseAdjustmentPositive($refunded['adjustment_negative'])
|
71 |
+
->save();
|
72 |
+
$order->unsetData();
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getOrderModel($last_order_increment_id)
|
76 |
+
{
|
77 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($last_order_increment_id);
|
78 |
+
return $order;
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
app/code/community/Raveinfosys/Exporter/Model/Operations/Invoice.php
CHANGED
@@ -2,47 +2,46 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Operations_Invoice extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
public function updateInvoiceQTY($invoice_item)
|
34 |
-
{
|
35 |
-
foreach($invoice_item as $itemid => $itemqty)
|
36 |
-
{
|
37 |
-
$orderItem = Mage::getModel('sales/order_item')->load($itemid);
|
38 |
-
$orderItem->setQtyInvoiced($itemqty)->save();
|
39 |
-
$orderItem->unsetData();
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
public function getOrderModel($last_order_increment_id)
|
44 |
{
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
}
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Operations_Invoice extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
+
|
6 |
+
public function createInvoice($order_id, $invoice_item, $date)
|
7 |
+
{
|
8 |
+
$order = $this->getOrderModel($order_id);
|
9 |
+
try {
|
10 |
+
if ($order->canInvoice()) {
|
11 |
+
$invoiceId = Mage::getModel('sales/order_invoice_api')
|
12 |
+
->create($order->getIncrementId(), $invoice_item, null, 0, 0);
|
13 |
+
|
14 |
+
if ($invoiceId) {
|
15 |
+
Mage::getSingleton("sales/order_invoice")->loadByIncrementId($invoiceId)
|
16 |
+
->setCreatedAt($date)
|
17 |
+
->setUpdatedAt($date)
|
18 |
+
->save()
|
19 |
+
->unsetData();
|
20 |
+
$this->updateInvoiceQTY($invoice_item);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
} catch (Exception $e) {
|
24 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'invoice');
|
25 |
+
Mage::helper('exporter')->footer();
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
$order->unsetData();
|
29 |
+
return $invoiceId;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function updateInvoiceQTY($invoice_item)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
{
|
34 |
+
foreach ($invoice_item as $itemid => $itemqty) {
|
35 |
+
$orderItem = Mage::getModel('sales/order_item')->load($itemid);
|
36 |
+
$orderItem->setQtyInvoiced($itemqty)->save();
|
37 |
+
$orderItem->unsetData();
|
38 |
+
}
|
39 |
}
|
40 |
+
|
41 |
+
public function getOrderModel($last_order_increment_id)
|
42 |
+
{
|
43 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($last_order_increment_id);
|
44 |
+
return $order;
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Raveinfosys/Exporter/Model/Operations/Shipment.php
CHANGED
@@ -2,49 +2,46 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Operations_Shipment extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
public function createShipment($order_id
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
return $order;
|
49 |
-
}
|
50 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Model_Operations_Shipment extends Mage_Core_Model_Abstract
|
4 |
{
|
5 |
+
|
6 |
+
public function createShipment($order_id, $shipped_item, $date)
|
7 |
+
{
|
8 |
+
$order = $this->getOrderModel($order_id);
|
9 |
+
try {
|
10 |
+
if ($order->canShip()) {
|
11 |
+
$shipId = Mage::getModel('sales/order_shipment_api')
|
12 |
+
->create($order_id, $shipped_item, null, 0, 0);
|
13 |
+
|
14 |
+
if ($shipId) {
|
15 |
+
Mage::getSingleton("sales/order_shipment")->loadByIncrementId($shipId)
|
16 |
+
->setCreatedAt($date)
|
17 |
+
->setUpdatedAt($date)
|
18 |
+
->save()
|
19 |
+
->unsetData();
|
20 |
+
$this->updateShipmentQTY($shipped_item);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
} catch (Exception $e) {
|
24 |
+
Mage::helper('exporter')->logException($e, $order->getIncrementId(), 'shipment');
|
25 |
+
Mage::helper('exporter')->footer();
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
$order->unsetData();
|
29 |
+
return $shipment;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function updateShipmentQTY($shipped_item)
|
33 |
+
{
|
34 |
+
foreach ($shipped_item as $itemid => $itemqty) {
|
35 |
+
$orderItem = Mage::getModel('sales/order_item')->load($itemid);
|
36 |
+
$orderItem->setQtyShipped($itemqty)->save();
|
37 |
+
$orderItem->unsetData();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getOrderModel($last_order_increment_id)
|
42 |
+
{
|
43 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($last_order_increment_id);
|
44 |
+
return $order;
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
|
|
|
|
|
app/code/community/Raveinfosys/Exporter/controllers/Adminhtml/ExporterController.php
CHANGED
@@ -2,56 +2,56 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Adminhtml_ExporterController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
{
|
47 |
-
|
48 |
-
|
49 |
-
$this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('export').'/'.$file));
|
50 |
}
|
51 |
|
52 |
-
|
53 |
-
{
|
54 |
-
$file = 'order_exception_log.htm';
|
55 |
-
$this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('var') .'/raveinfosys/exporter/'.$file));
|
56 |
-
}
|
57 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Adminhtml_ExporterController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
+
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('exporter/items')
|
10 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
11 |
+
|
12 |
+
return $this;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$this->_initAction()
|
18 |
+
->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function gridAction()
|
22 |
+
{
|
23 |
+
$this->_initAction()
|
24 |
+
->renderLayout();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function newAction()
|
28 |
+
{
|
29 |
+
$this->_forward('exportall');
|
30 |
+
}
|
31 |
+
|
32 |
+
public function exportallAction()
|
33 |
+
{
|
34 |
+
$orders = Mage::getModel('sales/order')->getCollection()
|
35 |
+
->addAttributeToSelect('entity_id');
|
36 |
+
$order_arr = array();
|
37 |
+
foreach ($orders as $order) {
|
38 |
+
$order_arr[] = $order->getId();
|
39 |
+
}
|
40 |
+
$file = Mage::getModel('exporter/exportorders')->exportOrders($order_arr);
|
41 |
+
$this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('export') . '/' . $file));
|
42 |
+
}
|
43 |
+
|
44 |
+
public function exportCsvAction()
|
45 |
+
{
|
46 |
+
$orders = $this->getRequest()->getPost('order_ids', array());
|
47 |
+
$file = Mage::getModel('exporter/exportorders')->exportOrders($orders);
|
48 |
+
$this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('export') . '/' . $file));
|
49 |
+
}
|
50 |
+
|
51 |
+
public function exportLogAction()
|
52 |
{
|
53 |
+
$file = 'order_exception_log.htm';
|
54 |
+
$this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('var') . '/raveinfosys/exporter/' . $file));
|
|
|
55 |
}
|
56 |
|
57 |
+
}
|
|
|
|
|
|
|
|
|
|
app/code/community/Raveinfosys/Exporter/controllers/Adminhtml/ImporterController.php
CHANGED
@@ -2,45 +2,43 @@
|
|
2 |
|
3 |
class Raveinfosys_Exporter_Adminhtml_ImporterController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
}
|
46 |
-
}
|
2 |
|
3 |
class Raveinfosys_Exporter_Adminhtml_ImporterController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
+
|
6 |
+
protected function _initAction()
|
7 |
+
{
|
8 |
+
$this->loadLayout()
|
9 |
+
->_setActiveMenu('exporter/items')
|
10 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Orders Import'), Mage::helper('adminhtml')->__('Orders Import'));
|
11 |
+
|
12 |
+
return $this;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
$this->_initAction()
|
18 |
+
->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function importOrdersAction()
|
22 |
+
{
|
23 |
+
if ($_FILES['order_csv']['name'] != '') {
|
24 |
+
$data = $this->getRequest()->getPost();
|
25 |
+
try {
|
26 |
+
$uploader = new Varien_File_Uploader('order_csv');
|
27 |
+
$uploader->setAllowedExtensions(array('csv'));
|
28 |
+
$uploader->setAllowRenameFiles(false);
|
29 |
+
$uploader->setFilesDispersion(false);
|
30 |
+
$path = Mage::getBaseDir('media') . DS . 'raveinfosys/exporter/import/';
|
31 |
+
$uploader->save($path, $_FILES['order_csv']['name']);
|
32 |
+
$csv = Mage::getModel('exporter/importorders')->readCSV($path . $_FILES['order_csv']['name'], $data);
|
33 |
+
} catch (Exception $e) {
|
34 |
+
Mage::getModel('core/session')->addError(Mage::helper('exporter')->__('Invalid file type!!'));
|
35 |
+
}
|
36 |
+
|
37 |
+
$this->_redirect('*/*/');
|
38 |
+
} else {
|
39 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('exporter')->__('Unable to find the import file'));
|
40 |
+
$this->_redirect('*/*/');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
|
|
|
package.xml
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Raveinfosys_OrderExporter</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Magento sales order import and export.</summary>
|
10 |
<description>Magento sales order import and export.</description>
|
11 |
-
<notes>This is stable version of this extension and has been tested on various version of community editions.
|
12 |
-
In this particular version we are supporting it to run on PHP V 5.5.X</notes>
|
13 |
<authors><author><name>Rave Infosys</name><user>raveinfo</user><email>magento@raveinfosys.com</email></author></authors>
|
14 |
-
<date>
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Exporter"><dir name="Block"><dir name="Adminhtml"><dir name="Exporter"><dir name="Edit"><file name="Form.php" hash="
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.2.0</min><max>5.6.
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Raveinfosys_OrderExporter</name>
|
4 |
+
<version>1.0.6</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Magento sales order import and export.</summary>
|
10 |
<description>Magento sales order import and export.</description>
|
11 |
+
<notes>This is stable version of this extension and has been tested on various version of community editions. In this particular version we are supporting it to run on PHP V 5.5.X.</notes>
|
|
|
12 |
<authors><author><name>Rave Infosys</name><user>raveinfo</user><email>magento@raveinfosys.com</email></author></authors>
|
13 |
+
<date>2016-04-06</date>
|
14 |
+
<time>14:52:49</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Exporter"><dir name="Block"><dir name="Adminhtml"><dir name="Exporter"><dir name="Edit"><file name="Form.php" hash="dbd790635eea6376ddd07cfe6fe9ed0d"/><dir name="Tab"><file name="Form.php" hash="7c5de68f66e90e516c227a75b24caa00"/></dir><file name="Tabs.php" hash="be0d7251cef6af8261f44937b57ee3b7"/></dir><file name="Edit.php" hash="5efb6c785cd3b7901a694248d1997674"/><file name="Grid.php" hash="342bba95b0511ea82ea04f9e7dd93632"/></dir><file name="Exporter.php" hash="2ada7ac4ecae33575d56b51a35ace5e7"/></dir><file name="Exporter.php" hash="92c76237657b54b0df2647273ed4f2d2"/><dir name="Sales"><dir name="Order"><dir name="Form"><file name="Form.php" hash="c13310c8740685a6bcf53c24c93ad547"/></dir><file name="Items.php" hash="77eb624408dad93ba8a1a65fcd9f1f49"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a1d6eff70cd6a3cc6e9488e9c230c649"/></dir><dir name="Model"><file name="Createorder.php" hash="b695f88a66d43569114ec77623bee7dd"/><file name="Exporter.php" hash="f760db7e60445d3fe402389609c50179"/><file name="Exportorders.php" hash="b4f84ffbbaafa6400699c9ef5d2c8b5f"/><file name="Importorders.php" hash="c3e73928fc6e3e210141ff3c30415aeb"/><dir name="Operations"><file name="Creditmemo.php" hash="b50def81463843f4d50f886fa215da19"/><file name="Invoice.php" hash="eb9c3baa50fde75a923916f2f5a0351f"/><file name="Shipment.php" hash="669fc49d4246f10f5dda91297c98c0eb"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExporterController.php" hash="402fc3b705e151adff4de8b81ac9d7a5"/><file name="ImporterController.php" hash="56b494d09af854a1c2074243160792ea"/></dir></dir><dir name="etc"><file name="config.xml" hash="73f299e777dda8c3a63d2028b8c94a05"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Raveinfosys_Exporter.xml" hash="af376451e72fdac6ac3d8999d2d78c6c"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="exporter.xml" hash="632c8fb654b60ff52d03641eb0589756"/></dir></dir></dir></dir></target><target name="mage"><dir name="var"><dir name="raveinfosys"><dir name="exporter"><file name="order_exception_log.htm" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>5.6.20</max></php></required></dependencies>
|
18 |
</package>
|