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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form