LinnLiveConnect - Version 1.1.63

Version Notes

Fixed an issue with new attribute options

Download this release

Release Info

Developer Albert Andrejev
Extension LinnLiveConnect
Version 1.1.63
Comparing to
See all releases


Code changes from version 1.1.62 to 1.1.63

app/code/local/LinnSystems/LinnLiveConnect/Helper/Data.php CHANGED
@@ -169,70 +169,66 @@ class LinnSystems_LinnLiveConnect_Helper_Data extends Mage_Core_Helper_Abstract
169
 
170
  public function createOptions($newOptions)
171
  {
 
172
  $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
173
  $attributeApi = Mage::getModel('catalog/product_attribute_api');
174
  $helperCatalog = Mage::helper('catalog');
175
 
176
  $installer->startSetup();
177
-
178
  $attributesList = array();
179
 
180
  foreach($newOptions as $attribute_id=>$options)
181
  {
182
- $aOption = array();
183
- $aOption['attribute_id'] = $attribute_id;
184
  $attributesList[] = $attribute_id;
185
-
186
- $i=0;
187
- foreach($options as $option)
188
- {
189
- $optionTitle = $helperCatalog->stripTags($option);
190
-
191
- $aOption['value']['option'.$i][0] = $optionTitle;
192
- $i++;
 
 
 
 
193
  }
194
- $installer->addAttributeOption($aOption);
195
  }
196
  $installer->endSetup();
197
 
198
  Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
199
 
200
-
201
  $currentOptions = array();
 
 
202
  $attributeApi = Mage::getModel('catalog/product_attribute_api');
 
203
  foreach($attributesList as $attribute_id)
204
  {
205
- if (!isset($currentOptions[$attribute_id])){
206
- $currentOptions[$attribute_id] = array();
207
- }
208
-
209
- try{
210
- $attributeOptions = $attributeApi->options($attribute_id);
211
- }catch(Exception $ex){
212
- throw new Mage_Api_Exception('attribute_not_exists', $attribute_id);
213
- }
 
 
 
 
 
214
 
215
- foreach ($attributeOptions as $opts)
216
- {
217
-
218
- $label = strtolower($opts['label']);
219
- $optionId = $opts['value'];
220
- if (!isset($currentOptions[$attribute_id][$label]))
221
  $currentOptions[$attribute_id][$label] = $optionId;
222
- else {
223
- $oldId = $currentOptions[$attribute_id][$label];
224
- if ($oldId > $optionId)
225
- {
226
- $attributeApi->removeOption($attribute_id, $oldId);
227
- $currentOptions[$attribute_id][$label] = $optionId;
228
- }
229
- else
230
- {
231
- $attributeApi->removeOption($attribute_id, $optionId);
232
- }
233
  }
234
  }
235
- }
236
 
237
  return $currentOptions;
238
  }
@@ -285,12 +281,12 @@ class LinnSystems_LinnLiveConnect_Helper_Data extends Mage_Core_Helper_Abstract
285
  if (isset($_availableOptions[$option->attribute_id]) && isset($_availableOptions[$option->attribute_id][strtolower($option->label)]))
286
  {
287
  $newAttribute->value = $_availableOptions[$option->attribute_id][strtolower($option->label)];
288
- }
289
 
290
  $additional_attributes->single_data[] = $newAttribute;
291
  }
292
  }
293
-
294
  foreach($multiAttributes as $key=>$data){
295
  $additional_attributes->single_data[] = $data;
296
  }
@@ -304,7 +300,6 @@ class LinnSystems_LinnLiveConnect_Helper_Data extends Mage_Core_Helper_Abstract
304
  {
305
  unset($productData->additional_attributes);
306
  }
307
-
308
  }
309
  return $productData;
310
  }
169
 
170
  public function createOptions($newOptions)
