Thursday 23 May 2019

All Customer Groups in Admin system config multiselect

<?php

namespace Namespace\ModuleName\Model\System\Config\Source\Dropdown;

class Frontend implements \Magento\Framework\Option\ArrayInterface {

    protected $_groupCollectionFactory;
    public function __construct(\Magento\Customer\Model\ResourceModel\Group\CollectionFactory $groupCollectionFactory)
    {
        $this->_groupCollectionFactory = $groupCollectionFactory;
    }
   
    public function toOptionArray()
    {
        $this->_options = array();
        if (!$this->_options) {
            $this->_options = $this->_groupCollectionFactory->create()->loadData()->toOptionArray();
        }
        return $this->_options;
    }

}

No comments:

Post a Comment

Product Collection with out of stock and In Stock in Magento 2

Product collection with out of stock and In stock. use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; $collection = $th...