FarApp_Connector - Version 1.2.2

Version Notes

Improved reliability of remote image loads.

Download this release

Release Info

Developer FarApp
Extension FarApp_Connector
Version 1.2.2
Comparing to
See all releases


Code changes from version 1.2.1 to 1.2.2

app/code/community/FarApp/Connector/Model/Import/Entity/.Order.php.swp ADDED
Binary file
app/code/community/FarApp/Connector/Model/Import/Entity/.Product.php.swp DELETED
Binary file
app/code/community/FarApp/Connector/Model/Import/Entity/Product.php CHANGED
@@ -76,7 +76,7 @@ class FarApp_Connector_Model_Import_Entity_Product extends Mage_ImportExport_Mod
76
  $destPath = $this->_getUploader()->correctFileNameCase(Mage_Core_Model_File_Uploader::getDispretionPath(basename($fileName)) . DS . $correctedBaseName);
77
  $fullDestPath = $this->_getUploader()->getDestDir() . DS . $destPath;
78
  if (!is_file($fullDestPath)) {
79
- if (!is_file($fullTempPath) && strpos($fileName, 'http') === 0 && strpos($fileName, '://') !== false) {
80
  try {
81
  $dir = $this->_getUploader()->getTmpDir();
82
  if (!is_dir($dir)) {
@@ -91,6 +91,7 @@ class FarApp_Connector_Model_Import_Entity_Product extends Mage_ImportExport_Mod
91
  curl_close($ch);
92
  fclose($fileHandle);
93
  } catch (Exception $e) {
 
94
  return '';
95
  }
96
  }
76
  $destPath = $this->_getUploader()->correctFileNameCase(Mage_Core_Model_File_Uploader::getDispretionPath(basename($fileName)) . DS . $correctedBaseName);
77
  $fullDestPath = $this->_getUploader()->getDestDir() . DS . $destPath;
78
  if (!is_file($fullDestPath)) {
79
+ if ((!is_file($fullTempPath) || !getimagesize($fullTempPath)) && strpos($fileName, 'http') === 0 && strpos($fileName, '://') !== false) {
80
  try {
81
  $dir = $this->_getUploader()->getTmpDir();
82
  if (!is_dir($dir)) {
91
  curl_close($ch);
92
  fclose($fileHandle);
93
  } catch (Exception $e) {
94
+ var_dump($e);
95
  return '';
96
  }
97
  }
app/code/community/FarApp/Connector/controllers/ExportController.php CHANGED
@@ -41,134 +41,135 @@ class FarApp_Connector_ExportController extends Mage_Core_Controller_Front_Actio
41
  echo $this->__('You don\'t have permission to export data.');
42
  return;
43
  }
44
-
45
- //error_reporting(E_ALL);
46
- //ini_set('display_errors', '1');
47
- $model = Mage::getModel('farapp_connector/export');
48
- $result = $model
49
- ->setIncludePayment(true)
50
- ->setIncludeShipment(true)
51
- ->setIncludeAddresses(true)
52
- ->setIncludeItems(true)
53
- ->processOrderExport();
54
- //var_dump($result);
55
- $resultStr = '';
56
- $csv = array();
57
- $baseFields = array();
58
- $shippingAddrFields = array();
59
- $billingAddrFields = array();
60
- $itemFields = array();
61
- $paymentFields = array();
62
- $shipmentFields = array();
63
- foreach ($result as $row) {
64
- if (!array_key_exists('shipping_address', $row) ||
65
- !array_key_exists('billing_address', $row) ||
66
- !array_key_exists('items', $row) ||
67
- !array_key_exists('payment', $row) ||
68
- !array_key_exists('shipments', $row)) {
69
- continue;
70
- }
71
- $csvrow = array();
72
- foreach ($row as $key => $val) {
73
- if ($key == 'shipping_address' || $key == 'billing_address' || $key == 'items' || $key == 'payment' || $key == 'shipments') {
74
  continue;
75
  }
76
- $csvrow[] = '"' . $key . '"';
77
- $baseFields[] = $key;
78
- }
79
- foreach ($row['shipping_address'] as $key => $val) {
80
- $csvrow[] = '"_shipping_address_' . $key . '"';
81
- $shippingAddrFields[] = $key;
82
- }
83
- foreach ($row['billing_address'] as $key => $val) {
84
- $csvrow[] = '"_billing_address_' . $key . '"';
85
- $billingAddrFields[] = $key;
86
- }
87
- if (isset($row['items'])) {
88
- $item = $row['items'][0];
89
- foreach ($item as $key => $val) {
90
- $csvrow[] = '"_item_' . $key . '"';
91
- $itemFields[] = $key;
92
  }
93
- }
94
- foreach ($row['payment'] as $key => $val) {
95
- $csvrow[] = '"_payment_' . $key . '"';
96
- $paymentFields[] = $key;
97
- }
98
- if (isset($row['shipments'])) {
99
- $shipment = $row['shipments'][0];
100
- foreach ($shipment as $key => $val) {
101
- $csvrow[] = '"_shipment_' . $key . '"';
102
- $shipmentFields[] = $key;
103
  }
104
- }
105
- $csv[] = $csvrow;
106
- break;
107
- }
108
- foreach ($result as $row) {
109
- $csvrow = array();
110
- foreach ($baseFields as $key) {
111
- $csvrow[] = '"' . $row[$key] . '"';
112
- }
113
- foreach ($shippingAddrFields as $key) {
114
- $csvrow[] = '"' . $row['shipping_address'][$key] . '"';
115
- }
116
- foreach ($billingAddrFields as $key) {
117
- $csvrow[] = '"' . $row['billing_address'][$key] . '"';
118
- }
119
- if (isset($row['items'])) {
120
- $item = $row['items'][0];
121
- foreach ($itemFields as $key) {
122
- $csvrow[] = '"' . str_replace('"', '""', $item[$key]) . '"';
123
  }
124
- }
125
- foreach ($paymentFields as $key) {
126
- $csvrow[] = '"' . $paymentFields[$key] . '"';
127
- }
128
- if (isset($row['shipments'])) {
129
- $shipment = $row['shipments'][0];
130
- foreach ($shipmentFields as $key) {
131
- $csvrow[] = '"' . $shipment[$key] . '"';
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
134
- $csv[] = $csvrow;
135
- for ($i = 1; $i < max(count($row['items']), count($row['shipments'])); $i++) {
136
  $csvrow = array();
137
- for ($j = 0; $j < count($baseFields)+count($shippingAddrFields)+count($billingAddrFields); $j++) {
138
- $csvrow[] = '""';
 
 
 
139
  }
140
- if ($i < count($row['items'])) {
141
- $item = $row['items'][$i];
 
 
 
142
  foreach ($itemFields as $key) {
143
  $csvrow[] = '"' . str_replace('"', '""', $item[$key]) . '"';
144
  }
145
  }
146
- else {
147
- for ($j = 0; $j < count($itemFields); $j++) {
148
- $csvrow[] = '""';
149
- }
150
- }
151
- for ($j = 0; $j < count($paymentFields); $j++) {
152
- $csvrow[] = '""';
153
  }
154
- if ($i < count($row['shipments'])) {
155
- $shipment = $row['shipments'][$i];
156
  foreach ($shipmentFields as $key) {
157
  $csvrow[] = '"' . $shipment[$key] . '"';
158
  }
159
  }
160
- else {
161
- for ($j = 0; $j < count($shipmentFields); $j++) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  $csvrow[] = '""';
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
165
- $csv[] = $csvrow;
166
  }
 
 
 
 
167
  }
168
- foreach ($csv as $idx => $csvrow) {
169
- echo implode(',', $csvrow) . "\n";
170
- }
171
- return;
172
 
173
  try {
174
  /** @var $model Mage_ImportExport_Model_Export */
@@ -181,11 +182,14 @@ class FarApp_Connector_ExportController extends Mage_Core_Controller_Front_Actio
181
  $model->getContentType()
182
  );
183
  } catch (Mage_Core_Exception $e) {
 
184
  $this->_getSession()->addError($e->getMessage());
185
  } catch (Exception $e) {
 
186
  Mage::logException($e);
187
  $this->_getSession()->addError($this->__('No valid data sent'));
188
  }
 
189
 
190
  if ($data) {
191
  /** @var $exportModel Mage_ImportExport_Model_Export */
41
  echo $this->__('You don\'t have permission to export data.');
42
  return;
43
  }
44
+ if ($data['entity'] == 'order') {
45
+ //error_reporting(E_ALL);
46
+ //ini_set('display_errors', '1');
47
+ $model = Mage::getModel('farapp_connector/export');
48
+ $result = $model
49
+ ->setIncludePayment(true)
50
+ ->setIncludeShipment(true)
51
+ ->setIncludeAddresses(true)
52
+ ->setIncludeItems(true)
53
+ ->processOrderExport();
54
+ //var_dump($result);
55
+ $resultStr = '';
56
+ $csv = array();
57
+ $baseFields = array();
58
+ $shippingAddrFields = array();
59
+ $billingAddrFields = array();
60
+ $itemFields = array();
61
+ $paymentFields = array();
62
+ $shipmentFields = array();
63
+ foreach ($result as $row) {
64
+ if (!array_key_exists('shipping_address', $row) ||
65
+ !array_key_exists('billing_address', $row) ||
66
+ !array_key_exists('items', $row) ||
67
+ !array_key_exists('payment', $row) ||
68
+ !array_key_exists('shipments', $row)) {
 
 
 
 
 
69
  continue;
70
  }
71
+ $csvrow = array();
72
+ foreach ($row as $key => $val) {
73
+ if ($key == 'shipping_address' || $key == 'billing_address' || $key == 'items' || $key == 'payment' || $key == 'shipments') {
74
+ continue;
75
+ }
76
+ $csvrow[] = '"' . $key . '"';
77
+ $baseFields[] = $key;
 
 
 
 
 
 
 
 
 
78
  }
79
+ foreach ($row['shipping_address'] as $key => $val) {
80
+ $csvrow[] = '"_shipping_address_' . $key . '"';
81
+ $shippingAddrFields[] = $key;
 
 
 
 
 
 
 
82
  }
83
+ foreach ($row['billing_address'] as $key => $val) {
84
+ $csvrow[] = '"_billing_address_' . $key . '"';
85
+ $billingAddrFields[] = $key;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
+ if (isset($row['items'])) {
88
+ $item = $row['items'][0];
89
+ foreach ($item as $key => $val) {
90
+ $csvrow[] = '"_item_' . $key . '"';
91
+ $itemFields[] = $key;
92
+ }
 
 
93
  }
94
+ foreach ($row['payment'] as $key => $val) {
95
+ $csvrow[] = '"_payment_' . $key . '"';
96
+ $paymentFields[] = $key;
97
+ }
98
+ if (isset($row['shipments'])) {
99
+ $shipment = $row['shipments'][0];
100
+ foreach ($shipment as $key => $val) {
101
+ $csvrow[] = '"_shipment_' . $key . '"';
102
+ $shipmentFields[] = $key;
103
+ }
104
+ }
105
+ $csv[] = $csvrow;
106
+ break;
107
  }
108
+ foreach ($result as $row) {
 
109
  $csvrow = array();
110
+ foreach ($baseFields as $key) {
111
+ $csvrow[] = '"' . $row[$key] . '"';
112
+ }
113
+ foreach ($shippingAddrFields as $key) {
114
+ $csvrow[] = '"' . $row['shipping_address'][$key] . '"';
115
  }
116
+ foreach ($billingAddrFields as $key) {
117
+ $csvrow[] = '"' . $row['billing_address'][$key] . '"';
118
+ }
119
+ if (isset($row['items'])) {
120
+ $item = $row['items'][0];
121
  foreach ($itemFields as $key) {
122
  $csvrow[] = '"' . str_replace('"', '""', $item[$key]) . '"';
123
  }
124
  }
125
+ foreach ($paymentFields as $key) {
126
+ $csvrow[] = '"' . $paymentFields[$key] . '"';
 
 
 
 
 
127
  }
128
+ if (isset($row['shipments'])) {
129
+ $shipment = $row['shipments'][0];
130
  foreach ($shipmentFields as $key) {
131
  $csvrow[] = '"' . $shipment[$key] . '"';
132
  }
133
  }
134
+ $csv[] = $csvrow;
135
+ for ($i = 1; $i < max(count($row['items']), count($row['shipments'])); $i++) {
136
+ $csvrow = array();
137
+ for ($j = 0; $j < count($baseFields)+count($shippingAddrFields)+count($billingAddrFields); $j++) {
138
+ $csvrow[] = '""';
139
+ }
140
+ if ($i < count($row['items'])) {
141
+ $item = $row['items'][$i];
142
+ foreach ($itemFields as $key) {
143
+ $csvrow[] = '"' . str_replace('"', '""', $item[$key]) . '"';
144
+ }
145
+ }
146
+ else {
147
+ for ($j = 0; $j < count($itemFields); $j++) {
148
+ $csvrow[] = '""';
149
+ }
150
+ }
151
+ for ($j = 0; $j < count($paymentFields); $j++) {
152
  $csvrow[] = '""';
153
  }
154
+ if ($i < count($row['shipments'])) {
155
+ $shipment = $row['shipments'][$i];
156
+ foreach ($shipmentFields as $key) {
157
+ $csvrow[] = '"' . $shipment[$key] . '"';
158
+ }
159
+ }
160
+ else {
161
+ for ($j = 0; $j < count($shipmentFields); $j++) {
162
+ $csvrow[] = '""';
163
+ }
164
+ }
165
+ $csv[] = $csvrow;
166
  }
 
167
  }
168
+ foreach ($csv as $idx => $csvrow) {
169
+ echo implode(',', $csvrow) . "\n";
170
+ }
171
+ return;
172
  }
 
 
 
 
173
 
174
  try {
175
  /** @var $model Mage_ImportExport_Model_Export */
182
  $model->getContentType()
183
  );
184
  } catch (Mage_Core_Exception $e) {
185
+ echo $e->getMessage();
186
  $this->_getSession()->addError($e->getMessage());
187
  } catch (Exception $e) {
188
+ echo $this->__('No valid data sent');
189
  Mage::logException($e);
190
  $this->_getSession()->addError($this->__('No valid data sent'));
191
  }
192
+ return;
193
 
194
  if ($data) {
195
  /** @var $exportModel Mage_ImportExport_Model_Export */
app/code/community/FarApp/Connector/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <FarApp_Connector>
12
- <version>1.2.1</version>
13
  </FarApp_Connector>
14
  </modules>
15
  <global>
9
  <config>
10
  <modules>
11
  <FarApp_Connector>
12
+ <version>1.2.2</version>
13
  </FarApp_Connector>
14
  </modules>
15
  <global>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FarApp_Connector</name>
4
- <version>1.2.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.farapp.com/p/farapp-subscription-form">Commercial</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connector to sync product data from FarApp to Magento. FarApp currently supports NetSuite and other backends.</summary>
10
  <description>FarApp is a cloud-based solution for posting product data to storefronts, retrieving orders from storefront and posting fulfillments to storefronts. We support various backends including NetSuite, X-Cart, 3D-Cart, and more. This connector allows full product data posting to Magento from FarApp. It has the the extra benefits of allowing FarApp to dynamically push new product data, automatically creating new attribute options and importing external images (features not provided by Magento).</description>
11
- <notes>Fixed behavior of Magento imports where in "replace" mode it deletes related products when related product data isn't part of import.</notes>
12
  <authors><author><name>FarApp</name><user>FarApp</user><email>support@farapp.com</email></author></authors>
13
- <date>2015-07-11</date>
14
- <time>23:29:54</time>
15
- <contents><target name="magecommunity"><dir name="FarApp"><dir name="Connector"><dir name="Model"><dir name="Export"><dir name="Adapter"><file name="Abstract.php" hash="765dc8fbab996f17b9f049cc8aa906a0"/><file name="Array.php" hash="6ca62c702dcb9512ec429563ac1ce1a2"/></dir><dir name="Entity"><file name="Order.php" hash="14a2f735cf8fc5e8f2bcd6682a1e56b1"/></dir></dir><file name="Export.php" hash="01643ef101731c6d98bbc523642f95a0"/><dir name="Import"><dir name="Entity"><file name="Customer.php" hash="376978f635c73605d428037cca8cf594"/><file name="Order.php" hash="38579396825a1bd3ad59de84278085f6"/><file name="Product.php" hash="59cee513eb66bf248e17688e6c85bd6e"/><file name="minVersion2.php" hash="8df670fd68516ba1629304ae8ab6c812"/><file name=".Product.php.swp" hash="547eb0194bd185b12fe1ed3e7df27168"/></dir></dir><file name="Import.php" hash="5f226d5505bf8e258a4e61f43b09b25a"/><dir name="Order"><dir name="Invoice"><file name="Api.php" hash="f133255dae51ab9c44c71ca9cc702d0a"/></dir></dir></dir><dir name="controllers"><file name="ExportController.php" hash="c994585c4535fc8b402160960092be95"/><file name="ImportController.php" hash="ec66abaf46073b9491889a199d665992"/><file name="IndexController.php" hash="93918848d3ce7f6ad05688f89a730e75"/></dir><dir name="etc"><file name="api.xml" hash="25b50336e5bfbd139eeb81bbf321dd78"/><file name="config.xml" hash="7c76d69019cee378e86032d27efde0c3"/><file name="wsdl.xml" hash="831bf87f9939132a9d9be6327d1b6a8e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FarApp_Connector.xml" hash="ff3fe315c70239229cb5ff3a49d40967"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>5.7.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FarApp_Connector</name>
4
+ <version>1.2.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.farapp.com/p/farapp-subscription-form">Commercial</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connector to sync product data from FarApp to Magento. FarApp currently supports NetSuite and other backends.</summary>
10
  <description>FarApp is a cloud-based solution for posting product data to storefronts, retrieving orders from storefront and posting fulfillments to storefronts. We support various backends including NetSuite, X-Cart, 3D-Cart, and more. This connector allows full product data posting to Magento from FarApp. It has the the extra benefits of allowing FarApp to dynamically push new product data, automatically creating new attribute options and importing external images (features not provided by Magento).</description>
11
+ <notes>Improved reliability of remote image loads.</notes>
12
  <authors><author><name>FarApp</name><user>FarApp</user><email>support@farapp.com</email></author></authors>
13
+ <date>2015-08-14</date>
14
+ <time>22:08:23</time>
15
+ <contents><target name="magecommunity"><dir name="FarApp"><dir name="Connector"><dir name="Model"><dir name="Export"><dir name="Adapter"><file name="Abstract.php" hash="765dc8fbab996f17b9f049cc8aa906a0"/><file name="Array.php" hash="6ca62c702dcb9512ec429563ac1ce1a2"/></dir><dir name="Entity"><file name="Order.php" hash="14a2f735cf8fc5e8f2bcd6682a1e56b1"/></dir></dir><file name="Export.php" hash="01643ef101731c6d98bbc523642f95a0"/><dir name="Import"><dir name="Entity"><file name="Customer.php" hash="376978f635c73605d428037cca8cf594"/><file name="Order.php" hash="38579396825a1bd3ad59de84278085f6"/><file name="Product.php" hash="e986a04628a28ab910a7110ca24f73af"/><file name="minVersion2.php" hash="8df670fd68516ba1629304ae8ab6c812"/><file name=".Order.php.swp" hash="8246d30fb145c3d38a1ce2fc077104b0"/></dir></dir><file name="Import.php" hash="5f226d5505bf8e258a4e61f43b09b25a"/><dir name="Order"><dir name="Invoice"><file name="Api.php" hash="f133255dae51ab9c44c71ca9cc702d0a"/></dir></dir></dir><dir name="controllers"><file name="ExportController.php" hash="c51395789ff9eed363f20d5ab08ff528"/><file name="ImportController.php" hash="ec66abaf46073b9491889a199d665992"/><file name="IndexController.php" hash="93918848d3ce7f6ad05688f89a730e75"/></dir><dir name="etc"><file name="api.xml" hash="25b50336e5bfbd139eeb81bbf321dd78"/><file name="config.xml" hash="897835fb13b6a1fd9b02f1aebe80fb4f"/><file name="wsdl.xml" hash="831bf87f9939132a9d9be6327d1b6a8e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="FarApp_Connector.xml" hash="ff3fe315c70239229cb5ff3a49d40967"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.0.0</min><max>5.7.0</max></php></required></dependencies>
18
  </package>