$object method is working for me but i want to convert this collection in factory method.

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$productCollection = $objectManager->create('Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection');
  • 1
    What about using DI to inject the method directly in your constructor ? Commented Sep 6, 2016 at 7:33

1 Answer 1


you can try with below method, There are many core files for frontend and backend module they used Group\CollectionFactory method you can get direction from that file.

You can refer frontend core file from here,


If you want to modify into backend, you can look at below core files,


Inside your php file,

protected $_groupCollectionFactory;
public function __construct(
        \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory
    ) {
        $this->_groupCollectionFactory = $groupCollectionFactory;
public function getGroupCollection()
        return $this->_groupCollectionFactory->create()->load();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.