I need to add a new dropdown field in the "CART PRICE RULE" form in Backend:



Create file in your custom module app/code/Vendor/Module/view/adminhtml/ui_component/sales_rule_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="rule_information" sortOrder="10">
        <field name="store_ids">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</item>
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">int</item>
                    <item name="label" xsi:type="string" translate="true">Store View Test</item>
                    <item name="formElement" xsi:type="string">multiselect</item>
                    <item name="source" xsi:type="string">sales_rule</item>
                    <item name="dataScope" xsi:type="string">store_ids</item>
                    <item name="default" xsi:type="string">0</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>

And you can see changes (the Store View Test column):


Change it to the desired one. But keep in mind, that this field just rendered in the layout, but to do save and load your custom data you should write a custom plugin code which can do this during the model load and save process.

  • @Sri I'm glad to help you :) – Siarhey Uchukhlebau Feb 27 '18 at 13:33
  • How do I save this field in DB and which file is responsibe to save my custom field – Jaisa Feb 27 '18 at 13:33
  • @Sri You can write an observer for the sales_rule model save\load or plugin. Value can be stored in the same table, or in your own table. If you ask a new question with desired result and requirements, I'll try to help you. – Siarhey Uchukhlebau Feb 27 '18 at 13:35
  • I posted a new question magento.stackexchange.com/questions/215266/… – Jaisa Feb 27 '18 at 13:50

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.