0

In Magento 2 I am trying to add SalesRule from API: /rest/V1/SalesRules Post Request body:

{
    "rule": { 
    "name": "Test SalesRule",
    "store_labels": [],
    "description": "test 50% discount",
            "website_ids": [
                1
            ],
            "customer_group_ids": [
                1,
                2,
                3,
                5,
                6
            ],
            "from_date": "2019-02-26",
            "to_date": "2019-03-05",
            "uses_per_customer": 1,
            "is_active": true,
            "condition": {
                "condition_type": "Magento\\SalesRule\\Model\\Rule\\Condition\\Combine",
                "aggregator_type": "any",
                "operator": null,
                "value": "1"
            },
            "action_condition": {
                "condition_type": "Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine",
                "aggregator_type": "all",
                "operator": null,
                "value": "1"
            },
            "stop_rules_processing": false,
            "is_advanced": true,
            "sort_order": 1,
            "simple_action": "cart_fixed",
            "discount_amount": 25,
            "discount_qty": 1,
            "discount_step": 0,
            "apply_to_shipping": false,
            "times_used": 0,
            "is_rss": false,
            "coupon_type": "SPECIFIC_COUPON",
            "use_auto_generation": false,
            "uses_per_coupon": 500,
            "simple_free_shipping": "0"
    }
}

But it gives me an error which says

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'actions_hint_label' cannot be null.

When I add this field and gave it some value 1, 0 or something it gives me an error like

Property "ActionsHintLabel" does not have accessor method "getActionsHintLabel" in class "Magento\SalesRule\Api\Data\RuleInterface".

Do you have any clue about that? and how to resolve that issue? thanks for reading, thank you in advance :)

2 Answers 2

0

In Magento, every data provider interface is rewritten by a model class.

If you Check di.xml of Magento_SalesRule of then you will find that Magento\SalesRule\Api\Data\RuleInterface is overridde by Magento\SalesRule\Model\Data\Rule.

So, is this class, might be Magento\SalesRule\Model\Data\Rule override by other class of any 3rd party module where might be ActionsHintLabel define. But this wrong way to rewrite a data model class.

Or may there are some Extension attribute concept build on Magento\SalesRule\Api\Data\RuleInterface and use for some additional work.

So, you have to check extension_attributes.xml of your 3rd party module's extension_attributes.xml and find the solution by removing this extension attribute.

0

Examine input data and compare your data with Magento\SalesRule\Api\ Data\RuleInterface

For example, you must enter the product ID in the array design

Some input functions have an array of specific objects Note the input of data to the functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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