0

I use a custom model with it's own Factory.

In my helper in the construct

public function __construct(

\Company\Module\Model\ResourceModel\Communication\CollectionFactory $communicationFactory
){

$this->_communicationFactory = $communicationFactory;

return parent::__construct($context);

  }

I created the first registry and saved it with

$communication = $this->_communicationFactory->create();

And after adding some data

$communication->save();

By the time I created the first one, there was no problem, everything ok. But when I try to create another one the instance of the model has already loaded the data from the first one, and I get this error:

PHP Fatal error:  Uncaught Error: Call to undefined method Company\ModuleName\Model\ResourceModel\Communication\Collection::setStatus() in /Users/Username/projects/htdocs/example.com/htdocs/extensions/company/module-modulename/Helper/Data.php:414

Anyone knows why?

1
  • can you please paste your entire helper code for better understanding? Aug 24, 2017 at 14:22

1 Answer 1

0

I have solved it by changing the path in the construct

This is how it should be done:

\Company\ModuleName\Model\CommunicationFactory                          $communicationFactory,

Before I was getting a instance of the collection, now I'm getting an instance of the single object.

Your Answer

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

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