FarApp_Connector - Version 1.2.1

Version Notes

Fixed behavior of Magento imports where in "replace" mode it deletes related products when related product data isn't part of import.

Download this release

Release Info

Developer FarApp
Extension FarApp_Connector
Version 1.2.1
Comparing to
See all releases


Code changes from version 1.2.0 to 1.2.1

app/code/community/FarApp/Connector/Model/Import/Entity/.Product.php.swp ADDED
Binary file
app/code/community/FarApp/Connector/Model/Import/Entity/Product.php CHANGED
@@ -101,6 +101,102 @@ class FarApp_Connector_Model_Import_Entity_Product extends Mage_ImportExport_Mod
101
  }
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  protected function _saveStockItem()
105
  {
106
  $defaultStockData = array(
101
  }
102
  }
103
 
104
+ protected function _saveLinks()
105
+ {
106
+ $resource = Mage::getResourceModel('catalog/product_link');
107
+ $mainTable = $resource->getMainTable();
108
+ $positionAttrId = array();
109
+ /** @var Varien_Db_Adapter_Interface $adapter */
110
+ $adapter = $this->_connection;
111
+
112
+ // pre-load 'position' attributes ID for each link type once
113
+ foreach ($this->_linkNameToId as $linkName => $linkId) {
114
+ $select = $adapter->select()
115
+ ->from(
116
+ $resource->getTable('catalog/product_link_attribute'),
117
+ array('id' => 'product_link_attribute_id')
118
+ )
119
+ ->where('link_type_id = :link_id AND product_link_attribute_code = :position');
120
+ $bind = array(
121
+ ':link_id' => $linkId,
122
+ ':position' => 'position'
123
+ );
124
+ $positionAttrId[$linkId] = $adapter->fetchOne($select, $bind);
125
+ }
126
+ $nextLinkId = Mage::getResourceHelper('importexport')->getNextAutoincrement($mainTable);
127
+ while ($bunch = $this->_dataSourceModel->getNextBunch()) {
128
+ $productIds = array();
129
+ $linkRows = array();
130
+ $positionRows = array();
131
+
132
+ foreach ($bunch as $rowNum => $rowData) {
133
+ $this->_filterRowData($rowData);
134
+ if (!$this->isRowAllowedToImport($rowData, $rowNum)) {
135
+ continue;
136
+ }
137
+ if (self::SCOPE_DEFAULT == $this->getRowScope($rowData)) {
138
+ $sku = $rowData[self::COL_SKU];
139
+ }
140
+ foreach ($this->_linkNameToId as $linkName => $linkId) {
141
+ $productId = $this->_newSku[$sku]['entity_id'];
142
+ $productIds[] = $productId;
143
+ if (isset($rowData[$linkName . 'sku'])) {
144
+ $linkedSku = $rowData[$linkName . 'sku'];
145
+
146
+ if ((isset($this->_newSku[$linkedSku]) || isset($this->_oldSku[$linkedSku]))
147
+ && $linkedSku != $sku) {
148
+ if (isset($this->_newSku[$linkedSku])) {
149
+ $linkedId = $this->_newSku[$linkedSku]['entity_id'];
150
+ } else {
151
+ $linkedId = $this->_oldSku[$linkedSku]['entity_id'];
152
+ }
153
+ $linkKey = "{$productId}-{$linkedId}-{$linkId}";
154
+
155
+ if (!isset($linkRows[$linkKey])) {
156
+ $linkRows[$linkKey] = array(
157
+ 'link_id' => $nextLinkId,
158
+ 'product_id' => $productId,
159
+ 'linked_product_id' => $linkedId,
160
+ 'link_type_id' => $linkId
161
+ );
162
+ if (!empty($rowData[$linkName . 'position'])) {
163
+ $positionRows[] = array(
164
+ 'link_id' => $nextLinkId,
165
+ 'product_link_attribute_id' => $positionAttrId[$linkId],
166
+ 'value' => $rowData[$linkName . 'position']
167
+ );
168
+ }
169
+ $nextLinkId++;
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+ if ($linkRows) {
176
+ if (Mage_ImportExport_Model_Import::BEHAVIOR_APPEND != $this->getBehavior() && $productIds) {
177
+ $adapter->delete(
178
+ $mainTable,
179
+ $adapter->quoteInto('product_id IN (?)', array_unique($productIds))
180
+ );
181
+ }
182
+ $adapter->insertOnDuplicate(
183
+ $mainTable,
184
+ $linkRows,
185
+ array('link_id')
186
+ );
187
+ $adapter->changeTableAutoIncrement($mainTable, $nextLinkId);
188
+ }
189
+ if ($positionRows) { // process linked product positions
190
+ $adapter->insertOnDuplicate(
191
+ $resource->getAttributeTypeTable('int'),
192
+ $positionRows,
193
+ array('value')
194
+ );
195
+ }
196
+ }
197
+ return $this;
198
+ }
199
+
200
  protected function _saveStockItem()
201
  {
202
  $defaultStockData = array(
app/code/community/FarApp/Connector/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <FarApp_Connector>
12
- <version>1.2.0</version>
13
  </FarApp_Connector>
14
  </modules>
15
  <global>
9
  <config>
10
  <modules>
11
  <FarApp_Connector>
12
+ <version>1.2.1</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.0</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>Remove dependencies</notes>
12
  <authors><author><name>FarApp</name><user>FarApp</user><email>support@farapp.com</email></author></authors>
13
- <date>2015-06-27</date>
14
- <time>18:28:16</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="4d99fbda283b0b96be7db7574ee715fe"/><file name="minVersion2.php" hash="8df670fd68516ba1629304ae8ab6c812"/></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="0a04d6d37a8de6f110c1488e1e78b316"/><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.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>