Solved: Error Call to a member function isClearShoppingCartEnabled() on null After Upgrading Magento 2
Upgraded your Magento store and facing issues on the cart page? Here is the method to solve the ‘Error Call to a member function isClearShoppingCartEnabled() on null’ on the cart page after the Magento upgrade.
Magento roll-outs regular system updates, including platform improvements and features. Sometimes, these version updates also include improvements in the core code, which can make the custom development incompatible. As a result, some of the features related to the custom development may not function properly. I recently faced one such issue after upgrading a store from Magento 2.3.3 to Magento 2.4.5.
In the testing phase, we came to know that the cart page was throwing the following error:
Error: Call to a member function isClearShoppingCartEnabled() on null in /home/magento/magento2_staging/vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml:59
I inspected the error, researched a bit over the internet, and found a working solution.
The cart page was custom developed, which overrode the default layout file.
It came to my notice that Magento 2 had introduced a new argument for blocks in the Magento 2 core code from version 2.3.3 onwards. The argument was missing in the custom cart part, leading to the Call to a member function isClearShoppingCartEnabled() on null in… error.
Here is what I did to solve the issue.
Method to Solve Error Call to a member function isClearShoppingCartEnabled() on null After Upgrading Magento 2
You can follow the steps below to solve the isClearShoppingCartEnabled() on null error after upgrading Magento 2.
- Step 1: Search your custom theme for XML files where the
Magento_Checkout::cart/form.phtml
is being used. - Step 2: Open the XML file, and add the following argument in the <block>:
<arguments>
<argument name="view_model" xsi:type="object">Magento\Checkout\ViewModel\Cart</argument>
</arguments> - Step 3: Save the file.
And that’s it..!
The issue will be solved.
I hope the above solution will help you solve ‘Error Call to a member function isClearShoppingCartEnabled() on null’ after upgrading Magento 2.
A solution to a similar error after Magento 2 upgrade:
If you are still facing the same issue or any other problems after upgrading your store, it is advisable to consult a professional Magento 2 developer to help you. Meetanshi has a team of Adobe-certified Magento 2 experts who can help you solve any post-upgrade issues. You may also consider opting for our annual Magento upgrade service to upgrade your store to the latest version throughout the year without any hurdles!
Prev
Monthly Recap: Meetanshi Launches and Updates – March 2023
10+ Insightful Google Bard Statistics & Facts For 2024
Next