We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    How to set color images in select box of color attribute in Magento 2?

    You can’t set any image & color icon image in the Magento color dropdown attribute.

    If you want to set color images in the dropdown of the color attribute then follow below steps.

    Step 1: Override this file in your theme and replace with the below code.

    app/design/frontend/[VendorName]/[theme]/Magento_ConfigurableProduct/templates/product/view/type/options/configurable.phtml

    <?php
    /** @var $block MagentoConfigurableProductBlockProductViewTypeConfigurable*/
    $_product    = $block->getProduct();
    $_attributes = $block->decorateArray($block->getAllowAttributes());
    ?>
    <?php if ($_product->isSaleable() && count($_attributes)):?>
        <?php foreach ($_attributes as $_attribute): ?>
            <?php if($block->escapeHtml($_attribute->getProductAttribute()->getStoreLabel()) == 'Color'): ?>
                <div class="field configurable required color">
                    <label class="label" for="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>">
                        <span><?= $block->escapeHtml($_attribute->getProductAttribute()->getStoreLabel()) ?></span>
                    </label>
                    <div class="control drop-down">
                        <select name="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
                                data-selector="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
                                data-validate="{required:true}"
                                id="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>"
                                class="super-attribute-select">
                            <option value=""><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>
                        </select>
                    </div>
                </div>
            <?php else: ?>
                <div class="field configurable required">
                    <label class="label" for="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>">
                        <span><?= $block->escapeHtml($_attribute->getProductAttribute()->getStoreLabel()) ?></span>
                    </label>
                    <div class="control">
                        <select name="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
                                data-selector="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
                                data-validate="{required:true}"
                                id="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>"
                                class="super-attribute-select">
                            <option value=""><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>
                        </select>
                    </div>
                </div>
            <?php endif; ?>            
        <?php endforeach; ?>
        <script type="text/x-magento-init">
            {
                "#product_addtocart_form": {
                    "configurable": {
                        "spConfig": <?= /* @escapeNotVerified */ $block->getJsonConfig() ?>,
                        "gallerySwitchStrategy": "<?php /* @escapeNotVerified */ echo $block->getVar('gallery_switch_strategy',
                            'Magento_ConfigurableProduct') ?: 'replace'; ?>"
                    }
                },
                "*" : {
                    "Magento_ConfigurableProduct/js/catalog-add-to-cart": {}
                }
            }
        </script>
    <?php endif;?>
    <?php 
        $objectManager =   MagentoFrameworkAppObjectManager::getInstance();
        $connection = $objectManager->get('MagentoFrameworkAppResourceConnection')->getConnection('MagentoFrameworkAppResourceConnection::DEFAULT_CONNECTION'); 
        $records = $connection->fetchAll("SELECT * FROM color_code");
        // In color_code table have 3 fields like id, color_name, image_url
        // and store data something like this
        // id   color_name      image_url
        // 1    Black           pub/media/catalog/swatches/2/40x40/media/black.png
        // 2    Green           pub/media/catalog/swatches/2/40x40/media/green.png
        // 3    White           pub/media/catalog/swatches/2/40x40/media/white.png
        //print_r($records);
        $storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
        $base_url = $storeManager->getStore()->getBaseUrl();
    ?>    
    <script type="text/javascript">
    require(["jquery"], function(jQuery) {
        document.onreadystatechange = function(){
            if(document.readyState=='loaded' || document.readyState=='complete') {
                setTimeout(function(){ 
                    
                    jQuery('.drop-down').append('<div class="button"></div>');  
                    jQuery('.drop-down').append('<ul class="select-list"></ul>');
                    jQuery('.drop-down select option').each(function() {
                        var bg = jQuery(this).val();
                        var colortext1 = jQuery(this).text();
                        var colortext1_arr = colortext1.split(' +');
                        var colortext = colortext1_arr[0].replace(/s/g, '');
                        
                        var obj = [];
                        <?php foreach ($records as $color) { ?>
                            obj['<?php echo $color['color_name']; ?>'] = '<?php echo $base_url.$color['image_url']; ?>';  
                        <?php } ?>
    
                        jQuery('.select-list').append('<li class="clsAnchor"><span class="color-icon" style="background:url(' + obj[colortext] + ') no-repeat center center"></span><span value="' + bg + '" class="' + jQuery(this).attr('class') + '" >' + colortext1_arr[0] + '</span></li>');
                    });
                    jQuery('.drop-down .button').html('<span class="color-icon" style="background-color:' + jQuery('.drop-down select').find(':selected').val() + '"></span><span class="color-text">' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');              
                    jQuery('.drop-down ul li').each(function() {
                        if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text()) {
                            jQuery(this).addClass('active');
                        }
                    });
                    jQuery('.drop-down .select-list span').on('click', function() {
                        var dd_text = jQuery(this).text();
                        var dd_val = jQuery(this).attr('value');
                        var dd_color_arr = dd_text.split(' +');
                        var dd_color = dd_color_arr[0].replace(/s/g, '');
                        
                        jQuery('.super-attribute-select option[value='+ dd_val +']').prop('selected',true).trigger('change');
    
                        var obj1 = [];
                        <?php foreach ($records as $color) { ?>
                            obj1['<?php echo $color['color_name']; ?>'] = '<?php echo $base_url.$color['image_url']; ?>';                         
                        <?php } ?>
    
                        jQuery('.drop-down .button').html('<span class="color-icon" style="background:url(' + obj1[dd_color] + ') no-repeat center center"></span><span class="color-text">' + dd_color_arr[0] + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
                        jQuery('.drop-down .select-list span').parent().removeClass('active');
                        jQuery(this).parent().addClass('active');
                        jQuery('.drop-down select[name=options]').val( dd_text );
                        jQuery('.drop-down .select-list li').slideUp();                
                    });                
                    jQuery('.drop-down .button').on('click', function() {
                        jQuery('.drop-down ul li').slideToggle();
                    });
                }, 3000);            
            }
        }
    }); 
    </script>

    Step 2: Add below CSS in your style.css

    .color .drop-down { position: relative; width: auto; margin-top: 0; font-family: verdana; }
    .color .drop-down select { display: none; }
    .color .drop-down .button { border: 1px solid #000; padding: 0px 8px; color: #333; border-radius: 6px; }
    .color .drop-down .button .color-icon { display: block; width: 20px; height: 20px; float: left; border-radius: 3px; margin: 6px 10px 6px 0px; }
    .color .drop-down .button a { float: right; text-decoration: none; }
    .color .drop-down .select-list { position: absolute; top: 0; left: 0; z-index: 1; margin-top: 40px; padding: 0; background-color: #f0f0f0; 
        border-radius: 6px; width: 100%; max-height: 250px; overflow: auto; }
    .color .drop-down .select-list li:first-child { margin-top: 1rem; }
    .color .drop-down .select-list li { display: none; list-style: none; }
    .color .drop-down .select-list li span { display: inline-block; min-height: 32px; padding: 5px 15px 5px 15px; background-position: left 10px center; background-repeat: no-repeat; font-size: 16px; text-align: left; color: #FFF; opacity: 0.7; box-sizing: border-box; color: #333; font-family: 'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif; font-style: normal; }
    .color .drop-down .select-list li span.undefined { padding: 0px 15px !important; }
    .color .drop-down .select-list li span:hover, .drop-down .select-list li span:focus { opacity: 1; }
    .color .drop-down .select-list li span.color-icon { float: left; margin-left: 10px; border-radius: 5px; }
    .color .drop-down .select-list li span.swatch-option { float: right; border: none; margin: 0; }

    Step 3: Run below commands.

    - php bin/magento setup:upgrade
    - php bin/magento cache:clean

    That’s it.

    After making these changes, you can check your product detail page. You will see color images or icons in the color select boxes.

     

    Upload fails. WYSIWYG displays “File validation failed” while uploading Images Magento 2

    Are you getting an error that says “File validation failed” while uploading images from cms block in Magento 2.3 version?

    Check error screenshot :

    I experienced the same issue. But, the problem solved for me after installing the “PHP Fileinfo module“.

    I advise you to install shown PHP extension as per your PHP version :

    Hope that helps!

    How to add custom button on admin order view page in Magento2?

    To add a custom button on the admin order view page, you need to create a before plugin for the PushButtons() method from the MagentoBackendBlockWidgetButtonToolbar class.

    Create di.xml file under the adminhtml scope,
    Path: app/code/Magemonkeys/OrderViewButton/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">
        <!-- Add new Button on sales order view toolbar -->
        <type name="MagentoBackendBlockWidgetButtonToolbar">
            <plugin name="add_sales_button_toolbar" type="MagemonkeysOrderViewButtonPluginBlockWidgetButtonToolbarPlugin" />
        </type>
    </config>

    create ToolbarPlugin.php
    Path: app/code/Magemonkeys/OrderViewButton/Plugin/Block/Widget/Button/ToolbarPlugin.php

    <?php declare(strict_types=1);
    
    namespace MagemonkeysOrderViewButtonPluginBlockWidgetButton;
    
    use MagentoSalesBlockAdminhtmlOrderCreate;
    use MagentoFrameworkViewElementAbstractBlock;
    use MagentoBackendBlockWidgetButtonButtonList;
    use MagentoBackendBlockWidgetButtonToolbar as ToolbarContext;
    
    class ToolbarPlugin
    {
        /**
         * @param ToolbarContext $toolbar
         * @param AbstractBlock $context
         * @param ButtonList $buttonList
         * @return array
         */
        public function beforePushButtons(
            ToolbarContext $toolbar,
            AbstractBlock $context,
            ButtonList $buttonList
        ): array {
            $order = false;
            $nameInLayout = $context->getNameInLayout();
            if ('sales_order_edit' == $nameInLayout) {
                $order = $context->getOrder();
            }
    
            if ($order) {
            	$url = "YOUR_URL"; // add your full url
    	        $buttonList->add(
    	            'my_button',
    	            [
    	                'label' => __('My Button'),
    	            	'on_click' => sprintf("location.href = '%s';", $url),
    	                'class' => 'primary',
    	                'id' => 'my_button'
    	            ]
    	        );
            }
    
            return [$context, $buttonList];        
        }
    }<code>

    Output :

    How to show associate product’s id of configurable product on product detail page?

    Default Magento does not show associate product’s id of a configurable product on the product detail page When change options of a configurable product.

    If, you want to show associate id then see below code

    Override this file into your theme : vendor/magento/module-catalog/view/frontend/templates/product/view/attribute.phtml

    And, paste below script in last of this page

    <script type="text/javascript">
        
        require(["jquery"], function(jQuery) {
            
            jQuery(".product-options-wrapper select[id^='attribute']").last().on('change', function() {
                
                setTimeout(function (){
                    
                    simpleId=jQuery("input[name=selected_configurable_option]").val();
                    
                    jQuery(".value").html(simpleId);       // Place your place id or class in place of ".value"
    
                }, 500); 
    
            });
    
        }); 
    
    </script>

     

    Magento 2: Add color background in drop-down

    Let’s say that you have a specific requirement to convert a simple drop-down into drop-down with color in the background.

    Step 1:  Add the “drop-down” class in the mentioned file “app/design/frontend/Magemonkey/luma_child/Magento_ConfigurableProduct/templates/product/view/type/options/configurable.phtml”

    <div class="field configurable required color">
                    <label class="label" for="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>">
                        <span><?= $block->escapeHtml($_attribute->getProductAttribute()->getStoreLabel()) ?></span>
                    </label>
                    <div class="control drop-down">
                        <select name="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
                                data-selector="super_attribute[<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>]"
                                data-validate="{required:true}"
                                id="attribute<?= /* @escapeNotVerified */ $_attribute->getAttributeId() ?>"
                                class="super-attribute-select">
                            <option value=""><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>
                        </select>
                    </div>
                </div>

    Step 2:  Add the below js in the mentioned file
    “app/design/frontend/Magemonkey/luma_child/Magento_ConfigurableProduct/templates/product/view/type/options/configurable.phtml”

    <script type="text/javascript">
    require(["jquery"], function(jQuery) {
        document.onreadystatechange = function(){
            if(document.readyState=='loaded' || document.readyState=='complete') {
                setTimeout(function(){ 
                    jQuery('.drop-down').append('<div class="button"></div>');  
                    jQuery('.drop-down').append('<ul class="select-list"></ul>');
                    jQuery('.drop-down select option').each(function() {
                        var bg = jQuery(this).val();
                        var colortext1 = jQuery(this).text();
                        var colortext1_arr = colortext1.split(' +');
                        
                        var colortext = colortext1_arr[0].replace(/s/g, '');
                        
                        jQuery('.select-list').append('<li class="clsAnchor"><span class="color-icon" style="background-color:' + colortext + '"></span><span value="' + bg + '" class="' + jQuery(this).attr('class') + '" >' + jQuery(this).text() + '</span></li>');
                    });
                    jQuery('.drop-down .button').html('<span class="color-icon" style="background-color:' + jQuery('.drop-down select').find(':selected').val() + '"></span><span class="color-text">' + jQuery('.drop-down select').find(':selected').text() + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');              
                    jQuery('.drop-down ul li').each(function() {
                        if (jQuery(this).find('span').text() == jQuery('.drop-down select').find(':selected').text()) {
                            jQuery(this).addClass('active');
                        }
                    });
                    jQuery('.drop-down .select-list span').on('click', function() {
                        var dd_text = jQuery(this).text();
                        var dd_img1 = jQuery(this).css('background-color');
                        var dd_img = '#'+dd_img1.match(/d+/g).map(x=>(+x).toString(16).padStart(2,0)).join('');
                        var dd_val = jQuery(this).attr('value');
                        //alert(dd_val);
                        var dd_color_arr = dd_text.split(' +');
                        //var dd_color = dd_color_arr[0];
                        var dd_color = dd_color_arr[0].replace(/s/g, '');
    
                        
                        jQuery('.super-attribute-select option[value='+ dd_val +']').prop('selected',true).trigger('change');
    
                        
                        jQuery('.drop-down .button').html('<span class="color-icon" style="background-color:' + dd_color + '"></span><span class="color-text">' + dd_text + '</span>' + '<a href="javascript:void(0);" class="select-list-link">Arrow</a>');
                        jQuery('.drop-down .select-list span').parent().removeClass('active');
                        jQuery(this).parent().addClass('active');
                        jQuery('.drop-down select[name=options]').val( dd_text );
                        jQuery('.drop-down .select-list li').slideUp();                
                    });
                    
                    jQuery('.drop-down .button').on('click', function() {
                        jQuery('.drop-down ul li').slideToggle();
                    });
    
                }, 3000);
            }
        }
    }); 
    </script>

    This will convert the drop-down in HTML structure and set the color as a background.

    Magento 2: Disable Order Confirmation Email Based On Configuration Settings

    To do this customization we have two options.

    In option one, we can use the event on order success and in the second option we can do it by using the plugin

    Here I am sharing you insights that how can we disable it by using the plugin:

    You have to create di.xml in your existing extension or create an extension which you can do by adding below code,

    app/code/[Vendor Name]/[Module Name]/etc/frontend/di.xml
    <type name="MagentoSalesModelOrderEmailContainerOrderIdentity">
        <plugin name="optDisableEmail" sortOrder="140" type="[Vendor Name][Module Name]PluginOrderEmailOrderEmail"/>
    </type>

    Then you have to create [Vendor Name][Module Name]PluginOrderEmailOrderEmail.php file and add below code,

    public function afterIsEnabled(
        MagentoSalesModelOrderEmailContainerOrderIdentity $subject,
        $result    
    ) {
        if(Get your configuration setting value here){ //Check you require flag value here
           $result = false;
        }
        return $result;
    }

    After that just clean the Magento cache and check by placing a demo order.
    A confirmation email should work based on a configuration setting.

    Create Customer using Programming in Magento 2

    If you want to create customer using programming in Magento 2, then use the following code.

    1. Create savecustomer.php file at magento 2 root folder

    2. Put below code in the savecustomer.php file

    <?php
    use MagentoFrameworkAppBootstrap;
    
    require __DIR__ . '/app/bootstrap.php';
    
    $bootstraps = Bootstrap::create(BP, $_SERVER);
    
    $objectManager = $bootstraps->getObjectManager();
    
    $appState = $objectManager->get('MagentoFrameworkAppState');
    
    $appState->setAreaCode('frontend');
    
    $storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
    
    $websiteId = $storeManager->getStore()->getWebsiteId();
    
    $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
    
    $connection = $resource->getConnection();
    
    use MagentoCustomerApiAccountManagementInterface;
    
    use MagentoCustomerModelAccountManagement;
    
    $customer = $objectManager->get('MagentoCustomerModelCustomerFactory')->create();
    
    $customer->setWebsiteId($websiteId);
    
    if ($customer->loadByEmail('stevealbini820@gmail.com')->getId()) {
    	echo '<br>';
    	echo 'Customer with email '.$email.' is already registered.';  
    } else {
    	try {
    		// prepare customer data
    		$customer->setEmail('stevealbini820@gmail.com'); 
    		$customer->setFirstname('firstName');
    		$customer->setLastname('lastName');
    
    		// set null to auto-generate password
    		$customer->setPassword('password');
    
    		
    		$customer->setForceConfirmed(true);
    
    		// save data
    		$customer->save();
    
    		// save customer address
    		// this is optional
    		// you can skip saving customer address while creating the customer
    		$customerAddress = $objectManager->get('MagentoCustomerModelAddressFactory')->create();
    		$customerAddress->setCustomerId($customer->getId())
    			->setFirstname('steve')
    			->setLastname('albini')
    			->setCountryId('US')
    			->setRegionId('12')
    			->setRegion('Florida')
    			->setPostcode('11003')
    			->setCity('Miami')
    			->setTelephone('111-222-4444')
    			->setFax('111-222-4444')
    			->setCompany('MageMonkeys')
    			->setStreet(array(
    				'0' => 'Your Customer Address 1', // compulsory
    				'1' => 'Your Customer Address 2' // optional
    			)) 
    			->setIsDefaultBilling('1')
    			->setIsDefaultShipping('1')
    			->setSaveInAddressBook('1');
    
    
    		try {
    			// save customer address
    			$customerAddress->save();
    		} catch (Exception $e) {
    			echo '<br>Cannot save customer address.';
    		}                
    		
    		// send welcome email to the customer
    		$customer->sendNewAccountEmail();
    
    		try {
            	$accountManagementInterface = $objectManager->get('MagentoCustomerApiAccountManagementInterface')->create();
                $accountManagementInterface->initiatePasswordReset($email,AccountManagement::EMAIL_RESET,$customer->getWebsiteId());
        	} 
            catch (NoSuchEntityException $e) {
    			// Do nothing, we don't want anyone to use this action to determine which email accounts are registered.
    		} catch (Exception $exception) {
    			echo '<br>Cannot send reset link email.';            
    		}
    
    	} catch (Exception $e) {
        	echo '<br>';
            echo $e->getMessage();        
        }
    }
    
    ?>

    Run this file on browser to create customer. Hope this article is useful.

    Magento 2: How to Add new custom fonts in your theme?

    If you want to add new custom fonts in your theme then follow below Instruction.

    Let’s say you need to add your font.woff file in your theme web/fonts folder, then you need to import that font in Magento, so you need to create new file _typography.less in your theme web/css/source/ folder.
    and add your fonts like below

    & when (@media-common = true) {
     .lib-font-face(
     @family-name: "Neue Plak W04 Regular",
     @font-path: '@{baseDir}fonts/65781df7-af4a-4a7e-8a89-83876affcd78',
     @font-weight: normal,
     @font-style: normal
     );
    
     .lib-font-face(
     @family-name: "font-family-name-here",
     @font-path: '@{baseDir}fonts/{your-woff-font-file-name-here}',
     @font-weight: normal,
     @font-style: normal
     );
    
     
    }

    Magento 2: How to remove postcode field in checkout?

    Today we are going to talk about how to remove the postcode field in checkout in Magento 2?

    The field is dynamically created from EAV attributes on the LayoutProcessor class.

    All we need to do is to set is_user_defined to 1 for the postcode eav_attribute. I recommend doing this via a setup resource, like this:

    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        /** @var MagentoCustomerSetupCustomerSetupFactory $customerSetup */
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
    
        $setup->startSetup();
    
        $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'postcode');
        $attribute->setIsUserDefined(1)->save();
    
        $attribute->save();
    }

    also, we need to remove validation for that, so we can direct set 0 to DB in eav_attribute table

    that’s it.

     

    Magento 2: How to customize existing attribute show in admin grid column via InstallData.php?

    Magento 2 create a custom attribute and save data

    Create a custom module and follow the below step

    Create InstallData.php file in VenderModulenameSetup

    <?php
    
    namespace VenderModulenameSetup;
    
    use MagentoFrameworkModuleSetupMigration;
    use MagentoFrameworkSetupInstallDataInterface;
    use MagentoFrameworkSetupModuleContextInterface;
    use MagentoFrameworkSetupModuleDataSetupInterface;
    
    class InstallData implements InstallDataInterface {
    
        private $customerSetupFactory;
    
        public function __construct(MagentoCustomerSetupCustomerSetupFactory $customerSetupFactory) {
            $this->customerSetupFactory = $customerSetupFactory;
        }
    
        public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
            $installer = $setup;
            $installer->startSetup();
            $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
            $entityTypeId = $customerSetup->getEntityTypeId(MagentoCustomerModelCustomer::ENTITY);
    
            $customerSetup->addAttribute(MagentoCustomerModelCustomer::ENTITY, "custom_attribute", array(
                "type" => "int",
                "backend" => "",
                "label" => "Custom Attribute",
                "input" => "select",
                "visible" => true,
                'source' => 'MagentoEavModelEntityAttributeSourceTable',
                "required" => false,
                "default" => "",
                "frontend" => "",
                "unique" => true,
                "note" => "",
            ));
    
            $employee = $customerSetup->getAttribute(MagentoCustomerModelCustomer::ENTITY, "custom_attribute");
    
            $employee = $customerSetup->getEavConfig()->getAttribute(MagentoCustomerModelCustomer::ENTITY, 'custom_attribute');
            $used_in_forms[] = "adminhtml_customer";
            $used_in_forms[] = "checkout_register";
            $used_in_forms[] = "customer_account_create";
            $used_in_forms[] = "customer_account_edit";
            $used_in_forms[] = "adminhtml_checkout";
            $employee->setData("used_in_forms", $used_in_forms)
                    ->setData("is_used_for_customer_segment", true)
                    ->setData("is_system", 0)
                    ->setData("is_user_defined", 1)
                    ->setData("is_visible", 1)
                    ->setData("is_used_in_grid", 1)
                    ->setData("is_visible_in_grid", 1)
                    ->setData("is_filterable_in_grid", 1)
                    ->setData("is_searchable_in_grid", 1)
                    ->setData("sort_order", 100);
            $employee->save();
    
            $installer->endSetup();
        }
    
    }