Environment:
Magneto EE 2.3.4 PHP 7.2.23-1 OS Ubuntu 16.04
Error:
Type Error occurred when creating object: Custom\Module\Model\ResourceModel\Module\Grid\Collection\Interceptor
Situation:
I am trying to add and admin Grid in Magento 2 Custom Module... It's working fine on Developer Mode
but I am getting this error in Production Mode
Here is My Code Of Custom\Module\Model\ResourceModel\Module\Grid\Collection.php
<?PHP
use Custom\Module\Model\ResourceModel\Module\Collection as CustomCollection;
/**
* Class Grid COllection
*/
class Collection extends CustomCollection implements \Magento\Framework\Api\Search\SearchResultInterface
{
private $_aggregations;
private $storeManager;
public function __construct(
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
$mainTable,
$eventPrefix,
$eventObject,
$resourceModel,
$model = 'Magento\Framework\View\Element\UiComponent\DataProvider\Document',
$connection = null,
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
) {
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$storeManager,
$connection,
$resource
);
$this->_eventPrefix = $eventPrefix;
$this->_eventObject = $eventObject;
$this->storeManager = $storeManager;
$this->_init($model, $resourceModel);
$this->setMainTable($mainTable);
}
/**
* @return \Magento\Framework\Search\AggregationInterface
*/
public function getAggregations()
{
return $this->_aggregations;
}
/**
* @param \Magento\Framework\Search\AggregationInterface $aggregations
* @return $this
*/
public function setAggregations($aggregations)
{
$this->_aggregations = $aggregations;
}
/**
* Retrieve all ids for collection
* Backward compatibility with EAV collection
*
* @param int $limit
* @param int $offset
* @return array
*/
public function getAllIds($limit = null, $offset = null)
{
return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
}
/**
* Get search criteria.
*
* @return \Magento\Framework\Api\SearchCriteriaInterface|null
*/
public function getSearchCriteria()
{
return null;
}
/**
* Set search criteria.
*
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
{
return $this;
}
/**
* Get total count.
*
* @return int
*/
public function getTotalCount()
{
return $this->getSize();
}
/**
* Set total count.
*
* @param int $totalCount
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setTotalCount($totalCount)
{
return $this;
}
/**
* Set items list.
*
* @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setItems(array $items = null)
{
return $this;
}
}
I have Tried by removing var/
and generated/
folder and run php bin/magento setup:di:compile
Collection
fromCustomCollection
but in myCustomCollection
there was no any object asStoreManagerInterface
so I removed in injectedStoreManagerInterface
class fromCollection
constructor and my issue was resolved – User 69 Jun 22 '20 at 13:03