1

I have installed this brazilian shipping module - https://bitbucket.org/igor_lm/igorludgero_correiosofflinem2 - then I got the error:

  PHP Fatal error:  Uncaught Error: Call to undefined method Igorludgero\Correios\Model\ResourceModel\Cotacoes::getCollection() in /magento221/vendor/igorludgero/correios/Helper/Data.php:276
  Stack trace:
  #0 /magento221/vendor/igorludgero/correios/Cron/UpdateTracks.php(24): Igorludgero\Correios\Helper\Data->updateOfflineTracks()
  #1 [internal function]: Igorludgero\Correios\Cron\UpdateTracks->execute(Object(Magento\Cron\Model\Schedule))
  #2 /magento221/app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php(292): call_user_func_array(Array, Array)
  #3 /magento221/app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php(228): Magento\Cron\Observer\ProcessCronQueueObserver->_runJob(1511677080, 1511677144, Array, Object(Magento\Cron\Model\Schedule), 'igorludgero_cor...')
  #4 /magento221/lib/internal/Magento/Framework/Event/Invoker/Invoker in /magento221/vendor/igorludgero/correios/Helper/Data.php on line 276

This does not seem to be a coding issue since it works for others, I also had opportunity to talk with its autor. So I was wondering it could be related to php config. I found out similar php fatal errors on google regarding short_open_tag set to off but that was not the case. It doesn't look like max_execution_time problem either.

Does anyone know which configuration could possibly cause such call to undefined method?

Magento 2.2.1
PHP 7.0.25
MySQL 5.6.33
Ubuntu 14.04.5 LTS

Thank you!

2

I have download the module and find out that getCollection method is not exists in the Igorludgero\Correios\Model\ResourceModel\Cotacoes class. Seem like a bug in the module. Usually getCollection method used in the regular models, not in the resource model. Try to contact the author of this module, or fix it by yourself - change this method:

public function __construct(\Magento\Catalog\Model\ProductRepository $productRepository,
                            \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
                            \Igorludgero\Correios\Model\ResourceModel\CotacoesFactory $cotacoesFactory)
{
    $this->_storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
    $this->_scopeConfig = $scopeConfig;
    $this->_productRepository = $productRepository;
    $this->_cotacoesFactory = $cotacoesFactory;
}

to this one:

public function __construct(\Magento\Catalog\Model\ProductRepository $productRepository,
                            \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
                            \Igorludgero\Correios\Model\CotacoesFactory $cotacoesFactory)
{
    $this->_storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
    $this->_scopeConfig = $scopeConfig;
    $this->_productRepository = $productRepository;
    $this->_cotacoesFactory = $cotacoesFactory;
}

I think this should work, because we just changed the resource model factory to the simple model factory. In the all places this factory is used as a regular model factory.

This changes exists since the 77473019194767fd482c8b8d47874a12596a234e commit, when the regular model was changed to the resource model factory, and I dont imagine how it can work for the other users without errors after this "update".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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