From 878cf8a513bf7a8297e945090ce2f80133897473 Mon Sep 17 00:00:00 2001 From: LiorGingi Date: Fri, 18 Nov 2022 11:56:13 +0200 Subject: [PATCH] fix(Category/SaveBefore):fixed passing null to json_decode --- Observer/Category/SaveBefore.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Observer/Category/SaveBefore.php b/Observer/Category/SaveBefore.php index 489e22a1..6388ef4f 100644 --- a/Observer/Category/SaveBefore.php +++ b/Observer/Category/SaveBefore.php @@ -87,15 +87,16 @@ public function execute(Observer $observer) $categoryId ); + $productIdToPositionInCategoryStringMapBeforeSave = $this->request->getParam('vm_category_products'); + if ($productIdToPositionInCategoryStringMapBeforeSave === null) { + return; + } + $productIdToPositionInCategoryMapBeforeSave = json_decode( - $this->request->getParam('vm_category_products'), + $productIdToPositionInCategoryStringMapBeforeSave, true ); - if ($productIdToPositionInCategoryMapBeforeSave === null) { - return; - } - $productIdsInCategoryBeforeSave = array_keys($productIdToPositionInCategoryMapBeforeSave); $productsAddedToCategory = array_diff($productIdsInCategoryBeforeSave, $currentProductIdsInCategory); $productsDeletedFromCategory = array_diff($currentProductIdsInCategory, $productIdsInCategoryBeforeSave);