add block in observer magento 1.9Strategy for rewriting classesNeed to know whole Magento Design PatternsAdd block with observer eventMagento add custom options to cartMagento: Adding block from observer programmaticallyChanging value of Block function from observerMagento 1: use of observers and missing native core setter?Simple Observer not firing on eventAdd a block to a page with event observerobserver cms block

Is there a general effective method to solve Smullyan style Knights and Knaves problems? Is the truth table method the most appropriate one?

Is there a way to make it so the cursor is included when I prtscr key?

How can I get exact maximal value of this expression?

Can a wire having 610-670 THz (frequency of blue light) A.C frequency supply, generate blue light?

Does linking adjectives allow you to talk about multiple variations of something?

Would Brexit have gone ahead by now if Gina Miller had not forced the Government to involve Parliament?

Integrating an absolute function using Mathematica

Under what law can the U.S. arrest International Criminal Court (ICC) judges over war crimes probe?

Four-in-a-line Puzzle

How to prevent bad sectors?

Is there a public standard for 8 and 10 character grid locators?

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

Is it ok to put a subplot to a story that is never meant to contribute to the development of the main plot?

What is the 中 in ダウンロード中?

If a person had control of every single cell of their body, would they be able to transform into another creature?

Identify this in soil?

How does an ARM MCU run faster than the external crystal?

How many chess players are over 2500 Elo?

Plot twist where the antagonist wins

Why do airplanes use an axial flow jet engine instead of a more compact centrifugal jet engine?

Show differential operator is not bounded using definition of bounded operators

Riley Rebuses that Share a Common Theme

Is the first derivative operation on a signal a causal system?

Full backup on database creation



add block in observer magento 1.9


Strategy for rewriting classesNeed to know whole Magento Design PatternsAdd block with observer eventMagento add custom options to cartMagento: Adding block from observer programmaticallyChanging value of Block function from observerMagento 1: use of observers and missing native core setter?Simple Observer not firing on eventAdd a block to a page with event observerobserver cms block






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








0















I need to show labels(BACK ON STOCK) on product when they back to stock,
for this I have added a observer



 <global>
<events>
<catalog_product_save_commit_after>
<observers>
<Name_StockLabel_Model_Observer>
<type>singleton</type>
<class>Name_StockLabel_Model_Observer</class>
<method>backInStock</method>
</Name_StockLabel_Model_Observer>
</observers>
</catalog_product_save_commit_after>
</events>
</global>


and in observer am adding trying to add block



 public function backInStock(Varien_Event_Observer $observer)

$product = $observer->getEvent()->getProduct();
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
$stockItem = $product->getStockItem();
if ($stockItem->getCanBackInStock() && $stockItem->getQty() > $stockItem->getMinQty() && $stockItem->getIsInStock())

WANT TO ADD BLOCK HERE THAT WILL DISPLAY ON PRODUCT IN FRONTEND





Can anyone here advise me how can I add I block here










