Showing results for 
Search instead for 
Did you mean: 

2.3.0: Update currency via cron

2.3.0: Update currency via cron

I'm a php veteran new to Magento 2 dev.


My goal is to integrate the action which is performed from the back end Stores | Currency rates | Import (but for a given currency Service) via Magento cron. I understand Magento cron needs a single method as an entry point specified by the "method" xml tag in crontab.xml.
I've also found refs to what the back end does in code here:
So it would seem I need to do what's in that back end via a single entry point, i.e. creating contexts, error checks, honoring transactions, security etc. Looking further this seems an awful lot of work - is there an API for it, has it already been done before, or am I missing something obvious?


The workaround I have now is dodgy. I call the external currency service API and update the values in directory_currency_rate directly, then flush the Magento cache. This works but doesn't feel right.