I have checked the similar post: Magento2.2 getCollection from Factory deprecated
But I still don't find the answer of it. I am calling getCollection()
function, and PHPStorm saying that this function is deprecated.
$this->_myCollectionFactory->create()->getCollection()
where $this->_myCollectionFactory
is the instance of my collection factory which is \Vendor\Module\Model\ModuleFactory
.
And this is my ModuleFactory
class code
<?php
namespace Vendor\Module\Model;
class ModuleFactory
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
*/
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->_objectManager = $objectManager;
}
/**
* Create new country model
*
* @param array $arguments
* @return \Magento\Directory\Model\Country
*/
public function create(array $arguments = [])
{
return $this->_objectManager->create('Vendor\Module\Model\Module', $arguments, false);
}
}
My question is, what is the alternate of getCollection if it is deprecated?