diff --git a/Mplusqapiclient.php b/Mplusqapiclient.php index 0169cc6..e9aaf74 100755 --- a/Mplusqapiclient.php +++ b/Mplusqapiclient.php @@ -2,7 +2,7 @@ class MplusQAPIclient { - const CLIENT_VERSION = '1.25.1'; + const CLIENT_VERSION = '1.26.0'; const WSDL_TTL = 300; // 5 min WSDL TTL var $MIN_API_VERSION_MAJOR = 0; @@ -3301,6 +3301,46 @@ public function getSalePromotions($branchNumbers = [], $attempts=0) throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e); } } // END getSalePromotions() + + //---------------------------------------------------------------------------- + public function getProductOverview($selectFields, $pageNumber = null, $maxPerPage = null, $orderField = null, $sortOrder = null, $filters = null, $search=null, $attempts=0) + { + try { + $request = $this->parser->convertGetProductOverviewRequest($selectFields, $pageNumber, $maxPerPage, $orderField, $sortOrder, $filters, $search); + $result = $this->client->getProductOverview($request); + return $this->parser->parseGetProductOverviewResult($result); + } catch (SoapFault $e) { + $msg = $e->getMessage(); + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { + sleep(1); + return $this->getProductOverview($selectFields, $pageNumber, $maxPerPage, $orderField, $sortOrder, $filters, $search, $attempts+1); + } else { + throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e); + } + } catch (Exception $e) { + throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e); + } + } // END getProductOverview() + + //---------------------------------------------------------------------------- + public function getProductOverviewFields($attempts=0) + { + try { + $request = $this->parser->convertGetProductOverviewFieldsRequest(); + $result = $this->client->getProductOverviewFields($request); + return $this->parser->parseGetProductOverviewFieldsResult($result); + } catch (SoapFault $e) { + $msg = $e->getMessage(); + if (false !== stripos($msg, 'Could not connect to host') and $attempts < 3) { + sleep(1); + return $this->getProductOverviewFields($attempts+1); + } else { + throw new MplusQAPIException('SoapFault occurred: '.$msg, 0, $e); + } + } catch (Exception $e) { + throw new MplusQAPIException('Exception occurred: '.$e->getMessage(), 0, $e); + } + } // END getProductOverview() } @@ -5749,6 +5789,32 @@ public function parseGetSalePromotionsResult($soapGetSalePromotionsResult) { return $salePromotions; } // END parseGetSalePromotionsResult() + //---------------------------------------------------------------------------- + public function parseGetProductOverviewResult($soapGetProductOverviewResult) { + $productOverview = array(); + if(isset($soapGetProductOverviewResult->productOverview)) { + $productOverview = objectToArray($soapGetProductOverviewResult->productOverview); + } + if (isset($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle)) { + $productOverview['productOverviewArticleList'] = objectToArray($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle); + } + return $productOverview; + } // END parseGetProductOverviewResult() + + //---------------------------------------------------------------------------- + public function parseGetProductOverviewFieldsResult($soapGetProductOverviewFieldsResult) { + $productOverviewFields = array(); + die(print_r($soapGetProductOverviewFieldsResult, true)); + + if(isset($soapGetProductOverviewResult->productOverview)) { + $productOverview = objectToArray($soapGetProductOverviewResult->productOverview); + } + if (isset($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle)) { + $productOverview['productOverviewArticleList'] = objectToArray($soapGetProductOverviewResult->productOverviewArticleList->productOverviewArticle); + } + return $productOverview; + } // END parseGetProductOverviewFieldsResult() + //---------------------------------------------------------------------------- @@ -8027,6 +8093,48 @@ public function convertGetSalePromotionsRequest($branchNumbers) $object = arrayToObject($array); return $object; } // END convertGetSalePromotionsRequest() + + //---------------------------------------------------------------------------- + public function convertGetProductOverviewRequest($selectFieldList, $pageNumber, $maxPerPage, $orderField, $sortOrder, $filters, $search) + { + $request = new stdClass(); + $request->request = new stdClass(); + + if(!is_array($selectFieldList)) { + $selectFieldList = array($selectFieldList); + } + $request->request->selectFieldNameList = $selectFieldList; + + if(isset($pageNumber)) { + $request->request->pageNumber = $pageNumber; + } + if(isset($maxPerPage)) { + $request->request->maxPerPage = $maxPerPage; + } + if(isset($orderField)) { + $request->request->orderField = $orderField; + } + if(isset($sortOrder)) { + $request->request->sortOrder = $sortOrder; + } + + if(isset($filters)) { + $request->request->filterList = $filters; + } + + if(isset($search)) { + $request->request->search = $search; + } + return $request; + } // END convertGetProductOverviewRequest() + + //---------------------------------------------------------------------------- + public function convertGetProductOverviewFieldsRequest() + { + $request = new stdClass(); + $request->request = new stdClass(); + return $request; + } // END convertGetProductOverviewFieldsRequest() //----------------------------------------------------------------------------