I am using the following code in a plugin's
It's returning me the following error,
Fatal error: Uncaught Error: Call to a member function getName() on null in /vendor/magento/module-configurable-product/Model/Product/Type/Configurable.php:992 Stack trace: #0 /generated/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Interceptor.php(310):
When I investigated, I found that some of the selected attributes are not valid for this product as the simple products as out of stock.
How to handle this error? Any help will be greatly appreciated.