Neto_Magento_Orders_Sync - Version 1.0.0.1

Version Notes

1) This version syncs the sales orders across the two systems. Product sync will be added in the future versions.

Download this release

Release Info

Developer Arun
Extension Neto_Magento_Orders_Sync
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/community/Dzinehub/Netoinventory/Block/Product/Bestsellers_1.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Dynamic Bestseller Products.
4
+ @Version : 1.1.0
5
+ @package : Dzinehub_Bestseller
6
+ @class : app/code/community/Dzinehub/Bestseller/Block/Product/Bestsellers.php
7
+ @author : http://www.dzine-hub.com/
8
+ @support : http://www.dzine-hub.com/contact-us/
9
+ ***************************************************************************/
10
+
11
+ class Dzinehub_Netoinventory_Block_Product_Bestsellers extends Mage_Catalog_Block_Product_Abstract
12
+ {
13
+ function getBestsellerProduct()
14
+ {
15
+ $extensionenableflag = Mage::getStoreConfig('dzinehub_netoinventory/general/active',Mage::app()->getStore());
16
+ if($extensionenableflag==1)
17
+ {
18
+ $productCount = 50; // Cache
19
+ $storeId = Mage::app()->getStore()->getId();
20
+
21
+ /****** Get the list of best selling product ******/
22
+
23
+ $_productCollection = Mage::getResourceModel('reports/product_collection')
24
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
25
+ ->addAttributeToSelect('image')
26
+ ->addAttributeToSelect('name')
27
+ ->addAttributeToSelect('url')
28
+ ->addAttributeToSelect('price')
29
+ ->setPageSize($productCount)
30
+ ->addOrderedQty()
31
+ ->setOrder('ordered_qty', 'desc');
32
+
33
+ return $_productCollection;
34
+ }
35
+ }
36
+ }
app/code/community/Dzinehub/Netoinventory/Block/Product/Netoinventory.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Dynamic Bestseller Products.
4
+ @Version : 1.1.0
5
+ @package : Dzinehub_Bestseller
6
+ @class : app/code/community/Dzinehub/Bestseller/Block/Product/Bestsellers.php
7
+ @author : http://www.dzine-hub.com/
8
+ @support : http://www.dzine-hub.com/contact-us/
9
+ ***************************************************************************/
10
+
11
+ class Dzinehub_Netoinventory_Block_Product_Netoinventory extends Mage_Catalog_Block_Product_Abstract
12
+ {
13
+ }
app/code/community/Dzinehub/Netoinventory/Model/System/Config/Source/Enabledisable.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Dzinehub_Catalog_Model_System_Config_Source_Enabledisable
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ return array(
33
+ array('value'=>'enable', 'label'=>Mage::helper('adminhtml')->__('Enable')),
34
+ array('value'=>'disable', 'label'=>Mage::helper('adminhtml')->__('Disable')),
35
+ );
36
+ }
37
+ }
app/code/community/Dzinehub/Netoinventory/Model/System/Config/Source/Yesno.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for Yes|No config value selection
29
+ *
30
+ */
31
+ class Mage_Adminhtml_Model_System_Config_Source_Yesno
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ return array(
42
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
43
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
44
+ );
45
+ }
46
+
47
+ /**
48
+ * Get options in "key-value" format
49
+ *
50
+ * @return array
51
+ */
52
+ public function toArray()
53
+ {
54
+ return array(
55
+ 0 => Mage::helper('adminhtml')->__('No'),
56
+ 1 => Mage::helper('adminhtml')->__('Yes'),
57
+ );
58
+ }
59
+
60
+ }
app/code/community/Dzinehub/Netoinventory/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <dzinehub_netoinventory>
12
+ <title>Dzinehub_Netoinventory</title> <!-- Used in resources tree -->
13
+ </dzinehub_netoinventory>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Dzinehub/Netoinventory/etc/config.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dzinehub_Netoinventory>
5
+ <codePool>community</codePool>
6
+ <version>1.1.0</version>
7
+ </Dzinehub_Netoinventory>
8
+ </modules>
9
+ <global>
10
+ <blocks>
11
+ <netoinventory>
12
+ <!--<class>Dzinehub_Bestseller_Block</class>-->
13
+ <rewrite>
14
+ <product_netoinventory>Dzinehub_Netoinventory_Block_Product_Netoinventory</product_netoinventory>
15
+ </rewrite>
16
+ </netoinventory>
17
+ </blocks>
18
+ </global>
19
+ <frontend>
20
+ <layout>
21
+ <updates>
22
+ <Dzinehub_Netoinventory>
23
+ <file>netoinventory.xml</file>
24
+ </Dzinehub_Netoinventory>
25
+ </updates>
26
+ </layout>
27
+ </frontend>
28
+ </config>
app/code/community/Dzinehub/Netoinventory/etc/system.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <Dzine-Hub translate="label">
5
+ <!-- <label>Dzine-Hub</label>-->
6
+ <label><![CDATA[<div style="position: absolute;"><img id="dzinehub_extension" src="" alt="Dzine-Hub" border="0" /></div>&nbsp;<script>$('dzinehub_extension').src = SKIN_URL + "images/dzinehub/dzinehub.png";</script>]]></label>
7
+ <sort_order>150</sort_order>
8
+ </Dzine-Hub>
9
+ </tabs>
10
+ <sections>
11
+ <dzinehub_netoinventory translate="label" module="adminhtml">
12
+ <label>Neto Inventory</label>
13
+ <tab>Dzine-Hub</tab>
14
+ <sort_order>10</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <general translate="label comment">
20
+ <label>General</label>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <comment><![CDATA[<a href="http://www.dzine-hub.com/" target="_blank">Click here for support.</a>]]></comment>
26
+ <fields>
27
+ <active translate="label comment">
28
+ <label>Enable/Disable</label>
29
+ <frontend_type>select</frontend_type>
30
+ <sort_order>1</sort_order>
31
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </active>
36
+ <netokey translate="label comment">
37
+ <label>Neto Key</label>
38
+ <comment>login to neto admin and get Neto key. Admin->System Setup->API->Neto API key</comment>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>2</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </netokey>
45
+ </fields>
46
+ </general>
47
+ </groups>
48
+ </dzinehub_netoinventory>
49
+ </sections>
50
+ </config>
app/design/frontend/base/default/layout/netoinventory.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <dzinehub_index_netoinventory>
4
+ <reference name="content">
5
+ <blocks>
6
+ <netoinventory>
7
+ <class>Dzinehub_netoinventory_Block</class>
8
+ <rewrite>
9
+ <product_netoinventory>Dzinehub_Netoinventory_Block_Product_Netoinventory</product_netoinventory>
10
+ </rewrite>
11
+ </netoinventory>
12
+ </blocks>
13
+ <models>
14
+ <netoinventory>
15
+ <class>Dzinehub_netoinventory_Model</class>
16
+ </netoinventory>
17
+ </models>
18
+ </reference>
19
+ </dzinehub_index_netoinventory>
20
+ <checkout_onepage_success translate="label">
21
+
22
+ <reference name="content">
23
+ <block name="neto" template="dzinehub/netoinventory.phtml" type="netoinventory/product_netoinventory" />
24
+ </reference>
25
+
26
+ </checkout_onepage_success>
27
+ </layout>
app/design/frontend/base/default/template/dzinehub/neto.phtml ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //set_time_limit(0);
4
+ //ini_set('memory_limit','1024M');
5
+
6
+ //NETO API Receiver
7
+ $body = file_get_contents('php://input');
8
+ $xml = simplexml_load_string($body);
9
+ $adn = $xml->Order->OrderID;
10
+ $OrderStatus = $xml->Order->OrderStatus;
11
+ $extensionnetokey = Mage::getStoreConfig('dzinehub_netoinventory/general/netokey',Mage::app()->getStore());
12
+ //New order in Neto and decrement item qty in Magento
13
+ if($OrderStatus=="New")
14
+ {
15
+ $apiEndPoint="dz.neto.com.au/do/WS/NetoAPI";
16
+
17
+ $requestXml = '<?xml version="1.0" encoding="UTF-8"?>';
18
+ $requestXml .= '<GetOrder>';
19
+ $requestXml .= '<Filter>';
20
+ $requestXml .= '<OrderID>';
21
+ $requestXml .= $adn;
22
+ $requestXml .= '</OrderID>';
23
+ $requestXml .= '<OutputSelector>OrderLine</OutputSelector>';
24
+ $requestXml .= '<OutputSelector>ProductSubtotal</OutputSelector>';
25
+ $requestXml .= '</Filter>';
26
+ $requestXml .= '</GetOrder>';
27
+
28
+ $headers = array (
29
+ "NETOAPI_KEY: $extensionnetokey",
30
+ 'NETOAPI_ACTION:GetOrder',
31
+ //'NETOAPI_USERNAME:dzinehub',
32
+ //'Content-Type: text/xml;charset=utf-8'
33
+ 'Content-Type: text/xml'
34
+ );
35
+
36
+ $ch = curl_init($apiEndPoint);
37
+ curl_setopt($ch, CURLOPT_POST, true);
38
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
39
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
40
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
41
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
42
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
43
+ $responseXML = curl_exec($ch);
44
+ curl_close($ch);
45
+ $resp = simplexml_load_string($responseXML);
46
+
47
+ //Checking order placed is not from magento
48
+ if(($resp->Ack != 'Success') && ($resp->Order->SalesChannel!="API")) {
49
+ //echo "<br><br>Shop Name : Not Found<br><br>";
50
+ exit();
51
+ }
52
+ else
53
+ {
54
+ //echo "<br><br>Shop Name : Found<br><br>";
55
+ foreach($resp->Order as $order)
56
+ {
57
+ //echo "<br><br>NETO Order ID : ".$order->OrderID[0]."<br><br>";
58
+ //Getting SKU and Qty from Neto
59
+ $sku = $order->OrderLine->SKU[0];
60
+ $qty = $order->OrderLine->Quantity[0];
61
+
62
+ //Getting SKU and Qty from Magento
63
+ $_productcode = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
64
+
65
+ if($_productcode)
66
+ {
67
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_productcode);
68
+ if($stock->getQty()>$qty)
69
+ {
70
+ $qty=$stock->getQty()-$qty;
71
+
72
+ //Qty update in Magento
73
+ $id = Mage::getModel('catalog/product')->getIdBySku($sku);
74
+ $product = Mage::getModel('catalog/product')->load($id);
75
+ $product->setStockData(array(
76
+ 'manage_stock' => 1,
77
+ 'use_config_manage_stock' => 0,
78
+ 'is_in_stock' => 1,
79
+ 'qty' => $qty
80
+ ));
81
+ $product->save();
82
+ }
83
+ else
84
+ {
85
+ $netologtext = nl2br("\nThe order (".$sku.") is placed in Neto at ".date("r")." but not updated in Magento");
86
+ $folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1);
87
+ $filename = $folder."netolog.txt" ;
88
+ $fp = fopen($filename,"a") or die("Open error!");
89
+ fwrite($fp, $netologtext) or die("Write error!");
90
+ fclose($fp);
91
+ exit();
92
+ }
93
+ }
94
+ else
95
+ {
96
+ $netologtext = nl2br("\nThe order (".$sku.") is placed in Neto at ".date("r")." but not updated in Magento");
97
+ $folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1);
98
+ $filename = $folder."netolog.txt" ;
99
+ $fp = fopen($filename,"a") or die("Open error!");
100
+ fwrite($fp, $netologtext) or die("Write error!");
101
+ fclose($fp);
102
+ exit();
103
+ }
104
+ }
105
+ }
106
+ }
107
+ if($OrderStatus=="Cancelled")
108
+ {
109
+ $apiEndPoint="dz.neto.com.au/do/WS/NetoAPI";
110
+
111
+ $requestXml = '<?xml version="1.0" encoding="UTF-8"?>';
112
+ $requestXml .= '<GetOrder>';
113
+ $requestXml .= '<Filter>';
114
+ $requestXml .= '<OrderID>';
115
+ $requestXml .= $adn;
116
+ $requestXml .= '</OrderID>';
117
+ $requestXml .= '<OutputSelector>OrderLine</OutputSelector>';
118
+ $requestXml .= '<OutputSelector>ProductSubtotal</OutputSelector>';
119
+ $requestXml .= '</Filter>';
120
+ $requestXml .= '</GetOrder>';
121
+
122
+ $headers = array (
123
+ "NETOAPI_KEY: $extensionnetokey",
124
+ 'NETOAPI_ACTION:GetOrder',
125
+ //'NETOAPI_USERNAME:dzinehub',
126
+ 'Content-Type: text/xml'
127
+ );
128
+
129
+ $ch = curl_init($apiEndPoint);
130
+ curl_setopt($ch, CURLOPT_POST, true);
131
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
132
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
133
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
134
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
135
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
136
+ $responseXML = curl_exec($ch);
137
+ curl_close($ch);
138
+ $resp = simplexml_load_string($responseXML);
139
+
140
+ if(($resp->Ack != 'Success') && ($resp->Order->SalesChannel!="API")) {
141
+ //echo "<br><br>Shop Name : Not Found<br><br>";
142
+ exit();
143
+ }
144
+ else
145
+ {
146
+ //echo "<br><br>Shop Name : Found<br><br>";
147
+ foreach($resp->Order as $order)
148
+ {
149
+ //echo "<br><br>NETO Order ID : ".$order->OrderID[0]."<br><br>";
150
+ $sku = $order->OrderLine->SKU[0];
151
+ $qty = $order->OrderLine->Quantity[0];
152
+
153
+ $_productcode = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
154
+ if($_productcode)
155
+ {
156
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_productcode);
157
+ if($stock->getQty()>$qty)
158
+ {
159
+ $qty = $stock->getQty()+$qty;
160
+ $id = Mage::getModel('catalog/product')->getIdBySku($sku);
161
+ $product = Mage::getModel('catalog/product')->load($id);
162
+ $product->setStockData(array(
163
+ 'manage_stock' => 1,
164
+ 'use_config_manage_stock' => 0,
165
+ 'is_in_stock' => 1,
166
+ 'qty' => $qty
167
+ ));
168
+
169
+ $product->save();
170
+ }
171
+ else
172
+ {
173
+ $netologtext = nl2br("\nThe order (".$sku.") is cancelled in Neto at ".date("r")." but not updated in Magento");
174
+ $folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1);
175
+ $filename = $folder."netolog.txt" ;
176
+ $fp = fopen($filename,"a") or die("Open error!");
177
+ fwrite($fp, $netologtext) or die("Write error!");
178
+ fclose($fp);
179
+ exit();
180
+ }
181
+ }
182
+ else
183
+ {
184
+ $netologtext = nl2br("\nThe order (".$sku.") is cancelled in Neto at ".date("r")." but not updated in Magento");
185
+ $folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1);
186
+ $filename = $folder."netolog.txt" ;
187
+ $fp = fopen($filename,"a") or die("Open error!");
188
+ fwrite($fp, $netologtext) or die("Write error!");
189
+ fclose($fp);
190
+ exit();
191
+ }
192
+ }
193
+ }
194
+ }
195
+ ?>
app/design/frontend/base/default/template/dzinehub/netoinventory.phtml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Neto and Magento Inventory Mapping
4
+ @Version : 1.1.0
5
+ @package : Dzinehub_Bestseller
6
+ @class : app/code/community/Dzinehub/Bestseller/Block/Product/Bestsellers.php
7
+ @author : Arun
8
+ @email : arun@dzine-hub.com
9
+ @support : http://www.dzine-hub.com/contact-us/
10
+ ***************************************************************************/
11
+ ?>
12
+ <?php
13
+
14
+ $extensionenableflag = 0;
15
+ $extensionenableflag = Mage::getStoreConfig('dzinehub_netoinventory/general/active',Mage::app()->getStore());
16
+ if($extensionenableflag == 1 )
17
+ {
18
+ $getorderid=Mage::getSingleton('checkout/session')->getLastOrderId();
19
+ if ($getorderid)
20
+ {
21
+ $extensionnetokey = Mage::getStoreConfig('dzinehub_netoinventory/general/netokey',Mage::app()->getStore());
22
+ $order = Mage::getModel("sales/order")->load($getorderid);
23
+ $magentoorderid=$order->getIncrementId();
24
+ $addbilling = $order->getBillingAddress()->getStreet();
25
+ $addshipping=$order->getShippingAddress()->getStreet();
26
+ $apiEndPoint="dz.neto.com.au/do/WS/NetoAPI";
27
+
28
+ $requestXml = '<?xml version="1.0" encoding="UTF-8"?>';
29
+ $requestXml .= '<AddOrder>';
30
+ $requestXml .= '<Order>';
31
+ $requestXml .= '<Username>sample</Username>';
32
+ $requestXml .= '<BillFirstName>'.$order->getBillingAddress()->getFirstname().'</BillFirstName>';
33
+ $requestXml .= '<BillLastName>'.$order->getBillingAddress()->getLastname().'</BillLastName>';
34
+ $requestXml .= '<BillStreet1>'.$addbilling[0].', '.$addbilling[1].'</BillStreet1>';
35
+ $requestXml .= '<BillCity>'.$order->getBillingAddress()->getCity().'</BillCity>';
36
+ $requestXml .= '<BillState>'.$order->getBillingAddress()->getRegion().'</BillState>';
37
+ $requestXml .= '<BillPostCode>'.$order->getBillingAddress()->getPostcode().'</BillPostCode>';
38
+ $requestXml .= '<BillCountry>'.$order->getBillingAddress()->getCountry().'</BillCountry>';
39
+ $requestXml .= '<ShipFirstName>'.$order->getShippingAddress()->getFirstname().'</ShipFirstName>';
40
+ $requestXml .= '<ShipLastName>'.$order->getShippingAddress()->getFirstname().'</ShipLastName>';
41
+ $requestXml .= '<ShipStreet1>'.$addshipping[0].', '.$addshipping[1].'</ShipStreet1>';
42
+ $requestXml .= '<ShipCity>'.$order->getShippingAddress()->getCity().'</ShipCity>';
43
+ $requestXml .= '<ShipState>'.$order->getShippingAddress()->getRegion().'</ShipState>';
44
+ $requestXml .= '<ShipPostCode>'.$order->getShippingAddress()->getPostcode().'</ShipPostCode>';
45
+ $requestXml .= '<ShipCountry>'.$order->getShippingAddress()->getCountry().'</ShipCountry>';
46
+ $requestXml .= '<ShipContactPhone>'.$order->getShippingAddress()->getTelephone().'</ShipContactPhone>';
47
+ $requestXml .= '<CustomerRef1>'.$order->getIncrementId().'</CustomerRef1>';
48
+
49
+ foreach($order->getItemsCollection() as $sItem)
50
+ {
51
+ $requestXml .= '<OrderLine>';
52
+ $requestXml .= '<SKU>'.$sItem->getSku().'</SKU>';
53
+ $requestXml .= '<Quantity>'.intval($sItem->getQtyOrdered()).'</Quantity>';
54
+ $requestXml .= '</OrderLine>';
55
+ }
56
+
57
+ $requestXml .= '</Order>';
58
+ $requestXml .= '</AddOrder>';
59
+
60
+ $headers = array (
61
+ "NETOAPI_KEY: $extensionnetokey",
62
+ 'NETOAPI_ACTION: AddOrder',
63
+ //'NETOAPI_USERNAME: dzinehub',
64
+ 'Content-Type: text/xml'
65
+ );
66
+
67
+ $ch = curl_init($apiEndPoint);
68
+ curl_setopt($ch, CURLOPT_POST, true);
69
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
70
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
71
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
72
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
73
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
74
+ $responseXML = curl_exec($ch);
75
+ curl_close($ch);
76
+
77
+ $resp = simplexml_load_string($responseXML);
78
+
79
+ if($resp->Ack != 'Success')
80
+ {
81
+ //echo "<br><br>Shop Name : Not Found<br><br>";
82
+ $netologtext = "";
83
+ $netologtext = nl2br("\nThe order (".$magentoorderid.") is placed in Magento at ".date("r")." but not created in Neto");
84
+ $folder = substr($_SERVER['SCRIPT_FILENAME'],0,strrpos($_SERVER['SCRIPT_FILENAME'],"/")+1);
85
+ $filename = $folder."netolog.txt" ;
86
+ $fp = fopen($filename,"a") or die("Open error!");
87
+ fwrite($fp, $netologtext) or die("Write error!");
88
+ fclose($fp);
89
+ }
90
+ else
91
+ {
92
+ foreach($resp->Order as $order)
93
+ {
94
+ echo "<br><br>NETO Order ID : ".$order->OrderID[0]."<br><br>";
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ?>
app/etc/modules/Dzinehub_Netoinventory.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dzinehub_Netoinventory>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Dzinehub_Netoinventory>
8
+ </modules>
9
+ </config>
netolog.txt ADDED
File without changes
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Neto_Magento_Orders_Sync</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Enabling all magento merchants to use neto as their multi-channel software, yet continue using the magento as their choice of ecommerce frontend. Use neto as your ecommerce backend, and magento to power your website frontend, and automatically synchronize the sales orders across both the systems.</summary>
10
+ <description>The world's first neto to magento connect!&#xD;
11
+ &#xD;
12
+ Those merchants who wish to continue using magento as their ecommerce frontend software, but prefer using neto for their multi-channel business needs, can now sync across the two systems!&#xD;
13
+ &#xD;
14
+ The sales orders will continue to be processed at neto. Every time a sale happens at magento's end, the quantities are adjusted in neto using neto's API calls. And every time a sale happens in neto, the product quantities are adjusted in magento using neto's push notification system. &#xD;
15
+ &#xD;
16
+ Single products and multi-variations are seamlessly handled during the orders sync process.&#xD;
17
+ &#xD;
18
+ Manage your product shipment and fulfillment entirely from neto! You never have to login to magento admin for order processing!&#xD;
19
+ &#xD;
20
+ Note: This extension requires you to set all products up in neto and magento manually, and ensure the same SKU is used across both the platforms for the similar products. The product SKU is used to identify the products.</description>
21
+ <notes>1) This version syncs the sales orders across the two systems. Product sync will be added in the future versions.</notes>
22
+ <authors><author><name>Arun</name><user>arun</user><email>arun@dzine-hub.com</email></author></authors>
23
+ <date>2015-04-24</date>
24
+ <time>10:24:50</time>
25
+ <contents><target name="magecommunity"><dir name="Dzinehub"><dir name="Netoinventory"><dir name="Block"><dir name="Product"><file name="Bestsellers_1.php" hash="cae07bbe4df5ba93e89569a33c150253"/><file name="Netoinventory.php" hash="26fa4f90d7c71a4416252a676ebe0fbc"/></dir></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Enabledisable.php" hash="cc907542cfe11f4d5aa4fb537c3584e9"/><file name="Yesno.php" hash="b506c229f70bf2101f244e8191f9a3bd"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3f661dac80d0437334c2849bcf9dd9fe"/><file name="config.xml" hash="3c06b621d08060c8fc92667ddd4fe18a"/><file name="system.xml" hash="11608ef2bb3189f3f33d16ca57bc662a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dzinehub_Netoinventory.xml" hash="c1146415c6c59cb334285015c8c32d88"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="dzinehub"><file name="neto.phtml" hash="f97ea5b73ca7c6323190359faf68372f"/><file name="netoinventory.phtml" hash="a39c87da6390a06ad418799316a06d21"/></dir></dir><dir name="layout"><file name="netoinventory.xml" hash="e9cb6308442e271575b70d97a17c76f0"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="dzinehub"><file name="dzinehub.png" hash="1938212479ffe381cc68af0299d7d832"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="."><file name="netolog.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
28
+ </package>
skin/adminhtml/default/default/images/dzinehub/dzinehub.png ADDED
Binary file