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

Putting Ant-Man on house arrest

Can this water damage be explained by lack of gutters and grading issues?

When does Bran Stark remember Jamie pushing him?

What could prevent concentrated local exploration?

BV functions and wave equation

How is an IPA symbol that lacks a name (e.g. ɲ) called?

Is Bran literally the world's memory?

Kepler's 3rd law: ratios don't fit data

Can I take recommendation from someone I met at a conference?

Assertions In A Mock Callout Test

Why does BitLocker not use RSA?

Why do C and C++ allow the expression (int) + 4*5?

Is my guitar’s action too high?

Why aren't these two solutions equivalent? Combinatorics problem

How to create a command for the "strange m" symbol in latex?

How to charge percentage of transaction cost?

Why not use the yoke to control yaw, as well as pitch and roll?

Pointing to problems without suggesting solutions

How do I overlay a PNG over two videos (one video overlays another) in one command using FFmpeg?

How to break 信じようとしていただけかも知れない into separate parts?

Are there any AGPL-style licences that require source code modifications to be public?

Why these surprising proportionalities of integrals involving odd zeta values?

What is the evidence that custom checks in Northern Ireland are going to result in violence?

Why is ArcGIS Pro not symbolizing my entire range of values?



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






























    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


























      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

      77921031




      77921031




















          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

                    Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

                    БиармияSxpst500bh2ntaf! 3h2r