Magento – Magento2 : Something went wrong while saving the rule data. Please review the error log

coupon-codesmagento2shopping-cart-price-rules

I have Magento2 version 2.1.8, when I tried to create new cart price rules after entering all info it doesn't get saved and shows error.

"Something went wrong while saving the rule data. Please review the
error log."

Kindly guide me I am beginner in Mangeto.

Thanks

Best Answer

A good trick is to search the GitHub repository for Magento 2 for the error strings which will lead you to the classes - this error string appears in two classes. One related to catalog rules and another related to quote - which I would guess would be what we're looking for).

The error is being generated by a catch all Exception block inside this class:

magento2/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Save.php

(or /vendor/magento/module-sales-rule/Controller/Adminhtml/Promo/Quote/Save.php)

Line ~102 depending on version:

       } catch (\Exception $e) {

            $this->messageManager->addError(

                __('Something went wrong while saving the rule data. Please review the error log.')

            );

I know it's forbidden to play with core, but sometimes these things get a bit annoying - and the update should be temporary only for debugging purposes, unless you need to provide a proper error message to an external system, in which case you'd probably override the method. if you're not on a production server you could try to back up the above file, then add an $e->getMessage() to the error output so you can immediately know why this is failing.

(Since you're a beginner - I would suggest checking the log file and reporting back to us instead of doing this)

} catch (\Exception $e) {

    $this->messageManager->addError(

                __('Something went wrong while saving the rule data. Please review the error log. ERROR: %1', $e->getMessage())

);
Related Topic