From e16b66df73b3898c6ee8539d32449939fb80217c Mon Sep 17 00:00:00 2001 From: pbaylies Date: Wed, 16 Nov 2016 10:10:17 -0500 Subject: [PATCH] Check return value for getItems() in getIdentities(). If getItems() returns an empty array then this code will generate a PHP warning and potentially crash the page; let's not do that, and check our return values before we try to loop over them. --- .../Magento/Catalog/Block/Product/ProductList/Related.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php index 046596e6d5b57..ff729d33e7f65 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php @@ -126,8 +126,11 @@ public function getItems() public function getIdentities() { $identities = []; - foreach ($this->getItems() as $item) { - $identities = array_merge($identities, $item->getIdentities()); + $items = $this->getItems(); + if ( !empty( $items ) ) { + foreach ($items as $item) { + $identities = array_merge($identities, $item->getIdentities()); + } } return $identities; }