Version Notes
mapping bug fixes
Download this release
Release Info
Developer | Albert Andrejev |
Extension | LinnLiveConnect |
Version | 1.1.44 |
Comparing to | |
See all releases |
Code changes from version 1.1.43 to 1.1.44
app/code/local/LinnSystems/LinnLiveConnect/Model/Api/V2.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
class Settings {
|
3 |
-
const VERSION =
|
4 |
}
|
5 |
|
6 |
class LinnSystems_LinnLiveConnect_Model_Api_V2{
|
@@ -704,7 +704,45 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
|
|
704 |
return $productData;
|
705 |
}
|
706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
|
|
|
|
|
|
|
708 |
|
709 |
/*
|
710 |
*
|
@@ -760,15 +798,6 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
|
|
760 |
catch (Mage_Core_Model_Store_Exception $e) {
|
761 |
throw new Mage_Api_Exception('store_not_exists', null);
|
762 |
}
|
763 |
-
/*
|
764 |
-
if ($identifierType == 'id')
|
765 |
-
{
|
766 |
-
$productId = intval($productId);
|
767 |
-
|
768 |
-
if ($productId < 1) {
|
769 |
-
throw new Mage_Api_Exception('product_not_exists', null);
|
770 |
-
}
|
771 |
-
}*/
|
772 |
|
773 |
$_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
|
774 |
|
@@ -787,7 +816,6 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
|
|
787 |
}
|
788 |
|
789 |
$productData->category_ids = array_merge($_categoryIds, $productData->category_ids);
|
790 |
-
|
791 |
}
|
792 |
else
|
793 |
{
|
@@ -943,6 +971,9 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
|
|
943 |
return true;
|
944 |
}
|
945 |
|
|
|
|
|
|
|
946 |
/*
|
947 |
* Implementation of catalogProductList because of bug in associativeArray.
|
948 |
* Extended to filter by category id too.
|
@@ -951,101 +982,72 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
|
|
951 |
* 'type_id' instead of product type.
|
952 |
*/
|
953 |
public function productList($page, $perPage, $filters = null, $store = null)
|
954 |
-
{
|
955 |
-
|
956 |
-
'nin',
|
957 |
-
'in',
|
958 |
-
);
|
959 |
-
|
960 |
-
$store = $this->_currentStoreCode($store);
|
961 |
-
|
962 |
try {
|
963 |
-
$storeId = Mage::app()->getStore($store)->getId();
|
964 |
}
|
965 |
catch (Mage_Core_Model_Store_Exception $e) {
|
966 |
throw new Mage_Api_Exception('store_not_exists', null);
|
967 |
}
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
}
|
974 |
}
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
$preparedFilters[$_op] = array(
|
989 |
-
$_filterKey => $values
|
990 |
-
);
|
991 |
}
|
992 |
-
|
993 |
-
|
994 |
-
if (isset($preparedFilters['category']) &&
|
995 |
-
is_string($preparedFilters['category']))
|
996 |
-
{
|
997 |
-
$_categoryId = intval($preparedFilters['category']);
|
998 |
unset($preparedFilters['category']);
|
999 |
}
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
if ($_categoryId > 0)
|
1006 |
-
{
|
1007 |
-
$_category = Mage::getModel('catalog/category')->load($_categoryId);
|
1008 |
-
$collection = Mage::getModel('catalog/product')->getCollection()
|
1009 |
-
->addStoreFilter($storeId)
|
1010 |
-
->addCategoryFilter($_category);
|
1011 |
-
}
|
1012 |
-
else
|
1013 |
-
{
|
1014 |
-
$collection = Mage::getModel('catalog/product')->getCollection()
|
1015 |
-
->addStoreFilter($storeId);
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
try {
|
1019 |
-
foreach ($preparedFilters as $field => $value) {
|
1020 |
-
$collection->addFieldToFilter($field, $value);
|
1021 |
-
}
|
1022 |
-
}
|
1023 |
-
catch (Mage_Core_Exception $e) {
|
1024 |
-
throw new Mage_Api_Exception('filters_invalid', $e->getMessage());
|
1025 |
}
|
1026 |
}
|
|
|
|
|
|
|
|
|
1027 |
|
1028 |
if ($page == 1)
|
1029 |
{
|
|
|
1030 |
$count = $collection->count();
|
1031 |
}
|
1032 |
else
|
1033 |
{
|
1034 |
-
$collection->setPageSize($perPage)
|
1035 |
-
->setCurPage($page);
|
1036 |
$count = 0;
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
$result
|
1041 |
-
|
1042 |
-
|
|
|
|
|
1043 |
$_assignedIds = array();
|
1044 |
$_fetchedIds = array();
|
1045 |
-
|
1046 |
$i = 0;
|
1047 |
-
foreach ($collection as $_product) {
|
1048 |
-
|
|
|
1049 |
$_loadedProduct = Mage::helper('catalog/product')->getProduct($_product->getId(), $storeId, 'id');
|
1050 |
|
1051 |
$_allAttributes = $_loadedProduct->getData();
|
@@ -1074,6 +1076,7 @@ class LinnLiveMain extends Mage_Core_Model_Abstract{
|
|
1074 |
'images' => $_productImages,
|
1075 |
'attributes' => $_productAttributes,
|
1076 |
);
|
|
|
1077 |
if($_loadedProduct->getTypeId() == "configurable")
|
1078 |
{
|
1079 |
$_typeInstance = $_loadedProduct->getTypeInstance();
|
1 |
<?php
|
2 |
class Settings {
|
3 |
+
const VERSION = 44;
|
4 |
}
|
5 |
|
6 |
class LinnSystems_LinnLiveConnect_Model_Api_V2{
|
704 |
return $productData;
|
705 |
}
|
706 |
|
707 |
+
/*
|
708 |
+
* Helper for productList
|
709 |
+
*/
|
710 |
+
private function _convertFiltersToArray($filters){
|
711 |
+
$arrayParams = array(
|
712 |
+
'nin',
|
713 |
+
'in',
|
714 |
+
);
|
715 |
+
|
716 |
+
$preparedFilters = array();
|
717 |
+
|
718 |
+
if (isset($filters->filter)) {
|
719 |
+
$preparedFilters = $filters->filter;
|
720 |
+
}
|
721 |
+
|
722 |
+
if (isset($filters->complex_filter)) {
|
723 |
+
|
724 |
+
foreach ($filters->complex_filter as $idx=>$data) {
|
725 |
+
if(is_object($data->value)){
|
726 |
+
//1.8
|
727 |
+
$field = $data->key;
|
728 |
+
$opts = $data->value;
|
729 |
+
|
730 |
+
}else{
|
731 |
+
//1.7
|
732 |
+
$field = $idx;
|
733 |
+
$opts = $data;
|
734 |
+
}
|
735 |
+
|
736 |
+
$value = (in_array($opts->key, $arrayParams)) ? explode(',', $opts->value) : $opts->value;
|
737 |
+
$preparedFilters[$field][$opts->key] = $value;
|
738 |
+
}
|
739 |
+
}
|
740 |
+
return $preparedFilters;
|
741 |
+
}
|
742 |
|
743 |
+
private function _log($message){
|
744 |
+
Mage::log(print_r($message, true));
|
745 |
+
}
|
746 |
|
747 |
/*
|
748 |
*
|
798 |
catch (Mage_Core_Model_Store_Exception $e) {
|
799 |
throw new Mage_Api_Exception('store_not_exists', null);
|
800 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
801 |
|
802 |
$_loadedProduct = Mage::helper('catalog/product')->getProduct($productId, $storeId, $identifierType);
|
803 |
|
816 |
}
|
817 |
|
818 |
$productData->category_ids = array_merge($_categoryIds, $productData->category_ids);
|
|
|
819 |
}
|
820 |
else
|
821 |
{
|
971 |
return true;
|
972 |
}
|
973 |
|
974 |
+
|
975 |
+
|
976 |
+
|
977 |
/*
|
978 |
* Implementation of catalogProductList because of bug in associativeArray.
|
979 |
* Extended to filter by category id too.
|
982 |
* 'type_id' instead of product type.
|
983 |
*/
|
984 |
public function productList($page, $perPage, $filters = null, $store = null)
|
985 |
+
{
|
986 |
+
//get store
|
|
|
|
|
|
|
|
|
|
|
|
|
987 |
try {
|
988 |
+
$storeId = Mage::app()->getStore( $this->_currentStoreCode($store) )->getId();
|
989 |
}
|
990 |
catch (Mage_Core_Model_Store_Exception $e) {
|
991 |
throw new Mage_Api_Exception('store_not_exists', null);
|
992 |
}
|
993 |
+
|
994 |
+
//prepare and convert filters to array
|
995 |
+
$preparedFilters = $this->_convertFiltersToArray($filters);
|
996 |
+
if (empty($preparedFilters)) {
|
997 |
+
throw new Mage_Api_Exception('filters_invalid', 'Filters not found');
|
|
|
998 |
}
|
999 |
+
|
1000 |
+
//load collection
|
1001 |
+
$collection = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId);
|
1002 |
+
|
1003 |
+
//filter collection by category if exists
|
1004 |
+
if (isset($preparedFilters['category']) && is_string($preparedFilters['category']))
|
1005 |
+
{
|
1006 |
+
$_category = Mage::getModel('catalog/category')->load(
|
1007 |
+
intval($preparedFilters['category'])
|
1008 |
+
);
|
1009 |
+
|
1010 |
+
if($_category->getId()){
|
1011 |
+
$collection = $collection->addCategoryFilter($_category);
|
|
|
|
|
|
|
1012 |
}
|
1013 |
+
|
|
|
|
|
|
|
|
|
|
|
1014 |
unset($preparedFilters['category']);
|
1015 |
}
|
1016 |
+
|
1017 |
+
//add prepared filters to collection
|
1018 |
+
try {
|
1019 |
+
foreach ($preparedFilters as $field => $value) {
|
1020 |
+
$collection->addFieldToFilter($field, $value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1021 |
}
|
1022 |
}
|
1023 |
+
catch (Mage_Core_Exception $e) {
|
1024 |
+
throw new Mage_Api_Exception('filters_invalid', $e->getMessage());
|
1025 |
+
}
|
1026 |
+
|
1027 |
|
1028 |
if ($page == 1)
|
1029 |
{
|
1030 |
+
//TODO: limit page size
|
1031 |
$count = $collection->count();
|
1032 |
}
|
1033 |
else
|
1034 |
{
|
|
|
|
|
1035 |
$count = 0;
|
1036 |
+
$collection->setPageSize($perPage)->setCurPage($page);
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
$result = array(
|
1040 |
+
'count'=>$count,
|
1041 |
+
'products'=>array()
|
1042 |
+
);
|
1043 |
+
|
1044 |
$_assignedIds = array();
|
1045 |
$_fetchedIds = array();
|
1046 |
+
|
1047 |
$i = 0;
|
1048 |
+
foreach ($collection as $_product) {
|
1049 |
+
|
1050 |
+
if ($i >= ($perPage * $page)) break;//TODO remove
|
1051 |
$_loadedProduct = Mage::helper('catalog/product')->getProduct($_product->getId(), $storeId, 'id');
|
1052 |
|
1053 |
$_allAttributes = $_loadedProduct->getData();
|
1076 |
'images' => $_productImages,
|
1077 |
'attributes' => $_productAttributes,
|
1078 |
);
|
1079 |
+
|
1080 |
if($_loadedProduct->getTypeId() == "configurable")
|
1081 |
{
|
1082 |
$_typeInstance = $_loadedProduct->getTypeInstance();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LinnLiveConnect</name>
|
4 |
-
<version>1.1.
|
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).
|
11 |
Contains some workarounds to avoid bugs in original Magento modules and additional functionality to operate Magento store remotely.</description>
|
12 |
-
<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-05-
|
15 |
-
<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="
|
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.44</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).
|
11 |
Contains some workarounds to avoid bugs in original Magento modules and additional functionality to operate Magento store remotely.</description>
|
12 |
+
<notes>mapping 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-05-05</date>
|
15 |
+
<time>13:13:19</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="8fcbd90078d8c11f99a632f516f24a3e"/></dir></dir><dir name="etc"><file name="api.xml" hash="ae6bb50af6b605606819021ce4acd33d"/><file name="config.xml" hash="9367dc40a0ce3d4078039f495ccd6527"/><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>
|