0

I'm looking for a way to trigger the hook entry_submission_ready on every entry that the Solspace Importer imports. I have another extension that, upon entry_submission_ready, manipulates entry data. In this case, the other extension takes a plaintext address, geocodes it, and inserts the geocoded address back into the entry data.

Importer disables extension hook triggers when it imports, and as the comments explain: (../importer/content_types/importer.content_type.channel_entries/content_type.channel_entries.php:starting-line 627)

// --------------------------------------------
//  Disable Extensions
// - Extension can cause ALL sorts of headaches
// when using the EE Channel Entries API.
// --------------------------------------------

$allow_extensions = ee()->config->item('allow_extensions');

ee()->config->config['allow_extensions'] = 'n';

// -------------------------------------
//  This is a fix for Extensions->active_hook
//  returning boolean true even when extensions
//  are disabled. EE Bug reported.
//  This should be fixed in EE 2.9.1/2.10.0.
// -------------------------------------

$old_ext = ee()->extensions->extensions;

ee()->extensions->extensions = array();

The extension triggers cause headaches. And so they do: the geocode extension throws an error if I allow extensions to remain enabled during the import. I could get around this by writing my own extension that is triggered after the importer is completely finished, and having that extension loop over all recently added entries and just triggering the entry_submission_ready hook. However, Solspace Importer does not have any (documented or otherwise) hooks for when it's completely finished.

This leaves me with my data imported, but having to go to Edit each individual entry, and just submit an unchanged Edit form so it triggers entry_submission_ready and the geocoder extension does it's thing. I'd love a better programmatic way to handle this, as getting the data import for this project right is about 90% of the work (it's a glorified blog project for a client with tons of csv data). Any help or suggestions would be awesome! Thanks!

0

I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. http://support.solspace.com/support/discussions

If enabling extensions in Importer is then causing issues, it could be that the geocode extension (maybe also others?) doesn't play nice with the native EE Channel Entries API and its hook. It would be worth bringing this up with the extension developer if that's possible. Another idea could be to disable the geocode hook in the exp_extensions table just for during your import, so that your extension is the only one using the hook (less add-ons using a hook, less problems).

2
  • Thanks Solspace. I bumped someone else's feature request. I'll see if it's just the geocoder that's breaking it, but I'm going to hack in/enable a post importer hook for my project, and hope to see this feature included in future versions. Any other clever solutions for the time being would be welcomed. – jrothafer Nov 13 '14 at 14:05
  • Update- it was the geocoder. It wasn't using some hooks in an intelligent manner (entry_submission_start hook function was using POST data to pre-validate/modify an ENTRIES data, that belongs in entry_submission_ready). I added one small hook at the end of importer and got things working; however, I now have this issue: expressionengine.stackexchange.com/questions/26693/… All my data imports, including matrix data, and the geocode works, I just get a sudden barage of warnings after import. I'd bump that question if I had the reputation to do so. – jrothafer Nov 14 '14 at 13:50

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.