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;








2















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.










share|improve this question




























    2















    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.










    share|improve this question
























      2












      2








      2


      2






      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 7 '18 at 13:02









      MariusMarius

      168k28324692




      168k28324692




















          2 Answers
          2






          active

          oldest

          votes


















          1














          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.






          share|improve this answer























          • 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



















          1














          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.






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            1














            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.






            share|improve this answer























            • 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
















            1














            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.






            share|improve this answer























            • 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














            1












            1








            1







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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 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


















            • 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

















            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














            1














            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.






            share|improve this answer



























              1














              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.






              share|improve this answer

























                1












                1








                1







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                MariusMarius

                168k28324692




                168k28324692



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?