-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disabling Scout sync during Feed Me Import #180
Comments
@mgburns Yep, agreed this is annoying. Adding to my list! |
@timkelty would you accept a PR for this? Need this as well. Most likely will go with the same approach as Blitz (a batch mode flag) |
Hey @lenvanessen! Sure, happy to review a PR for this if you can write it up 👍 |
Just chipping in that if your indices are limited to just commerce elements run on the import you could set: scout.php config: 'sync' => false, feedme event Event::on(
Process::class,
Process::EVENT_AFTER_PROCESS_FEED,
function(FeedProcessEvent $event) {
try {
Craft::$app->runAction('scout/index/refresh');
} catch (InvalidRouteException | Exception $e) {
Craft::error($e->getMessage(), __METHOD__);
throw new Exception($e->getMessage());
}
}
); |
Has anyone made any progress in turning off Algolia sync events during a FeedMe import or deferring until the end? Disabling the sync outright prevents general entries that are updated by Control Panel users being synchronised automatically, so it's not an ideal solution, you can hook into various events with FeedMe to trigger imports instead, but I was wondering if anyone had thoughts of a solution while keeping the original sync option enabled. |
@jamesmacwhite I've done it using the a listener on the queue:
if (Craft::$app->getRequest()->isConsoleRequest) {
|
@lenvanessen Interesting solution, I'll take a look. You can technically disable the queue jobs with I am however a fan of triggering these at the end of a successful feed import, leveraging feed events, because it will probably also speed up the import process. Do you still have sync enabled with this event before push code, so general entry saves in the CP aren't impacted. That's my main concern, the feed imports are one thing, I still want the automatic sync behaviour to work when entries not imported via FeedMe are modified. |
@jamesmacwhite, there are a couple of solutions you can go with, for one, you can temporary change the .env. You can see an example in the SetupController from Craft, where they set certain variables. So in your case, you could set the
And then using the feed-me imports
And once the import is done:
Or, if you don't want to touch the
And then make the code I previously shared like this:
And then after the import is done, release it
|
@lenvanessen Thanks. This is an interesting solution! My concern around using a mutex lock would be you could potentially trigger a mutex lock error if Feed Me processing would be happening to be occurring while another entry that's connected to Algolia events (not part of FeedMe) tries to be updated at the same time, but I'll have to do some testing. |
I'm trying to figure out how I can temporarily disable Algolia sync during Feed Me imports.
I know it can be done manually via the settings page if we omit it from
config/scout.php
but we're hiding those in prod so I'm trying to figure out a way to do it programmatically. I see that Feed Me fires events before / after feed processing but I'm not sure what I would do on the Scout end to make this work.The text was updated successfully, but these errors were encountered: