From f25a3937dc858715a8b6ebc7240f38194eb647a4 Mon Sep 17 00:00:00 2001 From: Dmitry Mamontov Date: Thu, 12 Nov 2015 07:56:31 -0500 Subject: [PATCH] fix motice generate category --- retailcrm/src/Helpers/IcmlHelper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/retailcrm/src/Helpers/IcmlHelper.php b/retailcrm/src/Helpers/IcmlHelper.php index 822b0c4..eff3956 100644 --- a/retailcrm/src/Helpers/IcmlHelper.php +++ b/retailcrm/src/Helpers/IcmlHelper.php @@ -74,6 +74,10 @@ class IcmlHelper private function addCategories($categories) { foreach($categories as $category) { + if (!array_key_exists('name', $category) || !array_key_exists('id', $category)) { + continue; + } + $e = $this->categories->appendChild( $this->document->createElement( 'category', $category['name'] @@ -82,7 +86,7 @@ class IcmlHelper $e->setAttribute('id', $category['id']); - if ($category['parentId'] > 0) { + if (array_key_exists('parentId', $category) && $category['parentId'] > 0) { $e->setAttribute('parentId', $category['parentId']); } }