Closed epolish closed 1 year ago
To fix a null pointer of a product inside a foreach loop
develop
To see valid filtered results
Found the issue in vendor/emico/tweakwise/Model/Autocomplete/DataProviderHelper.php::getProductItems() line 147 The foreach loop should be like this
foreach ($response->getProductData() as $item) { $product = $productCollection->getItemById($item['id']); if (!$product) { continue; } $product->setData('tweakwise_price', $item['tweakwise_price']); $result[] = $this->productItemFactory->create(['product' => $product]); } Because a product can be null $product = $productCollection->getItemById($item['id']); $product->setData('tweakwise_price', $item['tweakwise_price']);
Invalid null pointer
To fix a null pointer of a product inside a foreach loop
Environment
Steps to reproduce
develop
branch.Actual result
Expected result
To see valid filtered results
How to fix
Found the issue in vendor/emico/tweakwise/Model/Autocomplete/DataProviderHelper.php::getProductItems() line 147 The foreach loop should be like this