2

In Magento 2.3 I am attempting to add an item to cart, however the cart shows empty and if I 'proceed to checkout' the checkout page is blank with just the loading gif icon.

If I go to 'checkout/cart' then the cart page is blank and just has 'estimate shipping & tax' towards the top of the page.

The console error I get when I click 'add to cart' is below:

customer-data.js:91 Uncaught Error: [object Object]
at Object.<anonymous> (customer-data.js:91)
at fire (jquery.js:3232)
at Object.fireWith [as rejectWith] (jquery.js:3362)
at done (jquery.js:9842)
at XMLHttpRequest.callback (jquery.js:10311)

The server error logs show the below message:

500 GET /customer/section/load/?sections=cart%2Cmessages&update_section_id=true&_=1552910808681 HTTP/1.0

500 GET /customer/section/load/?sections=cart%2Cmessages&update_section_id=true&_=1552910808681 HTTP/1.0

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getFinalProduct() on null in /var/www/vhosts/mysite.co.uk/httpdocs/vendor/magento/module-checkout/CustomerData/DefaultItem.php:129\nStack trace:\n#0 /var/www/vhosts/mysite.co.uk/httpdocs/app/code/MGS/Mpanel/CustomerData/DefaultItem.php(81): Magento\\Checkout\\CustomerData\\DefaultItem->getProductForThumbnail()\n#1 /var/www/vhosts/mysite.co.uk/httpdocs/vendor/magento/module-checkout/CustomerData/AbstractItem.php(32): MGS\\Mpanel\\CustomerData\\DefaultItem->doGetItemData()\n#2 /var/www/vhosts/mysite.co.uk/httpdocs/vendor/magento/module-checkout/CustomerData/ItemPool.php(63): Magento\\Checkout\\CustomerData\\AbstractItem->getItemData(Object(Magento\\Quote\\Model\\Quote\\Item))\n#3 /var/www/vhosts/mysite.co.uk/httpdocs/vendor/magento/module-checkout/CustomerData/Cart.php(167): Magento\\Checkout\\CustomerData\\ItemPool->getItemData(Object(Magento\\Quote\\Model\\Quote\\Item))\n#4 /var/www/vhosts/...\n', referer: https://www.mysite.co.uk/coastal-chic-large-rectangular-dining-table.html

Can anyone please advise a solution?

  • Any solutions please? – mahmoudismail Apr 2 at 11:03
  • Hi @mahmoudismail in this case it was the specific template file that included the error, as it was incompatible with 2.3. – YorkieMagento Apr 2 at 13:23
  • Hi @YorkieMagento what is your solution? – mahmoudismail Apr 2 at 13:27
2

I happen to use the same theme you're using, or at least the module. In the file app\code\MGS\Mpanel\etc\di.xml you can see that the wishlist class is overridden <preference for="Magento\Wishlist\CustomerData\Wishlist" type="MGS\Mpanel\CustomerData\Wishlist" /> but in the constructor the parent constructor is not called what you have to do is to make the constructor look like this:

public function __construct(
    \Magento\Wishlist\Helper\Data $wishlistHelper,
    \Magento\Wishlist\Block\Customer\Sidebar $block,
    \Magento\Catalog\Helper\ImageFactory $imageHelperFactory,
    \Magento\Framework\App\ViewInterface $view,
    \MGS\Mpanel\Helper\Data $panelHelper,
    \MGS\Mpanel\Helper\Image $panelImageHelper,
    \Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface $itemResolver = null
) {
    $this->wishlistHelper = $wishlistHelper;
    $this->imageHelperFactory = $imageHelperFactory;
    $this->block = $block;
    $this->view = $view;
    $this->panelHelper = $panelHelper;
    $this->panelImageHelper = $panelImageHelper;
    parent::__construct($wishlistHelper,$block,$imageHelperFactory,$view,$itemResolver);
}

instead of this:

public function __construct(
    \Magento\Wishlist\Helper\Data $wishlistHelper,
    \Magento\Wishlist\Block\Customer\Sidebar $block,
    \Magento\Catalog\Helper\ImageFactory $imageHelperFactory,
    \Magento\Framework\App\ViewInterface $view,
    \MGS\Mpanel\Helper\Data $panelHelper,
    \MGS\Mpanel\Helper\Image $panelImageHelper
) {
    $this->wishlistHelper = $wishlistHelper;
    $this->imageHelperFactory = $imageHelperFactory;
    $this->block = $block;
    $this->view = $view;
    $this->panelHelper = $panelHelper;
    $this->panelImageHelper = $panelImageHelper;
}

the difference is, I injected the ItemResolverInterface and called the parent constructor like this: parent::__construct($wishlistHelper,$block,$imageHelperFactory,$view,$itemResolver);. Give it a setup:di:compile and you should be good to go.

Good luck.

  • Hi @hestajoe - just tried the above on another site I have (same error) but running Magento 2.2.8 but I get an error during compile.'incompatible argument type' – YorkieMagento Jul 3 at 20:07
  • Hi @YorkieMagento, verify if your theme is compatible with 2.2.8 (note: 2.2.9 came out recently with security updates). Also, could you copy-paste the full error? if nothing shows up, in dev environment, you can set error_reporting(E_ALL); ini_set('display_errors', 1) in app/bootstrap.php. compile it and show us the error. – hestajoe Jul 4 at 11:40
1

I hope, you are using the below custom module where you are trying to get Item information.

MGS/Mpanel/CustomerData/DefaultItem.php

This specific file code is not properly written which gave PHP 500 error. You have to check the Line # 81 in this file and check the product which you are trying to add to cart. This specific product may not have the relevant attribute information which resulted 500 PHP error message.

Either you have to correct the php code or update the proper data for the attribute which will solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.