diff --git a/retailcrm/src/Components/RequestProxy.php b/retailcrm/src/Components/RequestProxy.php index ce1ffd2..4e68083 100644 --- a/retailcrm/src/Components/RequestProxy.php +++ b/retailcrm/src/Components/RequestProxy.php @@ -28,6 +28,10 @@ class RequestProxy if (isset($response['errors'])) { foreach ($response['errors'] as $error) { + if (is_array($error)) { + $error = @implode(', ', $error); + } + $this->logger->write( "[$method] $error \n", $this->container->errorLog diff --git a/retailcrm/src/Helpers/ApiHelper.php b/retailcrm/src/Helpers/ApiHelper.php index ca7fec9..cf6c024 100644 --- a/retailcrm/src/Helpers/ApiHelper.php +++ b/retailcrm/src/Helpers/ApiHelper.php @@ -76,11 +76,15 @@ class ApiHelper $this->logger->put($timemark, $this->container->customersLog); } - public function updateCustomers($customers) + public function updateCustomers($customers, $searchEdit = false) { $timemark = date('Y-m-d H:i:s'); foreach ($customers as $customer) { - $this->api->ordersEdit($customer); + if ($searchEdit) { + $this->checkCustomers($customer, true); + } else { + $this->api->ordersEdit($customer); + } time_nanosleep(0, 250000000); } @@ -151,7 +155,7 @@ class ApiHelper return $orders; } - private function checkCustomers($customer) + private function checkCustomers($customer, $searchEdit = false) { $criteria = array( @@ -189,6 +193,11 @@ class ApiHelper $_externalId = $customer['externalId']; }; + if ($searchEdit) { + $customer['externalId'] = $_externalId; + $this->api->customersEdit($customer); + } + return $_externalId; } } else { diff --git a/retailcrm/src/Helpers/DataHelper.php b/retailcrm/src/Helpers/DataHelper.php index 6bc8106..352a5df 100644 --- a/retailcrm/src/Helpers/DataHelper.php +++ b/retailcrm/src/Helpers/DataHelper.php @@ -25,6 +25,8 @@ class DataHelper if (is_null($haystack[$key]) || $haystack[$key] === '' || count($haystack[$key]) == 0) { unset($haystack[$key]); + } elseif (!is_array($value)) { + $haystack[$key] = trim($value); } }