Let’s initiate a discussion!!
By using the below code, we can get customer group multi-select option with the help of system.xml.
We can get all Customer group by system.xml in System -> Configuration Section of admin.
Create system.xml file,
Path, app/code/Magemonkeys/Customer/etc/adminhtml/system.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <system> <section id="catalog"> <group id="customer_group" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <field id="list" translate="label" type="multiselect" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="0"> <label>Customer Groups</label> <source_model>Magemonkeys\Customer\Model\Adminhtml\System\Config\Source\Customer\Group</source_model> <can_be_empty>1</can_be_empty> </field> </group> </section> </system> </config> |
You need to get all customer group using a Model file
Create Group.php file,
Path, app/code/Magemonkeys/Customer/Model/Adminhtml/System/Config/Source/Customer/Group.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php namespace Magemonkeys\Customer\Model\Adminhtml\System\Config\Source\Customer; class Group implements \Magento\Framework\Option\ArrayInterface { public function __construct(\Magento\Customer\Model\ResourceModel\Group\CollectionFactory $groupCollectionFactory) { $this->_groupCollectionFactory = $groupCollectionFactory; } /** * @return array */ public function toOptionArray() { if (!$this->_options) { $this->_options = $this->_groupCollectionFactory->create()->loadData()->toOptionArray(); } return $this->_options; } } |
Clear Cache using php bin/magento cache:flush
[crayon-6421745accfad000653783/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.