I have a custom repository that sends off information to an ERP API.

In a console script I am accessing this repository that pulls data from a custom database table.

The rough outline looks like this:

     $pendingSends = $this->_erpPendingSendRepository->getByStatus('pending');

        foreach ($pendingSends as $pendingSend) {

// Do some stuff...
     $pendingSends = $this->_erpPendingSendRepository->getByStatus('complete');

        foreach ($pendingSends as $pendingSend) {

// Do some other stuff...

What is happening: The first $pendingSends is populated and the foreach works as expected, returns the correct results and processes fine. The second $pendingSends call returns an empty array and obviously nothing else happens. If I commend out the entire first block and just run the second block by itself, it works and returns results.

It seems that the combination of using both calls is preventing me from getting results in the subsequent calls to the erpPendingSendRepository.

Am I restricted to only using the _erpPendingSendRepository once per execution? I have tried various means to get new objects like

$this->_erpPendingSendRepository->create(); and new $this->_erpPendingSendRepository; but neither work.

Your Answer

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

Browse other questions tagged or ask your own question.