Configurable Swatches: Uncaught Error: Call to a member function provide() on null
-
12-12-2020 - |
Question
Uncaught Error: Call to a member function provide() on null in /vendor/magento/module-swatches/Helper/Data.php:350
I'm using Magento 2.1.8
with the Ethan theme from MGS
. When I added swatches to configurable product and view the catalog this error appears and breaks the layout/styling of the page.
The single view page for the product doesn't load anything and display white screen.
I've looked all over for a solution, has anyone experienced this before?
Is there a fix?
Solution
I was only able to fix this with a core hack.
Above:
$swatchAttributes = $this->swatchAttributesProvider->provide($product);
Put this:
if (!isset($this->swatchAttributesProvider)) { $this->swatchAttributesProvider = ObjectManager::getInstance()->get(SwatchAttributesProvider::class); }