171
  {
172
+ $cache = Mage::app()->getCache();
173
  $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
174
  $attributeApi = Mage::getModel('catalog/product_attribute_api');
175
  $helperCatalog = Mage::helper('catalog');
176
 
177
  $installer->startSetup();
 
178
  $attributesList = array();
179
 
180
  foreach($newOptions as $attribute_id=>$options)
181
  {
182
+ $newOption = array();
183
+ $newOption['attribute_id'] = $attribute_id;
184
  $attributesList[] = $attribute_id;
185
+ $newOption['value'] = array();
186
+
187
+ for($i = 0; $i< sizeof($options); $i++) {
188
+ $label = $helperCatalog->stripTags($options[$i]);
189
+ $cachedValue = $cache->load($attribute_id.'_'.strtolower($label));
190
+ if($cachedValue != 1){
191
+ $newOption['value']['option'.$i][0] = $label;
192
+ $cache->save("1",$attribute_id.'_'.strtolower($label), array('LINNLIVE_EXTENSION_ATTRIBUTES'), 300);
193
+ }
194
+ }
195
+ if(sizeof($newOption['value'])){
196
+ $installer->addAttributeOption($newOption);
197
  }
 
198
  }
199
  $installer->endSetup();
200
 
201
  Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
202
 
 
203
  $currentOptions = array();
204
+
205
+
206
  $attributeApi = Mage::getModel('catalog/product_attribute_api');
207
+
208
  foreach($attributesList as $attribute_id)
209
  {
210
+ $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product',$attribute_id);
211
+
212
+ foreach ( $attribute->getSource()->getAllOptions(true, true) as $option ){
213
+
214
+ $label = strtolower($option['label']);
215
+ $optionId = $option['value'];
216
+ if (!isset($currentOptions[$attribute_id][$label])){
217
+ $currentOptions[$attribute_id][$label] = $optionId;
218
+ }
219
+
220
+ $currentOptionId = $currentOptions[$attribute_id][$label];
221
+ if ($optionId > $currentOptionId){
222
+ $attributeApi->removeOption($attribute_id, $optionId);
223
+ }
224
 
225
+ if ($currentOptionId > $optionId)
226
+ {
227
+ $attributeApi->removeOption($attribute_id, $currentOptionId);
 
 
 
228
  $currentOptions[$attribute_id][$label] = $optionId;
 
 
 
 
 
 
 
 
 
 
 
229
  }
230
  }
231
+ }
232
 
233
  return $currentOptions;
234
  }
281
  if (isset($_availableOptions[$option->attribute_id]) && isset($_availableOptions[$option->attribute_id][strtolower($option->label)]))
282
  {
283
  $newAttribute->value = $_availableOptions[$option->attribute_id][strtolower($option->label)];
284
+ }
285
 
286
  $additional_attributes->single_data[] = $newAttribute;
287
  }
288
  }
289
+
290
  foreach($multiAttributes as $key=>$data){
291
  $additional_attributes->single_data[] = $data;
292
  }
300
  {
301
  unset($productData->additional_attributes);
302
  }
 
303
  }
304
  return $productData;
305
  }
app/code/local/LinnSystems/LinnLiveConnect/Model/Community.php CHANGED
@@ -213,11 +213,12 @@ class LinnSystems_LinnLiveConnect_Model_Community extends LinnSystems_LinnLiveCo
213
  }
214
 
215
  /**
216
- * Get store code
217
  *
218
  * @return string
219
  */
220
  public function getStoreCode($store = null) {
 
221
  $helper = Mage::helper('linnLiveConnect');
222
  return $helper -> currentStoreCode($store);
223
  }
213
  }
214
 
215
  /**
216
+ * Get store code and reset attribute cache
217
  *
218
  * @return string
219
  */
220
  public function getStoreCode($store = null) {
221
+ Mage::app()->cleanCache(array('LINNLIVE_EXTENSION_ATTRIBUTES'));
222
  $helper = Mage::helper('linnLiveConnect');
223
  return $helper -> currentStoreCode($store);
224
  }
