Commit 1af60eed by Vladislav

исправление удаления уделанных фраз

1 parent 1acc74a1
...@@ -41,7 +41,7 @@ class DeleteKeywords extends DirectRequest ...@@ -41,7 +41,7 @@ class DeleteKeywords extends DirectRequest
$delete_results = $response['result']['DeleteResults']; $delete_results = $response['result']['DeleteResults'];
foreach (array_chunk(array_column(array_filter($delete_results, function ($delete_result) { foreach (array_chunk(array_column(array_filter($delete_results, function ($delete_result) {
return isset($delete_result['Id']) || (isset($delete_result['Errors'][0]['Details']) && $delete_result['Errors'][0]['Details'] === 'Keyword not found'); return isset($delete_result['Id']);
}), 'Id'), 1000) as $external_ids) { }), 'Id'), 1000) as $external_ids) {
GoalKeyword::whereExternalId($external_ids)->delete(); GoalKeyword::whereExternalId($external_ids)->delete();
} }
...@@ -54,7 +54,13 @@ class DeleteKeywords extends DirectRequest ...@@ -54,7 +54,13 @@ class DeleteKeywords extends DirectRequest
$external_id = $this->getParams()['SelectionCriteria']['Ids'][$key]; $external_id = $this->getParams()['SelectionCriteria']['Ids'][$key];
if (isset($delete_result['Errors']) && count($delete_result['Errors'])) { if (isset($delete_result['Errors'][0]['Details']) && $delete_result['Errors'][0]['Details'] === 'Keyword not found') {
//объекта по какой то причине нет
GoalKeyword::where('external_id', $external_id)->delete();
continue;
} elseif (isset($delete_result['Errors']) && count($delete_result['Errors'])) {
$goalKeyword = GoalKeyword::whereExternalId($external_id)->first(); $goalKeyword = GoalKeyword::whereExternalId($external_id)->first();
if ($goalKeyword) { if ($goalKeyword) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!