Magento – How to add option in display mode of display setting in category in admin panel

admin-panelcategorymagento2

There are three options (1. products only, 2. Static block only, 3. Static block and products) in display mode, i want add two more options so can any one help me to add more options.

enter image description here

thanks in advanced.

Best Answer

Create a plugin following way:

Vendor/Module/etc/adminhtml/di.xml

 <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\Category\Attribute\Source\Mode">
        <plugin name="WebkulCart" type="Md\Nspc\Plugin\Model\Category\Attribute\Source\Mode" sortOrder="1"/>
    </type>
</config>

Vendor/Module/Plugin/Model/Category/Attribute/Source/Mode.php

namespace Vendor\Module\Plugin\Model\Category\Attribute\Source;

class Mode
{
    public function afterGetAllOptions(
        \Magento\Catalog\Model\Category\Attribute\Source\Mode $subject,
        $result
    ) {
        $result[] = ['value' => 'CUSTOM_MODE', 'label' => 'Custom Mode'];
        return $result;
    }
}

Clear cache.

Related Topic