LinnLiveConnect - Version 1.1.41

Version Notes

minor bug fixes

Download this release

Release Info

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


Code changes from version 1.1.40 to 1.1.41

app/code/local/LinnSystems/LinnLiveConnect/Model/Api/V2.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  class Settings {
3
- static $VERSION = 38;
4
  }
5
 
6
  class LinnSystems_LinnLiveConnect_Model_Api_V2{
@@ -79,7 +79,7 @@ class Factory{
79
  $version = intval($version);
80
 
81
  if ($version == 0)
82
- throw new Mage_Api_Exception('version is not specified');
83
  if (Settings::$VERSION < $version )
84
  throw new Mage_Api_Exception('wrong_version');
85
  }
@@ -390,7 +390,8 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
390
  $indexer = Mage::getSingleton('index/indexer');
391
  $process = $indexer->getProcessByCode('catalog_product_price');
392
  $process->reindexEverything();
393
- } catch (Mage_Core_Exception $e) {
 
394
  throw new Mage_Api_Exception('configurable_creating_error', $e->getMessage());
395
  }
396
  }
@@ -532,6 +533,20 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
532
  return $this->_getStore()->getCode();
533
  }
534
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  private function _getStore($storeCode=null)
536
  {
537
  if (Mage::app()->isSingleStoreMode()) {
@@ -695,10 +710,10 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
695
 
696
 
697
  /*
698
- *
699
- * Public functions(API)
700
- *
701
- */
702
  public function configurableProduct($set, $sku, $reindex, $productData, $productsSet, $attributesSet, $store=null)
703
  {
704
  if (!$set || !$sku) {
@@ -737,26 +752,34 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
737
 
738
  public function updateConfigurableProduct($productId, $reindex, $productData, $productsSet, $attributesSet, $store=null, $identifierType='id')
739
  {
740
- if ($identifierType == 'id')
741
- {
742
- $productId = intval($productId);
743
 
744
- if ($productId < 1) {
745
- throw new Mage_Api_Exception('product_not_exists', null);
746
- }
747
- }
748
 
749
  $this->_prepareConfigurableData($store, $productData, $assignedProductsArray,
750
  $attributesSetArray, $productsSet, $attributesSet);
751
 
752
  try {
753
  $storeId = Mage::app()->getStore($store)->getId();
754
- } catch (Mage_Core_Model_Store_Exception $e) {
 
755
  throw new Mage_Api_Exception('store_not_exists', null);
756
  }
 
 
 
 
 
 
 
 
 
757
 
758
  $_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
759
 
 
 
 
 
 
760
  $_categoryIds = $_loadedProduct->getCategoryIds();
761
  if (property_exists($productData, 'category_ids'))
762
  {
@@ -808,8 +831,8 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
808
  }
809
 
810
  /*
811
- * Checks if this Magento server has valid Extension installed
812
- */
813
  public function storesList()
814
  {
815
  return ($this->_getCurrentVersion() >= 160);
@@ -822,24 +845,23 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
822
 
823
  public function deleteAssigned($productId, $store=null, $identifierType='id')
824
  {
825
- if ($identifierType == 'id')
826
- {
827
- $productId = intval($productId);
828
-
829
- if ($productId < 1) {
830
- throw new Mage_Api_Exception('product_not_exists', null);
831
- }
832
- }
833
-
834
  $store = $this->_currentStoreCode($store);
835
 
836
  try {
837
  $storeId = Mage::app()->getStore($store)->getId();
838
- } catch (Mage_Core_Model_Store_Exception $e) {
 
839
  throw new Mage_Api_Exception('store_not_exists', null);
840
  }
841
 
842
  $_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
 
 
 
 
 
 
 
843
  $currentWebsites = $_loadedProduct->getWebsiteIds();
844
  $websiteId = $this->_getWebsiteId($store);
845
  $websiteId = $websiteId[0];
@@ -925,12 +947,12 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
925
  }
926
 
927
  /*
928
- * Implementation of catalogProductList because of bug in associativeArray.
929
- * Extended to filter by category id too.
930
- *
931
- * Use 'entity_id' for product_id,
932
- * 'type_id' instead of product type.
933
- */
934
  public function productList($page, $perPage, $filters = null, $store = null)
935
  {
936
  $arrayParams = array(
@@ -942,7 +964,8 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
942
 
943
  try {
944
  $storeId = Mage::app()->getStore($store)->getId();
945
- } catch (Mage_Core_Model_Store_Exception $e) {
 
946
  throw new Mage_Api_Exception('store_not_exists', null);
947
  }
948
 
@@ -999,7 +1022,8 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
999
  foreach ($preparedFilters as $field => $value) {
1000
  $collection->addFieldToFilter($field, $value);
1001
  }
1002
- } catch (Mage_Core_Exception $e) {
 
1003
  throw new Mage_Api_Exception('filters_invalid', $e->getMessage());
1004
  }
1005
  }
@@ -1179,24 +1203,22 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
1179
 
1180
  public function update($productId, $productData, $store = null, $identifierType = 'id')
1181
  {
1182
- if ($identifierType == 'id')
1183
- {
1184
- $productId = intval($productId);
1185
-
1186
- if ($productId < 1) {
1187
- throw new Mage_Api_Exception('product_not_exists', null);
1188
- }
1189
- }
1190
-
1191
  $store = $this->_currentStoreCode($store);
1192
  try {
1193
  $storeId = Mage::app()->getStore($store)->getId();
1194
- } catch (Mage_Core_Model_Store_Exception $e) {
 
1195
  throw new Mage_Api_Exception('store_not_exists', null);
1196
  }
1197
 
1198
  $_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
1199
 
 
 
 
 
 
 
1200
  $_categoryIds = $_loadedProduct->getCategoryIds();
1201
  if (property_exists($productData, 'category_ids'))
1202
  {
@@ -1251,6 +1273,11 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
1251
 
1252
  public function create($type, $set, $sku, $productData, $store = null)
1253
  {
 
 
 
 
 
1254
  $store = $this->_currentStoreCode($store);
1255
 
1256
  $DefaultStore = $this->_getStore();
@@ -1397,7 +1424,7 @@ class LinnLiveEnterprise extends LinnLiveMain{
1397
  }
1398
  else
1399
  {
1400
- $productData->additional_attributes->single_data[$i]->value = $_availableOptions[$option->attribute_id][strtolower($option->label)];
1401
  }
1402
  }
1403
  else
@@ -1408,7 +1435,7 @@ class LinnLiveEnterprise extends LinnLiveMain{
1408
  }
1409
  else
1410
  {
1411
- $productData->additional_attributes->single_data[$i]->value = $option->value;
1412
  }
1413
  }
1414
  $i++;
1
  <?php
2
  class Settings {
3
+ static $VERSION = 41;
4
  }
5
 
6
  class LinnSystems_LinnLiveConnect_Model_Api_V2{
79
  $version = intval($version);
80
 
81
  if ($version == 0)
82
+ throw new Mage_Api_Exception('version_not_specified');
83
  if (Settings::$VERSION < $version )
84
  throw new Mage_Api_Exception('wrong_version');
85
  }
390
  $indexer = Mage::getSingleton('index/indexer');
391
  $process = $indexer->getProcessByCode('catalog_product_price');
392
  $process->reindexEverything();
393
+ }
394
+ catch (Mage_Core_Exception $e) {
395
  throw new Mage_Api_Exception('configurable_creating_error', $e->getMessage());
396
  }
397
  }
533
  return $this->_getStore()->getCode();
534
  }
535
 
536
+ private function _getProductBySku($sku)
537
+ {
538
+ if($sku){
539
+ $product = Mage::getModel('catalog/product');
540
+ $productId = $product->getIdBySku((string)$sku);
541
+ if($productId){
542
+ $product->load($productId);
543
+ if($product->getId()){
544
+ return $product;
545
+ }
546
+ }
547
+ }
548
+ }
549
+
550
  private function _getStore($storeCode=null)
551
  {
552
  if (Mage::app()->isSingleStoreMode()) {
710
 
711
 
712
  /*
713
+ *
714
+ * Public functions(API)
715
+ *
716
+ */
717
  public function configurableProduct($set, $sku, $reindex, $productData, $productsSet, $attributesSet, $store=null)
718
  {
719
  if (!$set || !$sku) {
752
 
753
  public function updateConfigurableProduct($productId, $reindex, $productData, $productsSet, $attributesSet, $store=null, $identifierType='id')
754
  {
 
 
 
755
 
 
 
 
 
756
 
757
  $this->_prepareConfigurableData($store, $productData, $assignedProductsArray,
758
  $attributesSetArray, $productsSet, $attributesSet);
759
 
760
  try {
761
  $storeId = Mage::app()->getStore($store)->getId();
762
+ }
763
+ catch (Mage_Core_Model_Store_Exception $e) {
764
  throw new Mage_Api_Exception('store_not_exists', null);
765
  }
766
+ /*
767
+ if ($identifierType == 'id')
768
+ {
769
+ $productId = intval($productId);
770
+
771
+ if ($productId < 1) {
772
+ throw new Mage_Api_Exception('product_not_exists', null);
773
+ }
774
+ }*/
775
 
776
  $_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
777
 
778
+ if (!$_loadedProduct->getId())
779
+ {
780
+ throw new Mage_Api_Exception('product_not_exists', null);
781
+ }
782
+
783
  $_categoryIds = $_loadedProduct->getCategoryIds();
784
  if (property_exists($productData, 'category_ids'))
785
  {
831
  }
832
 
833
  /*
834
+ * Checks if this Magento server has valid Extension installed
835
+ */
836
  public function storesList()
837
  {
838
  return ($this->_getCurrentVersion() >= 160);
845
 
846
  public function deleteAssigned($productId, $store=null, $identifierType='id')
847
  {
 
 
 
 
 
 
 
 
 
848
  $store = $this->_currentStoreCode($store);
849
 
850
  try {
851
  $storeId = Mage::app()->getStore($store)->getId();
852
+ }
853
+ catch (Mage_Core_Model_Store_Exception $e) {
854
  throw new Mage_Api_Exception('store_not_exists', null);
855
  }
856
 
857
  $_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
858
+
859
+ if (!$_loadedProduct->getId())
860
+ {
861
+ throw new Mage_Api_Exception('product_not_exists', null);
862
+ }
863
+
864
+
865
  $currentWebsites = $_loadedProduct->getWebsiteIds();
866
  $websiteId = $this->_getWebsiteId($store);
867
  $websiteId = $websiteId[0];
947
  }
948
 
949
  /*
950
+ * Implementation of catalogProductList because of bug in associativeArray.
951
+ * Extended to filter by category id too.
952
+ *
953
+ * Use 'entity_id' for product_id,
954
+ * 'type_id' instead of product type.
955
+ */
956
  public function productList($page, $perPage, $filters = null, $store = null)
957
  {
958
  $arrayParams = array(
964
 
965
  try {
966
  $storeId = Mage::app()->getStore($store)->getId();
967
+ }
968
+ catch (Mage_Core_Model_Store_Exception $e) {
969
  throw new Mage_Api_Exception('store_not_exists', null);
970
  }
971
 
1022
  foreach ($preparedFilters as $field => $value) {
1023
  $collection->addFieldToFilter($field, $value);
1024
  }
1025
+ }
1026
+ catch (Mage_Core_Exception $e) {
1027
  throw new Mage_Api_Exception('filters_invalid', $e->getMessage());
1028
  }
1029
  }
1203
 
1204
  public function update($productId, $productData, $store = null, $identifierType = 'id')
1205
  {
 
 
 
 
 
 
 
 
 
1206
  $store = $this->_currentStoreCode($store);
1207
  try {
1208
  $storeId = Mage::app()->getStore($store)->getId();
1209
+ }
1210
+ catch (Mage_Core_Model_Store_Exception $e) {
1211
  throw new Mage_Api_Exception('store_not_exists', null);
1212
  }
1213
 
1214
  $_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
1215
 
1216
+ if (!$_loadedProduct->getId())
1217
+ {
1218
+ throw new Mage_Api_Exception('product_not_exists', null);
1219
+ }
1220
+
1221
+
1222
  $_categoryIds = $_loadedProduct->getCategoryIds();
1223
  if (property_exists($productData, 'category_ids'))
1224
  {
1273
 
1274
  public function create($type, $set, $sku, $productData, $store = null)
1275
  {
1276
+ $product = $this->_getProductBySku($sku);
1277
+ if($product){
1278
+ return $product->getId();
1279
+ }
1280
+
1281
  $store = $this->_currentStoreCode($store);
1282
 
1283
  $DefaultStore = $this->_getStore();
1424
  }
1425
  else
1426
  {
1427
+ $productData->additional_attributes->single_data[$i]->value = $_availableOptions[$option->attribute_id][strtolower($option->label)];
1428
  }
1429
  }
1430
  else
1435
  }
1436
  else
1437
  {
1438
+ $productData->additional_attributes->single_data[$i]->value = $option->value;
1439
  }
1440
  }
1441
  $i++;
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LinnLiveConnect</name>
4
- <version>1.1.40</version>
5
  <stability>stable</stability>
6
  <license>GPL v2</license>
7
  <channel>community</channel>
@@ -12,8 +12,8 @@ Contains some workarounds to avoid bugs in original Magento modules and addition
12
  <notes>minor bug fixes</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>2014-04-16</date>
15
- <time>12:49:47</time>
16
- <contents><target name="magelocal"><dir name="LinnSystems"><dir name="LinnLiveConnect"><dir name="Helper"><file name="Data.php" hash="5fe5216de67d4e69a0f418b0cd7780ee"/></dir><dir name="Model"><dir name="Api"><file name="V2.php" hash="488b6fe5c1eb60f1d812387cf570a046"/></dir></dir><dir name="etc"><file name="api.xml" hash="2d53cb9b318de468f6d2e3d388bb8732"/><file name="config.xml" hash="2d1d6338d93e36b730efde622893b4e6"/><file name="wsdl.xml" hash="fc21f2963c1253f5f40e5e8414312174"/><file name="wsi.xml" hash="ef000d5115f5988664f58df8b9139e5e"/></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.41</version>
5
  <stability>stable</stability>
6
  <license>GPL v2</license>
7
  <channel>community</channel>
12
  <notes>minor bug fixes</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>2014-04-16</date>
15
+ <time>13:18:55</time>
16
+ <contents><target name="magelocal"><dir name="LinnSystems"><dir name="LinnLiveConnect"><dir name="Helper"><file name="Data.php" hash="5fe5216de67d4e69a0f418b0cd7780ee"/></dir><dir name="Model"><dir name="Api"><file name="V2.php" hash="92f252fdbe817193d1cdf7ba4a402191"/></dir></dir><dir name="etc"><file name="api.xml" hash="2d53cb9b318de468f6d2e3d388bb8732"/><file name="config.xml" hash="2d1d6338d93e36b730efde622893b4e6"/><file name="wsdl.xml" hash="fc21f2963c1253f5f40e5e8414312174"/><file name="wsi.xml" hash="ef000d5115f5988664f58df8b9139e5e"/></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>