Temporarily disable reindexing The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraWhat indexes need to be reindexed for products to display correctly after stock is changed via script?Disabled product remains in catalog_category_product index (Magento Enterprise)Re-index error: Cannot initialize the indexer processMagento2 reindex from backendMagento 2: Is there a way to lock indexer programmatically?Magento2 reindex via cron jobMagento Flat Category Table contains incorrect data (even after reindexing)Magento 2 Reindexing is taking too long + Freezing website!”Undefined offset: 4” when reindexing “Search indexer”Magento2 catalog_product_category / catalog_category_product - Serialization failure Deadlock
Why doesn't a hydraulic lever violate conservation of energy?
What can I do if neighbor is blocking my solar panels intentionally?
Is an up-to-date browser secure on an out-of-date OS?
What is the role of 'For' here?
Is 'stolen' appropriate word?
Do working physicists consider Newtonian mechanics to be "falsified"?
Python - Fishing Simulator
Can withdrawing asylum be illegal?
ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?
Loose spokes after only a few rides
How did passengers keep warm on sail ships?
Drawing arrows from one table cell reference to another
Sub-subscripts in strings cause different spacings than subscripts
Can I visit the Trinity College (Cambridge) library and see some of their rare books
Could an empire control the whole planet with today's comunication methods?
How to determine omitted units in a publication
Accepted by European university, rejected by all American ones I applied to? Possible reasons?
My body leaves; my core can stay
What was the last x86 CPU that did not have the x87 floating-point unit built in?
How to type a long/em dash `—`
Can we generate random numbers using irrational numbers like π and e?
should truth entail possible truth
What information about me do stores get via my credit card?
Why not take a picture of a closer black hole?
Temporarily disable reindexing
The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraWhat indexes need to be reindexed for products to display correctly after stock is changed via script?Disabled product remains in catalog_category_product index (Magento Enterprise)Re-index error: Cannot initialize the indexer processMagento2 reindex from backendMagento 2: Is there a way to lock indexer programmatically?Magento2 reindex via cron jobMagento Flat Category Table contains incorrect data (even after reindexing)Magento 2 Reindexing is taking too long + Freezing website!”Undefined offset: 4” when reindexing “Search indexer”Magento2 catalog_product_category / catalog_category_product - Serialization failure Deadlock
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Scenario:
I'm running some script that changed some attribute values for some products.
Because of performance reasons, I split this into batches.
Problem:
But each time I'm done with a batch the reindexing starts for the products that belong to that batch. Indexes are set to "real time".
Desired result:
I want to disable the reindexing during the execution of my script.
But I don't want to set the reindex mode to 'schedule' because my script can take a while and any other operations done via admin need to still trigger the indexing for those specific products.
Main Question:
How can I tell magento at the start of my script "Don't reindex anything during this script, no matter on how the index mode is set!!" ?
Note: The script is a magento command executed either via cli or cron.
reindex magento-2.2.5
add a comment |
Scenario:
I'm running some script that changed some attribute values for some products.
Because of performance reasons, I split this into batches.
Problem:
But each time I'm done with a batch the reindexing starts for the products that belong to that batch. Indexes are set to "real time".
Desired result:
I want to disable the reindexing during the execution of my script.
But I don't want to set the reindex mode to 'schedule' because my script can take a while and any other operations done via admin need to still trigger the indexing for those specific products.
Main Question:
How can I tell magento at the start of my script "Don't reindex anything during this script, no matter on how the index mode is set!!" ?
Note: The script is a magento command executed either via cli or cron.
reindex magento-2.2.5
add a comment |
Scenario:
I'm running some script that changed some attribute values for some products.
Because of performance reasons, I split this into batches.
Problem:
But each time I'm done with a batch the reindexing starts for the products that belong to that batch. Indexes are set to "real time".
Desired result:
I want to disable the reindexing during the execution of my script.
But I don't want to set the reindex mode to 'schedule' because my script can take a while and any other operations done via admin need to still trigger the indexing for those specific products.
Main Question:
How can I tell magento at the start of my script "Don't reindex anything during this script, no matter on how the index mode is set!!" ?
Note: The script is a magento command executed either via cli or cron.
reindex magento-2.2.5
Scenario:
I'm running some script that changed some attribute values for some products.
Because of performance reasons, I split this into batches.
Problem:
But each time I'm done with a batch the reindexing starts for the products that belong to that batch. Indexes are set to "real time".
Desired result:
I want to disable the reindexing during the execution of my script.
But I don't want to set the reindex mode to 'schedule' because my script can take a while and any other operations done via admin need to still trigger the indexing for those specific products.
Main Question:
How can I tell magento at the start of my script "Don't reindex anything during this script, no matter on how the index mode is set!!" ?
Note: The script is a magento command executed either via cli or cron.
reindex magento-2.2.5
reindex magento-2.2.5
asked Sep 7 '18 at 13:02
Marius♦Marius
168k28324692
168k28324692
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Great question! In theory this is possible. Magento commands are based on Symfony. You could use SymfonyComponentFilesystemLockHandler
class to create a lock to your command.
Then have a plugin to the reindex manager, where you would check if your command is locked. If your command is locked then it means it's running therefore don't proceed to the reindexing etc.
Note: When your commands ends make sure to release it.
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within atry
&catch
block and have the catch as the fall back to unlock it. Have a look at these classesMagentoIndexerModelIndexer
andMagentoIndexerModelProcessor
for the plugin stuff.
– André Ferraz
Sep 11 '18 at 21:40
add a comment |
I ended up taking an approach that looks a bit dirty, but it does the job.
My script starts with this:
$this->registry->register('skip_indexing', true);
and ends with
$this->registry->unregister('skip_indexing');
where $this->registry
is an instance of MagentoFrameworkRegistry
.
and I've added an after
plugin for MagentoIndexerModelIndexer::isScheduled
to simulate that the indexer is set "on schedule".
public function afterIsScheduled(MagentoIndexerModelIndexer $subject, $result)
if ($this->registry->registry('skip_indexing'))
return true;
return $result;
Not proud of it, but it gets the job done.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f241326%2ftemporarily-disable-reindexing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Great question! In theory this is possible. Magento commands are based on Symfony. You could use SymfonyComponentFilesystemLockHandler
class to create a lock to your command.
Then have a plugin to the reindex manager, where you would check if your command is locked. If your command is locked then it means it's running therefore don't proceed to the reindexing etc.
Note: When your commands ends make sure to release it.
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within atry
&catch
block and have the catch as the fall back to unlock it. Have a look at these classesMagentoIndexerModelIndexer
andMagentoIndexerModelProcessor
for the plugin stuff.
– André Ferraz
Sep 11 '18 at 21:40
add a comment |
Great question! In theory this is possible. Magento commands are based on Symfony. You could use SymfonyComponentFilesystemLockHandler
class to create a lock to your command.
Then have a plugin to the reindex manager, where you would check if your command is locked. If your command is locked then it means it's running therefore don't proceed to the reindexing etc.
Note: When your commands ends make sure to release it.
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within atry
&catch
block and have the catch as the fall back to unlock it. Have a look at these classesMagentoIndexerModelIndexer
andMagentoIndexerModelProcessor
for the plugin stuff.
– André Ferraz
Sep 11 '18 at 21:40
add a comment |
Great question! In theory this is possible. Magento commands are based on Symfony. You could use SymfonyComponentFilesystemLockHandler
class to create a lock to your command.
Then have a plugin to the reindex manager, where you would check if your command is locked. If your command is locked then it means it's running therefore don't proceed to the reindexing etc.
Note: When your commands ends make sure to release it.
Great question! In theory this is possible. Magento commands are based on Symfony. You could use SymfonyComponentFilesystemLockHandler
class to create a lock to your command.
Then have a plugin to the reindex manager, where you would check if your command is locked. If your command is locked then it means it's running therefore don't proceed to the reindexing etc.
Note: When your commands ends make sure to release it.
answered Sep 7 '18 at 13:48
André FerrazAndré Ferraz
1,80711132
1,80711132
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within atry
&catch
block and have the catch as the fall back to unlock it. Have a look at these classesMagentoIndexerModelIndexer
andMagentoIndexerModelProcessor
for the plugin stuff.
– André Ferraz
Sep 11 '18 at 21:40
add a comment |
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within atry
&catch
block and have the catch as the fall back to unlock it. Have a look at these classesMagentoIndexerModelIndexer
andMagentoIndexerModelProcessor
for the plugin stuff.
– André Ferraz
Sep 11 '18 at 21:40
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
thanks for the idea. one drawback though. If my command crashes, then reindexing will not be triggered until I manually remove the lock. but I think I can overcome that by setting something in the registry when my command starts instead of using locks. and use that registry value in the plugin. could you explain more about pluginizing the reindex manager. What method should I pluginize from what class? What's the central point of triggering reindexing?
– Marius♦
Sep 7 '18 at 14:54
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within a
try
& catch
block and have the catch as the fall back to unlock it. Have a look at these classes MagentoIndexerModelIndexer
and MagentoIndexerModelProcessor
for the plugin stuff.– André Ferraz
Sep 11 '18 at 21:40
No worries. Using registry will also have the same effect if your command crashes. If you use PHP7, you can always wrap your command logic within a
try
& catch
block and have the catch as the fall back to unlock it. Have a look at these classes MagentoIndexerModelIndexer
and MagentoIndexerModelProcessor
for the plugin stuff.– André Ferraz
Sep 11 '18 at 21:40
add a comment |
I ended up taking an approach that looks a bit dirty, but it does the job.
My script starts with this:
$this->registry->register('skip_indexing', true);
and ends with
$this->registry->unregister('skip_indexing');
where $this->registry
is an instance of MagentoFrameworkRegistry
.
and I've added an after
plugin for MagentoIndexerModelIndexer::isScheduled
to simulate that the indexer is set "on schedule".
public function afterIsScheduled(MagentoIndexerModelIndexer $subject, $result)
if ($this->registry->registry('skip_indexing'))
return true;
return $result;
Not proud of it, but it gets the job done.
add a comment |
I ended up taking an approach that looks a bit dirty, but it does the job.
My script starts with this:
$this->registry->register('skip_indexing', true);
and ends with
$this->registry->unregister('skip_indexing');
where $this->registry
is an instance of MagentoFrameworkRegistry
.
and I've added an after
plugin for MagentoIndexerModelIndexer::isScheduled
to simulate that the indexer is set "on schedule".
public function afterIsScheduled(MagentoIndexerModelIndexer $subject, $result)
if ($this->registry->registry('skip_indexing'))
return true;
return $result;
Not proud of it, but it gets the job done.
add a comment |
I ended up taking an approach that looks a bit dirty, but it does the job.
My script starts with this:
$this->registry->register('skip_indexing', true);
and ends with
$this->registry->unregister('skip_indexing');
where $this->registry
is an instance of MagentoFrameworkRegistry
.
and I've added an after
plugin for MagentoIndexerModelIndexer::isScheduled
to simulate that the indexer is set "on schedule".
public function afterIsScheduled(MagentoIndexerModelIndexer $subject, $result)
if ($this->registry->registry('skip_indexing'))
return true;
return $result;
Not proud of it, but it gets the job done.
I ended up taking an approach that looks a bit dirty, but it does the job.
My script starts with this:
$this->registry->register('skip_indexing', true);
and ends with
$this->registry->unregister('skip_indexing');
where $this->registry
is an instance of MagentoFrameworkRegistry
.
and I've added an after
plugin for MagentoIndexerModelIndexer::isScheduled
to simulate that the indexer is set "on schedule".
public function afterIsScheduled(MagentoIndexerModelIndexer $subject, $result)
if ($this->registry->registry('skip_indexing'))
return true;
return $result;
Not proud of it, but it gets the job done.
answered yesterday
Marius♦Marius
168k28324692
168k28324692
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f241326%2ftemporarily-disable-reindexing%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown