Skip to content

Duplicating a cart price rule returns an error #7

@the-line

Description

@the-line

When a cart price rule is duplicated, an error is given. The rule is also not duplicated.

What we noticed is that in the file /vendor/leat/magento2-loyalty/src/module-loyalty/Plugin/SalesRule/ExtensionAttributesPlugin.php at the function beforeSave, there is a call to $rule->getData('gift_skus'). This method does not exist on the given interface. This might break compatibility with other modules, like in this example. This is the reason this error is returned.

The callstack is:

[2025-12-10T10:26:42.785255+00:00] main.CRITICAL: Error: Call to undefined method Magento\SalesRule\Model\Data\Rule::getData() in /vendor/leat/magento2-loyalty/src/module-loyalty/Plugin/SalesRule/ExtensionAttributesPlugin.php:95
Stack trace:
#0 /vendor/magento/framework/Interception/Interceptor.php(121): Leat\Loyalty\Plugin\SalesRule\ExtensionAttributesPlugin->beforeSave()
#1 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\SalesRule\Model\RuleRepository\Interceptor->Magento\Framework\Interception\{closure}()
#2 /generated/code/Magento/SalesRule/Model/RuleRepository/Interceptor.php(23): Magento\SalesRule\Model\RuleRepository\Interceptor->___callPlugins()
#3 /vendor/amasty/rgrid/Model/DuplicateRuleProcessor.php(47): Magento\SalesRule\Model\RuleRepository\Interceptor->save()
#4 /vendor/amasty/rgrid/Controller/Adminhtml/Promo/Quote/Duplicate.php(40): Amasty\Rgrid\Model\DuplicateRuleProcessor->execute()
#5 /vendor/magento/framework/Interception/Interceptor.php(58): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate->execute()
#6 /vendor/magento/framework/Interception/Interceptor.php(138): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->___callParent()
#7 /vendor/magento/framework/Interception/Interceptor.php(153): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->Magento\Framework\Interception\{closure}()
#8 /generated/code/Amasty/Rgrid/Controller/Adminhtml/Promo/Quote/Duplicate/Interceptor.php(23): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->___callPlugins()
#9 /vendor/magento/framework/App/Action/Action.php(111): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->execute()
#10 /vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch()
#11 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch()
#12 /vendor/magento/framework/Interception/Interceptor.php(138): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->___callParent()
#13 /vendor/magento/module-backend/App/Action/Plugin/Authentication.php(145): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->Magento\Framework\Interception\{closure}()
#14 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch()
#15 /vendor/magento/framework/Interception/Interceptor.php(153): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->Magento\Framework\Interception\{closure}()
#16 /generated/code/Amasty/Rgrid/Controller/Adminhtml/Promo/Quote/Duplicate/Interceptor.php(32): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->___callPlugins()
#17 /vendor/magento/framework/App/FrontController.php(245): Amasty\Rgrid\Controller\Adminhtml\Promo\Quote\Duplicate\Interceptor->dispatch()
#18 /vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#19 /vendor/magento/framework/App/FrontController.php(146): Magento\Framework\App\FrontController->processRequest()
#20 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#21 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#22 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#23 /generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#24 /vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#25 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#26 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()
#27 /vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#28 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch()
#29 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#30 /generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()
#31 /vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#32 /pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#33 {main} {"exception":"[object] (Error(code: 0): Call to undefined method Magento\\SalesRule\\Model\\Data\\Rule::getData() at /vendor/leat/magento2-loyalty/src/module-loyalty/Plugin/SalesRule/ExtensionAttributesPlugin.php:95)"} []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions