Couldn't reindex stock of one item programmatically Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento reindex from command line, still having timeout errorMagento 1.8 reindex allFix error “There was a problem with reindexing process.” or “Cannot initialize the indexer process.”Reindex doesn't work (but shows success message)Custom indexer on Magento2Magento 2 Reindex failed on customer gridTable missing after index:resetMagento Reindex Issue on Product AttributesMagento 2.2.2 SSH Reindex locked processes help

Did any compiler fully use 80-bit floating point?

Special flights

How many time has Arya actually used Needle?

GDP with Intermediate Production

One-one communication

Why is a lens darker than other ones when applying the same settings?

Is CEO the "profession" with the most psychopaths?

What is the difference between a "ranged attack" and a "ranged weapon attack"?

The test team as an enemy of development? And how can this be avoided?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Monty Hall Problem-Probability Paradox

Flight departed from the gate 5 min before scheduled departure time. Refund options

Printing attributes of selection in ArcPy?

Where is the Next Backup Size entry on iOS 12?

Trying to understand entropy as a novice in thermodynamics

License to disallow distribution in closed source software, but allow exceptions made by owner?

Why not send Voyager 3 and 4 following up the paths taken by Voyager 1 and 2 to re-transmit signals of later as they fly away from Earth?

Tips to organize LaTeX presentations for a semester

Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?

Random body shuffle every night—can we still function?

Why are vacuum tubes still used in amateur radios?

Universal covering space of the real projective line?

Is there hard evidence that the grant peer review system performs significantly better than random?

Project Euler #1 in C++



Couldn't reindex stock of one item programmatically



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento reindex from command line, still having timeout errorMagento 1.8 reindex allFix error “There was a problem with reindexing process.” or “Cannot initialize the indexer process.”Reindex doesn't work (but shows success message)Custom indexer on Magento2Magento 2 Reindex failed on customer gridTable missing after index:resetMagento Reindex Issue on Product AttributesMagento 2.2.2 SSH Reindex locked processes help



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to reindex one product only programmatically:



$product = Mage::getModel('catalog/product')->load($_productId);
$product->setForceReindexRequired(true);
Mage::getSingleton('index/indexer')->processEntityAction(
$product,
Mage_CatalogInventory_Model_Stock_Item::ENTITY,
Mage_Index_Model_Event::TYPE_SAVE
);


However, nothing is inserted to cataloginventory_stock_status_idx table. But if I reindex using command line:



php indexer.php --reindex cataloginventory_stock


The table is populated.










