Skip to content

Commit

Permalink
Merge pull request #4 from SysteembeheerEdg/feature/SEDG-177_fix_empt…
Browse files Browse the repository at this point in the history
…y_array

Added check to prevent error on empty array
  • Loading branch information
mhaagen85 authored Oct 11, 2021
2 parents 8ed0417 + d40271b commit d1f9718
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions Cron/API/ArticleInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,26 @@ protected function processProductUpdates()
if (sizeof($this->_skuList) == 0) {
$this->_skuList = $this->getSkuArray();
}

$results = $client->pullArticleInfo($this->_skuList);

foreach ($results as $result) {
$articles = $result->getArticles();
foreach ($articles as $article) {
if (!$article->isArticleExist()) {
$msg = 'No match for product with sku "' . $article->getArticleNumber() . '", product does not exist in PIM.';
$this->moduleLog(__METHOD__ . '() ' . $msg, true);
$messages[] = ['type'=>'error', 'message' => $msg];
continue;

if ($this->_skuList) {
$results = $client->pullArticleInfo($this->_skuList);

foreach ($results as $result) {
$articles = $result->getArticles();
foreach ($articles as $article) {
if (!$article->isArticleExist()) {
$msg = 'No match for product with sku "' . $article->getArticleNumber() . '", product does not exist in PIM.';
$this->moduleLog(__METHOD__ . '() ' . $msg, true);
$messages[] = ['type' => 'error', 'message' => $msg];
continue;
}

$this->processProduct($article);
$messages[] = [
'type' => 'success',
'message' => 'Successfully synchronized sku "' . $article->getArticleNumber() . '".'
];
}

$this->processProduct($article);
$messages[] = ['type'=>'success', 'message' => 'Successfully synchronized sku "' . $article->getArticleNumber() . '".'];
}
}
return $messages;
Expand Down

0 comments on commit d1f9718

Please sign in to comment.