app/code/local/LinnSystems/LinnLiveConnect/Model/Main.php CHANGED
@@ -6,7 +6,7 @@ class LinnSystems_LinnLiveConnect_Model_Main extends Mage_Core_Model_Abstract {
6
  protected $_permittedAttributes = array('select', 'multiselect', 'text', 'textarea', 'date', 'price');
7
 
8
  protected function _prepareConfigurableData($productsSet, $attributesSet, $productId, $isUpdate) {
9
-
10
  $helper = Mage::helper('linnLiveConnect');
11
 
12
  $assignedProductsArray = $helper -> objectToArray($this -> _createProductsData($productsSet));
6
  protected $_permittedAttributes = array('select', 'multiselect', 'text', 'textarea', 'date', 'price');
7
 
8
  protected function _prepareConfigurableData($productsSet, $attributesSet, $productId, $isUpdate) {
9
+
10
  $helper = Mage::helper('linnLiveConnect');
11
 
12
  $assignedProductsArray = $helper -> objectToArray($this -> _createProductsData($productsSet));
app/code/local/LinnSystems/LinnLiveConnect/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <LinnSystems_LinnLiveConnect>
5
- <version>1.1.62</version>
6
  </LinnSystems_LinnLiveConnect>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <LinnSystems_LinnLiveConnect>
5
+ <version>1.1.63</version>
6
  </LinnSystems_LinnLiveConnect>
7
  </modules>
8
  <global>
app/etc/modules/LinnSystems_LinnLiveConnect.xml CHANGED
@@ -1,9 +1,13 @@
1
  <?xml version="1.0"?>
2
  <config>
3
- <modules>
4
- <LinnSystems_LinnLiveConnect>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- </LinnSystems_LinnLiveConnect>
8
- </modules>
 
 
 
 
9
  </config>
1
  <?xml version="1.0"?>
2
  <config>
3
+ <modules>
4
+ <LinnSystems_LinnLiveConnect>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Core />
9
+ <Mage_Catalog />
10
+ </depends>
11
+ </LinnSystems_LinnLiveConnect>
12
+ </modules>
13
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LinnLiveConnect</name>
4
- <version>1.1.62</version>
5
  <stability>stable</stability>
6
  <license>GPL v2</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
9
  <summary>Extended SOAP WS-I compliant API to support integration with LinnLive2.</summary>
10
  <description>Extended SOAP WS-I compliant API to support integration with LinnLive2 (http://www.linnlive.com).&#xD;
11
  Contains some workarounds to avoid bugs in original Magento modules and additional functionality to operate Magento store remotely.</description>
12
- <notes>Fixed an issue with identifier type</notes>
13
  <authors><author><name>Albert Andrejev</name><user>albert_andrejev</user><email>albert@linnsystems.com</email></author><author><name>Pavel Nikolajev</name><user>Pavel_LL2</user><email>pavel.nokolajev@linnsystems.com</email></author><author><name>Aleksandr Kornev</name><user>alex_LL2</user><email>alex.kornevs@linnsystems.com</email></author></authors>
14
- <date>2015-02-19</date>
15
- <time>06:37:30</time>
16
- <contents><target name="magelocal"><dir name="LinnSystems"><dir name="LinnLiveConnect"><dir name="Helper"><file name="Data.php" hash="78f74c475691a687b1468f2fcb3f9337"/><file name="Factory.php" hash="7e0a0e26fa3618917f3540b799b05840"/><file name="Settings.php" hash="086ba912d38dc66964a2f40f685394a5"/></dir><dir name="Model"><dir name="Api"><file name="V2.php" hash="a60247b30a00144ee34b77b74821266a"/></dir><dir name="Category"><file name="Api.php" hash="e1d52ef1f902a454c747f0d67d7dfb5e"/></dir><file name="Community.php" hash="20c1d880203627654657a90676eae460"/><dir name="Core"><file name="Store.php" hash="223c37a5156966322f1ef3d4b4530502"/><file name="Url.php" hash="f7480821c151b21f071b8853bf468f78"/></dir><file name="Main.php" hash="f0e9eff62c728f566e9a7da8730ac4d6"/><dir name="Product"><dir name="Api"><file name="V2.php" hash="2e5d74bff09976d7970ac514ec2babd1"/></dir><file name="Api.php" hash="eaa63183cb69e529322459cf3e86c6df"/><dir name="Attribute"><file name="Api.php" hash="fa77daa27c19a04d2a357a4da8222f16"/><dir name="Media"><file name="Api.php" hash="d343f56cbf15bbf5ae5a829be8c66d6d"/></dir></dir><dir name="Link"><file name="Api.php" hash="0ff8998682b9d85a84947215748dd94b"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="a4b2a568bf5b2def5f3fe32c06b4528c"/><file name="config.xml" hash="0952c9fd8898ddc5a86e37c1b3311c53"/><file name="wsdl.xml" hash="2b450fd6a6332d20583aaa4fc52012b6"/><file name="wsi.xml" hash="38e71032a3bcf4629c4feccdd9e3ca15"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LinnSystems_LinnLiveConnect.xml" hash="19c48712cd0516815d6784592ada0881"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LinnLiveConnect</name>
4
+ <version>1.1.63</version>
5
  <stability>stable</stability>
6
  <license>GPL v2</license>
7
  <channel>community</channel>
9
  <summary>Extended SOAP WS-I compliant API to support integration with LinnLive2.</summary>
10
  <description>Extended SOAP WS-I compliant API to support integration with LinnLive2 (http://www.linnlive.com).&#xD;
11
  Contains some workarounds to avoid bugs in original Magento modules and additional functionality to operate Magento store remotely.</description>
12
+ <notes>Fixed an issue with new attribute options</notes>
13
  <authors><author><name>Albert Andrejev</name><user>albert_andrejev</user><email>albert@linnsystems.com</email></author><author><name>Pavel Nikolajev</name><user>Pavel_LL2</user><email>pavel.nokolajev@linnsystems.com</email></author><author><name>Aleksandr Kornev</name><user>alex_LL2</user><email>alex.kornevs@linnsystems.com</email></author></authors>
14
+ <date>2015-04-22</date>
15
+ <time>07:36:10</time>
16
+ <contents><target name="magelocal"><dir name="LinnSystems"><dir name="LinnLiveConnect"><dir name="Helper"><file name="Data.php" hash="39795e3b89da70d74f5a2bd1b8adb901"/><file name="Factory.php" hash="7e0a0e26fa3618917f3540b799b05840"/><file name="Settings.php" hash="086ba912d38dc66964a2f40f685394a5"/></dir><dir name="Model"><dir name="Api"><file name="V2.php" hash="a60247b30a00144ee34b77b74821266a"/></dir><dir name="Category"><file name="Api.php" hash="e1d52ef1f902a454c747f0d67d7dfb5e"/></dir><file name="Community.php" hash="8ca85cd35830e9cf3f1a78b64cc2ef14"/><dir name="Core"><file name="Store.php" hash="223c37a5156966322f1ef3d4b4530502"/><file name="Url.php" hash="f7480821c151b21f071b8853bf468f78"/></dir><file name="Main.php" hash="6a7b9d8c6a0fb33d53c1e5aec3e57301"/><dir name="Product"><dir name="Api"><file name="V2.php" hash="2e5d74bff09976d7970ac514ec2babd1"/></dir><file name="Api.php" hash="eaa63183cb69e529322459cf3e86c6df"/><dir name="Attribute"><file name="Api.php" hash="fa77daa27c19a04d2a357a4da8222f16"/><dir name="Media"><file name="Api.php" hash="d343f56cbf15bbf5ae5a829be8c66d6d"/></dir></dir><dir name="Link"><file name="Api.php" hash="0ff8998682b9d85a84947215748dd94b"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="a4b2a568bf5b2def5f3fe32c06b4528c"/><file name="config.xml" hash="f078b3d978fe4b03c0e999a721588985"/><file name="wsdl.xml" hash="2b450fd6a6332d20583aaa4fc52012b6"/><file name="wsi.xml" hash="38e71032a3bcf4629c4feccdd9e3ca15"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LinnSystems_LinnLiveConnect.xml" hash="14fc1be272169d4eec6a481eee3cbb0d"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>