How to hide some option in condition field in admin?

I used this blog to create a condition action:


enter image description here


You need to override this file


in your custom module here


Content for this file is..


namespace Vendor\Rules\Model\Rule\Condition;

class Combine extends \Magento\SalesRule\Model\Rule\Condition\Combine
    protected $_eventManager = null;

    protected $_conditionAddress;

    protected $request;

    public function __construct(
        \Magento\Rule\Model\Condition\Context $context,
        \Magento\Framework\Event\ManagerInterface $eventManager,
        \Magento\SalesRule\Model\Rule\Condition\Address $conditionAddress,
        \Magento\Framework\App\Request\Http $request,
        array $data = []
    ) {
        $this->request = $request;
        parent::__construct($context, $eventManager, $conditionAddress, $data);

    public function getNewChildSelectOptions()
        $conditions = parent::getNewChildSelectOptions();
        $routerName = $this->request->getRouteName(); //'vendor_rules';

        if($routerName == 'vendor_rules'){ //Here you can add your router name in condition.
            $removeProductFound = array_search('Magento\SalesRule\Model\Rule\Condition\Product\Found', array_column($conditions, 'value'));

            $removeSubselect = array_search('Magento\SalesRule\Model\Rule\Condition\Combine', array_column($conditions, 'value'));

        return $conditions;

Here I've added one condition based on router name you can replace your router name there, and I've unset that both options from that array. So now you will not get that both options only in your custom rule module.

You need to add this line in your di.xml file here


Content for this file is..

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\SalesRule\Model\Rule\Condition\Combine" type="Vendor\Rules\Model\Rule\Condition\Combine" />

Run following command once..

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean
php bin/magento cache:flush

Hope this will help you!

| improve this answer | |
  • 1
    its works what i m expect thank you :) – divya sekar Nov 27 '19 at 13:11
  • You're welcome :) @divyasekar – Kishan Savaliya Nov 27 '19 at 13:13
  • can you please tell me how ro remove cart attributes option from condition field prnt.sc/qabr5i – divya sekar Dec 13 '19 at 12:10
  • 1
    try to use unset($conditions[4]); before return. – Kishan Savaliya Dec 13 '19 at 12:51
  • 1
    thanks sir, its working fine – divya sekar Dec 13 '19 at 13:09

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.