Cdiscount / API-MarketPlace-SDK-PHP

15 stars 42 forks source link

GetProductListByIdentifierResponse #52

Open Eayshwary opened 5 years ago

Eayshwary commented 5 years ago

when there is only one product that is fetched by the identifier like ean there is fatal error because this code

private function _getProductList() { foreach ($this->_dataResponse['s:Body']['GetProductListByIdentifierResponse']['GetProductListByIdentifierResult']['a:ProductListByIdentifier']['a:ProductByIdentifier'] as $productXML) {

gets all the data as key value instead of 0 index

solution :

private function _getProductList() { if (!isset($this->_dataResponse['s:Body']['GetProductListByIdentifierResponse']['GetProductListByIdentifierResult']['a:ProductListByIdentifier']['a:ProductByIdentifier'][0])) { $this->_dataResponse['s:Body']['GetProductListByIdentifierResponse']['GetProductListByIdentifierResult']['a:ProductListByIdentifier']['a:ProductByIdentifier'] = array($this->_dataResponse['s:Body']['GetProductListByIdentifierResponse']['GetProductListByIdentifierResult']['a:ProductListByIdentifier']['a:ProductByIdentifier']); }; foreach ($this->_dataResponse['s:Body']['GetProductListByIdentifierResponse']['GetProductListByIdentifierResult']['a:ProductListByIdentifier']['a:ProductByIdentifier'] as $productXML) { $product = new ProductIdentity($productXML['a:Ean']);