I have an orders/customers import based on API which has been created on a channel. I have noticed that when an API call returns an empty array then the script jump to onFinish() in my listener import method where supposed to update last sync date, but when an API call is empty then the script doesn’t update this date. Why is that? There is no any PHP condition to prevent it. This part of code should be always done.
Hi Adam, Can you share code of the listener you created and the declaration in services.yml to understand to what event it subscribed and that subscription made right?
There is nothing tricky. There is something in ORO CRM what prevents to update this last sync date when API request is empty, but I need to update this date. It’s crucial.
This reply was modified 5 years, 12 months ago by Adam.
This reply was modified 5 years, 12 months ago by Adam.
This reply was modified 5 years, 12 months ago by Adam.
There are no errors in /app/logs/, nothing in there. It does not make any sense. I have tested couple different scenarios and if an API call doesn’t return anything then CRM doesn’t update last sync date. If there are orders in the API call ORO updates date.
This reply was modified 5 years, 12 months ago by Adam.
Don’t think so, as computeChangeSet is internal doctrine thing and it should be used only on doctrine listeners. Also everything should be already flushed so event called out of transaction there is no reason to work directly with UnitOfWork
You can debug message consumer, starting from this method \Oro\Bundle\IntegrationBundle\Async\SyncIntegrationProcessor::process to see whats happening on API returing empty result. I recently recorded a video how to debug message consumer, this may help
But it also do a lot of other work, like dispatching events, so calling ‘computeChangeSet’ outside of doctrine event listener is not safe as it will not trigger listeners to this or related entities and broke some other staff like inserting new related entities.
So it’s recommended to replace computeChangeSet with flush back, but don’t pass arguments to it.
Just change
PHP
1
2
$carManager->persist($car);
$carManager->flush($car);
to
PHP
1
$carManager->flush();
This reply was modified 5 years, 12 months ago by Andrey Yatsenko.
This reply was modified 5 years, 12 months ago by Andrey Yatsenko.
This reply was modified 5 years, 7 months ago by Mike Luskavets.
It was triggered but the changes made to the series were not persisted to the database. Since you do not have access to the entity manager in these callbacks, there is furthermore no way to force a persist/flush from here.
We collect cookie information with a goal to provide you with the best user experience. By using this website, you agree to our use of cookies. Read Oro Inc.’s Cookie policy.
We collect cookie information with a goal to provide you with the best user experience. By using this website, you agree to our use of cookies. Read Oro Inc.’s Cookie policy.