share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.





















    1















    I'm trying to reindex one product only programmatically:



    $product = Mage::getModel('catalog/product')->load($_productId);
    $product->setForceReindexRequired(true);
    Mage::getSingleton('index/indexer')->processEntityAction(
    $product,
    Mage_CatalogInventory_Model_Stock_Item::ENTITY,
    Mage_Index_Model_Event::TYPE_SAVE
    );


    However, nothing is inserted to cataloginventory_stock_status_idx table. But if I reindex using command line:



    php indexer.php --reindex cataloginventory_stock


    The table is populated.










    share|improve this question
















    bumped to the homepage by Community 2 days ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      1












      1








      1


      1






      I'm trying to reindex one product only programmatically:



      $product = Mage::getModel('catalog/product')->load($_productId);
      $product->setForceReindexRequired(true);
      Mage::getSingleton('index/indexer')->processEntityAction(
      $product,
      Mage_CatalogInventory_Model_Stock_Item::ENTITY,
      Mage_Index_Model_Event::TYPE_SAVE
      );


      However, nothing is inserted to cataloginventory_stock_status_idx table. But if I reindex using command line:



      php indexer.php --reindex cataloginventory_stock


      The table is populated.










      share|improve this question
















      I'm trying to reindex one product only programmatically:



      $product = Mage::getModel('catalog/product')->load($_productId);
      $product->setForceReindexRequired(true);
      Mage::getSingleton('index/indexer')->processEntityAction(
      $product,
      Mage_CatalogInventory_Model_Stock_Item::ENTITY,
      Mage_Index_Model_Event::TYPE_SAVE
      );


      However, nothing is inserted to cataloginventory_stock_status_idx table. But if I reindex using command line:



      php indexer.php --reindex cataloginventory_stock


      The table is populated.







      php magento-1 reindex indexing indexer






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 2 '17 at 12:38









      sv3n

      10k62557




      10k62557










      asked May 7 '15 at 9:55









      user1240207user1240207

      77421031




      77421031





      bumped to the homepage by Community 2 days ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 2 days ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          2 Answers
          2






          active

          oldest

          votes


















          0














          You should try with:



          Mage::getModel('catalogsearch/fulltext')->getResource()->rebuildIndex( 1, (int)$product->getId());





          share|improve this answer
































            0














            Try



            $process = Mage::getSingleton('index/indexer')->getProcessByCode($code);
            $process->reindexAll();


            Or if you want to do Mage::getSingleton('index/indexer')->processEntityAction your event needs to be registered and processed like in: app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php



            protected function _registerEvent(Mage_Index_Model_Event $event)



            which already has case Mage_CatalogInventory_Model_Stock_Item::ENTITY



            you just need to add something like: $event->addNewData('cataloginventory_stock_reindex_all', true); to that case



            and method



            protected function _processEvent(Mage_Index_Model_Event $event)


            already has:



            if (!empty($data['cataloginventory_stock_reindex_all'])) 
            $this->reindexAll();



            Don't forget to extend this and don't write code in core.






            share|improve this answer

























            • Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

              – user1240207
              May 8 '15 at 0:29











            • @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

              – Magarusu
              May 13 '15 at 10:55











            • Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

              – Magarusu
              May 18 '15 at 9:08












            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%2f67007%2fcouldnt-reindex-stock-of-one-item-programmatically%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









            0














            You should try with:



            Mage::getModel('catalogsearch/fulltext')->getResource()->rebuildIndex( 1, (int)$product->getId());





            share|improve this answer





























              0














              You should try with:



              Mage::getModel('catalogsearch/fulltext')->getResource()->rebuildIndex( 1, (int)$product->getId());





              share|improve this answer



























                0












                0








                0







                You should try with:



                Mage::getModel('catalogsearch/fulltext')->getResource()->rebuildIndex( 1, (int)$product->getId());





                share|improve this answer















                You should try with:



                Mage::getModel('catalogsearch/fulltext')->getResource()->rebuildIndex( 1, (int)$product->getId());






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 10 '17 at 0:35









                Khoa TruongDinh

                22.3k64187




                22.3k64187










                answered Feb 9 '17 at 20:40









                duttymanduttyman

                712




                712























                    0














                    Try



                    $process = Mage::getSingleton('index/indexer')->getProcessByCode($code);
                    $process->reindexAll();


                    Or if you want to do Mage::getSingleton('index/indexer')->processEntityAction your event needs to be registered and processed like in: app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php



                    protected function _registerEvent(Mage_Index_Model_Event $event)



                    which already has case Mage_CatalogInventory_Model_Stock_Item::ENTITY



                    you just need to add something like: $event->addNewData('cataloginventory_stock_reindex_all', true); to that case



                    and method



                    protected function _processEvent(Mage_Index_Model_Event $event)


                    already has:



                    if (!empty($data['cataloginventory_stock_reindex_all'])) 
                    $this->reindexAll();



                    Don't forget to extend this and don't write code in core.






                    share|improve this answer

























                    • Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

                      – user1240207
                      May 8 '15 at 0:29











                    • @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

                      – Magarusu
                      May 13 '15 at 10:55











                    • Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

                      – Magarusu
                      May 18 '15 at 9:08
















                    0














                    Try



                    $process = Mage::getSingleton('index/indexer')->getProcessByCode($code);
                    $process->reindexAll();


                    Or if you want to do Mage::getSingleton('index/indexer')->processEntityAction your event needs to be registered and processed like in: app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php



                    protected function _registerEvent(Mage_Index_Model_Event $event)



                    which already has case Mage_CatalogInventory_Model_Stock_Item::ENTITY



                    you just need to add something like: $event->addNewData('cataloginventory_stock_reindex_all', true); to that case



                    and method



                    protected function _processEvent(Mage_Index_Model_Event $event)


                    already has:



                    if (!empty($data['cataloginventory_stock_reindex_all'])) 
                    $this->reindexAll();



                    Don't forget to extend this and don't write code in core.






                    share|improve this answer

























                    • Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

                      – user1240207
                      May 8 '15 at 0:29











                    • @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

                      – Magarusu
                      May 13 '15 at 10:55











                    • Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

                      – Magarusu
                      May 18 '15 at 9:08














                    0












                    0








                    0







                    Try



                    $process = Mage::getSingleton('index/indexer')->getProcessByCode($code);
                    $process->reindexAll();


                    Or if you want to do Mage::getSingleton('index/indexer')->processEntityAction your event needs to be registered and processed like in: app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php



                    protected function _registerEvent(Mage_Index_Model_Event $event)



                    which already has case Mage_CatalogInventory_Model_Stock_Item::ENTITY



                    you just need to add something like: $event->addNewData('cataloginventory_stock_reindex_all', true); to that case



                    and method



                    protected function _processEvent(Mage_Index_Model_Event $event)


                    already has:



                    if (!empty($data['cataloginventory_stock_reindex_all'])) 
                    $this->reindexAll();



                    Don't forget to extend this and don't write code in core.






                    share|improve this answer















                    Try



                    $process = Mage::getSingleton('index/indexer')->getProcessByCode($code);
                    $process->reindexAll();


                    Or if you want to do Mage::getSingleton('index/indexer')->processEntityAction your event needs to be registered and processed like in: app/code/core/Mage/CatalogInventory/Model/Indexer/Stock.php



                    protected function _registerEvent(Mage_Index_Model_Event $event)



                    which already has case Mage_CatalogInventory_Model_Stock_Item::ENTITY



                    you just need to add something like: $event->addNewData('cataloginventory_stock_reindex_all', true); to that case



                    and method



                    protected function _processEvent(Mage_Index_Model_Event $event)


                    already has:



                    if (!empty($data['cataloginventory_stock_reindex_all'])) 
                    $this->reindexAll();



                    Don't forget to extend this and don't write code in core.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 2 '17 at 12:39









                    sv3n

                    10k62557




                    10k62557










                    answered May 7 '15 at 10:24









                    MagarusuMagarusu

                    2681310




                    2681310












                    • Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

                      – user1240207
                      May 8 '15 at 0:29











                    • @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

                      – Magarusu
                      May 13 '15 at 10:55











                    • Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

                      – Magarusu
                      May 18 '15 at 9:08


















                    • Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

                      – user1240207
                      May 8 '15 at 0:29











                    • @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

                      – Magarusu
                      May 13 '15 at 10:55











                    • Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

                      – Magarusu
                      May 18 '15 at 9:08

















                    Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

                    – user1240207
                    May 8 '15 at 0:29





                    Doesn't $process->reindexAll(); will reindexall? How about for a single item only?

                    – user1240207
                    May 8 '15 at 0:29













                    @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

                    – Magarusu
                    May 13 '15 at 10:55





                    @user1240207 take a look over this but I don't think single product reindex is available in newer magento versions.

                    – Magarusu
                    May 13 '15 at 10:55













                    Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

                    – Magarusu
                    May 18 '15 at 9:08






                    Some indexers have methods that will reindex by product id. Ex: Mage::getSingleton('catalog/url')->refreshProductRewrite($productId); Mage::getSingleton('catalogsearch/fulltext')->rebuildIndex(null, $productId);

                    – Magarusu
                    May 18 '15 at 9:08


















                    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%2f67007%2fcouldnt-reindex-stock-of-one-item-programmatically%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?