share|improve this question




























    0















    I need to show labels(BACK ON STOCK) on product when they back to stock,
    for this I have added a observer



     <global>
    <events>
    <catalog_product_save_commit_after>
    <observers>
    <Name_StockLabel_Model_Observer>
    <type>singleton</type>
    <class>Name_StockLabel_Model_Observer</class>
    <method>backInStock</method>
    </Name_StockLabel_Model_Observer>
    </observers>
    </catalog_product_save_commit_after>
    </events>
    </global>


    and in observer am adding trying to add block



     public function backInStock(Varien_Event_Observer $observer)

    $product = $observer->getEvent()->getProduct();
    $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
    $stockItem = $product->getStockItem();
    if ($stockItem->getCanBackInStock() && $stockItem->getQty() > $stockItem->getMinQty() && $stockItem->getIsInStock())

    WANT TO ADD BLOCK HERE THAT WILL DISPLAY ON PRODUCT IN FRONTEND





    Can anyone here advise me how can I add I block here










    share|improve this question
























      0












      0








      0








      I need to show labels(BACK ON STOCK) on product when they back to stock,
      for this I have added a observer



       <global>
      <events>
      <catalog_product_save_commit_after>
      <observers>
      <Name_StockLabel_Model_Observer>
      <type>singleton</type>
      <class>Name_StockLabel_Model_Observer</class>
      <method>backInStock</method>
      </Name_StockLabel_Model_Observer>
      </observers>
      </catalog_product_save_commit_after>
      </events>
      </global>


      and in observer am adding trying to add block



       public function backInStock(Varien_Event_Observer $observer)

      $product = $observer->getEvent()->getProduct();
      $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
      $stockItem = $product->getStockItem();
      if ($stockItem->getCanBackInStock() && $stockItem->getQty() > $stockItem->getMinQty() && $stockItem->getIsInStock())

      WANT TO ADD BLOCK HERE THAT WILL DISPLAY ON PRODUCT IN FRONTEND





      Can anyone here advise me how can I add I block here










      share|improve this question














      I need to show labels(BACK ON STOCK) on product when they back to stock,
      for this I have added a observer



       <global>
      <events>
      <catalog_product_save_commit_after>
      <observers>
      <Name_StockLabel_Model_Observer>
      <type>singleton</type>
      <class>Name_StockLabel_Model_Observer</class>
      <method>backInStock</method>
      </Name_StockLabel_Model_Observer>
      </observers>
      </catalog_product_save_commit_after>
      </events>
      </global>


      and in observer am adding trying to add block



       public function backInStock(Varien_Event_Observer $observer)

      $product = $observer->getEvent()->getProduct();
      $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
      $stockItem = $product->getStockItem();
      if ($stockItem->getCanBackInStock() && $stockItem->getQty() > $stockItem->getMinQty() && $stockItem->getIsInStock())

      WANT TO ADD BLOCK HERE THAT WILL DISPLAY ON PRODUCT IN FRONTEND





      Can anyone here advise me how can I add I block here







      magento-1.9 magento-1.8 event-observer blocks






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 21 at 11:42









      Daniel_12Daniel_12

      19510




      19510




















          2 Answers
          2






          active

          oldest

          votes


















          0














          You can use an alternative way:



          Create an attribute say back_on_stock with type Yes/No.



          Change you event form catalog_product_save_commit_after to catalog_product_save_before.



          Now in observer you can set this new attribute value in your if condition, like:



          $product->setBackOnStock(1);
          return $this;


          Now in Your phtml, you can check this attribute value and show label



          Hope above will help!






          share|improve this answer






























            0














            I don't think you need an observer for that.



            Just add a conditon in your template (catalog/product/view.phtml), like this:



            //$_product is Mage_Catalog_Model_Product object

            <?php if ($this->displayProductStockStatus() && $_product->isAvailable()) :?>
            Stock is back
            <?php //echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml()?>
            <?php endif;?>





            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%2f275456%2fadd-block-in-observer-magento-1-9%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 can use an alternative way:



              Create an attribute say back_on_stock with type Yes/No.



              Change you event form catalog_product_save_commit_after to catalog_product_save_before.



              Now in observer you can set this new attribute value in your if condition, like:



              $product->setBackOnStock(1);
              return $this;


              Now in Your phtml, you can check this attribute value and show label



              Hope above will help!






              share|improve this answer



























                0














                You can use an alternative way:



                Create an attribute say back_on_stock with type Yes/No.



                Change you event form catalog_product_save_commit_after to catalog_product_save_before.



                Now in observer you can set this new attribute value in your if condition, like:



                $product->setBackOnStock(1);
                return $this;


                Now in Your phtml, you can check this attribute value and show label



                Hope above will help!






                share|improve this answer

























                  0












                  0








                  0







                  You can use an alternative way:



                  Create an attribute say back_on_stock with type Yes/No.



                  Change you event form catalog_product_save_commit_after to catalog_product_save_before.



                  Now in observer you can set this new attribute value in your if condition, like:



                  $product->setBackOnStock(1);
                  return $this;


                  Now in Your phtml, you can check this attribute value and show label



                  Hope above will help!






                  share|improve this answer













                  You can use an alternative way:



                  Create an attribute say back_on_stock with type Yes/No.



                  Change you event form catalog_product_save_commit_after to catalog_product_save_before.



                  Now in observer you can set this new attribute value in your if condition, like:



                  $product->setBackOnStock(1);
                  return $this;


                  Now in Your phtml, you can check this attribute value and show label



                  Hope above will help!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 22 at 5:21









                  PawanPawan

                  2,3892721




                  2,3892721























                      0














                      I don't think you need an observer for that.



                      Just add a conditon in your template (catalog/product/view.phtml), like this:



                      //$_product is Mage_Catalog_Model_Product object

                      <?php if ($this->displayProductStockStatus() && $_product->isAvailable()) :?>
                      Stock is back
                      <?php //echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml()?>
                      <?php endif;?>





                      share|improve this answer



























                        0














                        I don't think you need an observer for that.



                        Just add a conditon in your template (catalog/product/view.phtml), like this:



                        //$_product is Mage_Catalog_Model_Product object

                        <?php if ($this->displayProductStockStatus() && $_product->isAvailable()) :?>
                        Stock is back
                        <?php //echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml()?>
                        <?php endif;?>





                        share|improve this answer

























                          0












                          0








                          0







                          I don't think you need an observer for that.



                          Just add a conditon in your template (catalog/product/view.phtml), like this:



                          //$_product is Mage_Catalog_Model_Product object

                          <?php if ($this->displayProductStockStatus() && $_product->isAvailable()) :?>
                          Stock is back
                          <?php //echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml()?>
                          <?php endif;?>





                          share|improve this answer













                          I don't think you need an observer for that.



                          Just add a conditon in your template (catalog/product/view.phtml), like this:



                          //$_product is Mage_Catalog_Model_Product object

                          <?php if ($this->displayProductStockStatus() && $_product->isAvailable()) :?>
                          Stock is back
                          <?php //echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml()?>
                          <?php endif;?>






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered May 22 at 5:33









                          Adarsh KhatriAdarsh Khatri

                          6,75511644




                          6,75511644



























                              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%2f275456%2fadd-block-in-observer-magento-1-9%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

                              Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                              Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                              Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림