Skip to content

Commit

Permalink
fix(Category/SaveBefore):fixed passing null to json_decode
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorGingi committed Nov 18, 2022
1 parent 51ebef5 commit 59c1a75
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Observer/Category/SaveBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 59c1a75

Please sign in to comment.