How to save custom value in sales_flat_order_grid on order placement?Magento 1.7 Redirect on review_product_view PageEditing existing column in orders gridobserver method sales_order_place_after not executinghow to get value of custom attribute of customer in sales_orde_ place_afterHow magento stores date in created_at fieldHow to save custom attribute in Magento moduleCan't get order object in sales_order_place_after observer method in multi-shippingSimple Observer not firing on eventMagento 1.9 : sales_flat_order and sales_flat_order_grid tables are not updatingEvents when the order is placed is not firing

Is it OK to use personal email ID for faculty job applications or should we use (current) institute's ID

Why isn't aluminium involved in biological processes?

Why don't commercial aircraft adopt a slightly more seaplane-like design to allow safer ditching in case of emergency?

Is there a standard way of referencing line numbers in a draft?

Did Voldemort kill his father before finding out about Horcruxes?

Cauchy reals and Dedekind reals satisfy "the same mathematical theorems"

Why did Steve Rogers choose this character in Endgame?

Can a pizza stone be fixed after soap has been used to clean it?

Why do so many pure math PhD students drop out or leave academia, compared to applied mathematics PhDs?

What happens if there is no space for entry stamp in the passport for US visa?

What "fuel more powerful than anything the West (had) in stock" put Laika in orbit aboard Sputnik 2?

What made Windows ME so crash-prone?

What is the word for "event executor"?

What are "full piece" and "half piece" in chess?

Is this artwork (used in a video game) real?

Why are road bikes (not time trial bikes) used in many triathlons?

Will a contempt of congress lawsuit actually reach the merits?

Manually select/unselect lines before forwarding to stdout

What details should I consider before agreeing for part of my salary to be 'retained' by employer?

Did 007 exist before James Bond?

Can you perfectly wrap a cube with this blocky shape?

Why should I cook the flour first when making bechamel sauce?

Why is my calculation for added length of coax for a double cross antenna different to everyone else's?

Finding the package which provides a given command



How to save custom value in sales_flat_order_grid on order placement?


Magento 1.7 Redirect on review_product_view PageEditing existing column in orders gridobserver method sales_order_place_after not executinghow to get value of custom attribute of customer in sales_orde_ place_afterHow magento stores date in created_at fieldHow to save custom attribute in Magento moduleCan't get order object in sales_order_place_after observer method in multi-shippingSimple Observer not firing on eventMagento 1.9 : sales_flat_order and sales_flat_order_grid tables are not updatingEvents when the order is placed is not firing






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








1















I have to save the stock of each product when an order is placed.



The custom module is Tbb_StockRegistrar. It creates a column called order_stock_message in sales_flat_order and sales_flat_order_grid tables. This is OK.



Then, the observer should save the value in those tables (Not working):



config.xml



<events>
<sales_order_place_after>
<observers>
<checkout_submit_all_after_handler>
<type>model</type>
<class>Tbb_StockRegistrar_Model_Observer</class>
<method>save</method>
</checkout_submit_all_after_handler>
</observers>
</sales_order_place_after>
</events>


Observer.php



<?php

class Tbb_StockRegistrar_Model_Observer


public function save($observer)

$order = $observer->getEvent()->getOrder();
$stocks = $this->saveComment($order);
$this->saveOrderGridColumn($order, $stocks);


protected function saveComment($order)

# Save the stocks as an order comment (Working)


protected function saveOrderGridColumn($order, $stocks)

$stockMessage = ... // It populates the message to be saved

$orderModel = Mage::getModel('sales/order')->load($order->getId());
$orderModel->setOrderStockMessage($stockMessage);
$orderModel->save();







The method setOrderStockMessage is not saving anything. Why?



Plus, how can I store the same value in sales_flat_order_grid table on sales_order_place_after observer?










share|improve this question






























    1















    I have to save the stock of each product when an order is placed.



    The custom module is Tbb_StockRegistrar. It creates a column called order_stock_message in sales_flat_order and sales_flat_order_grid tables. This is OK.



    Then, the observer should save the value in those tables (Not working):



    config.xml



    <events>
    <sales_order_place_after>
    <observers>
    <checkout_submit_all_after_handler>
    <type>model</type>
    <class>Tbb_StockRegistrar_Model_Observer</class>
    <method>save</method>
    </checkout_submit_all_after_handler>
    </observers>
    </sales_order_place_after>
    </events>


    Observer.php



    <?php

    class Tbb_StockRegistrar_Model_Observer


    public function save($observer)

    $order = $observer->getEvent()->getOrder();
    $stocks = $this->saveComment($order);
    $this->saveOrderGridColumn($order, $stocks);


    protected function saveComment($order)

    # Save the stocks as an order comment (Working)


    protected function saveOrderGridColumn($order, $stocks)

    $stockMessage = ... // It populates the message to be saved

    $orderModel = Mage::getModel('sales/order')->load($order->getId());
    $orderModel->setOrderStockMessage($stockMessage);
    $orderModel->save();







    The method setOrderStockMessage is not saving anything. Why?



    Plus, how can I store the same value in sales_flat_order_grid table on sales_order_place_after observer?










    share|improve this question


























      1












      1








      1








      I have to save the stock of each product when an order is placed.



      The custom module is Tbb_StockRegistrar. It creates a column called order_stock_message in sales_flat_order and sales_flat_order_grid tables. This is OK.



      Then, the observer should save the value in those tables (Not working):



      config.xml



      <events>
      <sales_order_place_after>
      <observers>
      <checkout_submit_all_after_handler>
      <type>model</type>
      <class>Tbb_StockRegistrar_Model_Observer</class>
      <method>save</method>
      </checkout_submit_all_after_handler>
      </observers>
      </sales_order_place_after>
      </events>


      Observer.php



      <?php

      class Tbb_StockRegistrar_Model_Observer


      public function save($observer)

      $order = $observer->getEvent()->getOrder();
      $stocks = $this->saveComment($order);
      $this->saveOrderGridColumn($order, $stocks);


      protected function saveComment($order)

      # Save the stocks as an order comment (Working)


      protected function saveOrderGridColumn($order, $stocks)

      $stockMessage = ... // It populates the message to be saved

      $orderModel = Mage::getModel('sales/order')->load($order->getId());
      $orderModel->setOrderStockMessage($stockMessage);
      $orderModel->save();







      The method setOrderStockMessage is not saving anything. Why?



      Plus, how can I store the same value in sales_flat_order_grid table on sales_order_place_after observer?










      share|improve this question
















      I have to save the stock of each product when an order is placed.



      The custom module is Tbb_StockRegistrar. It creates a column called order_stock_message in sales_flat_order and sales_flat_order_grid tables. This is OK.



      Then, the observer should save the value in those tables (Not working):



      config.xml



      <events>
      <sales_order_place_after>
      <observers>
      <checkout_submit_all_after_handler>
      <type>model</type>
      <class>Tbb_StockRegistrar_Model_Observer</class>
      <method>save</method>
      </checkout_submit_all_after_handler>
      </observers>
      </sales_order_place_after>
      </events>


      Observer.php



      <?php

      class Tbb_StockRegistrar_Model_Observer


      public function save($observer)

      $order = $observer->getEvent()->getOrder();
      $stocks = $this->saveComment($order);
      $this->saveOrderGridColumn($order, $stocks);


      protected function saveComment($order)

      # Save the stocks as an order comment (Working)


      protected function saveOrderGridColumn($order, $stocks)

      $stockMessage = ... // It populates the message to be saved

      $orderModel = Mage::getModel('sales/order')->load($order->getId());
      $orderModel->setOrderStockMessage($stockMessage);
      $orderModel->save();







      The method setOrderStockMessage is not saving anything. Why?



      Plus, how can I store the same value in sales_flat_order_grid table on sales_order_place_after observer?







      magento-1.9 php event-observer sales-order






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 8 at 14:19









      Abdul Pathan

      3507 bronze badges




      3507 bronze badges










      asked Jul 8 at 13:35









      Alejandro AraujoAlejandro Araujo

      83 bronze badges




      83 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Need to change as per below code config.xml



          <events>
          <sales_order_place_after>
          <observers>
          <Tbb_StockRegistrar_Model_Observer>
          <type>model</type>
          <class>Tbb_StockRegistrar_Model_Observer</class>
          <method>save</method>
          </Tbb_StockRegistrar_Model_Observer>
          </observers>
          </sales_order_place_after>
          </events>





          share|improve this answer

























          • Worked! TYVM!!!

            – Alejandro Araujo
            Jul 8 at 15:53













          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%2f281225%2fhow-to-save-custom-value-in-sales-flat-order-grid-on-order-placement%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Need to change as per below code config.xml



          <events>
          <sales_order_place_after>
          <observers>
          <Tbb_StockRegistrar_Model_Observer>
          <type>model</type>
          <class>Tbb_StockRegistrar_Model_Observer</class>
          <method>save</method>
          </Tbb_StockRegistrar_Model_Observer>
          </observers>
          </sales_order_place_after>
          </events>





          share|improve this answer

























          • Worked! TYVM!!!

            – Alejandro Araujo
            Jul 8 at 15:53















          0














          Need to change as per below code config.xml



          <events>
          <sales_order_place_after>
          <observers>
          <Tbb_StockRegistrar_Model_Observer>
          <type>model</type>
          <class>Tbb_StockRegistrar_Model_Observer</class>
          <method>save</method>
          </Tbb_StockRegistrar_Model_Observer>
          </observers>
          </sales_order_place_after>
          </events>





          share|improve this answer

























          • Worked! TYVM!!!

            – Alejandro Araujo
            Jul 8 at 15:53













          0












          0








          0







          Need to change as per below code config.xml



          <events>
          <sales_order_place_after>
          <observers>
          <Tbb_StockRegistrar_Model_Observer>
          <type>model</type>
          <class>Tbb_StockRegistrar_Model_Observer</class>
          <method>save</method>
          </Tbb_StockRegistrar_Model_Observer>
          </observers>
          </sales_order_place_after>
          </events>





          share|improve this answer















          Need to change as per below code config.xml



          <events>
          <sales_order_place_after>
          <observers>
          <Tbb_StockRegistrar_Model_Observer>
          <type>model</type>
          <class>Tbb_StockRegistrar_Model_Observer</class>
          <method>save</method>
          </Tbb_StockRegistrar_Model_Observer>
          </observers>
          </sales_order_place_after>
          </events>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 9 at 7:08

























          answered Jul 8 at 15:22









          MSAMSA

          1,4023 silver badges17 bronze badges




          1,4023 silver badges17 bronze badges












          • Worked! TYVM!!!

            – Alejandro Araujo
            Jul 8 at 15:53

















          • Worked! TYVM!!!

            – Alejandro Araujo
            Jul 8 at 15:53
















          Worked! TYVM!!!

          – Alejandro Araujo
          Jul 8 at 15:53





          Worked! TYVM!!!

          – Alejandro Araujo
          Jul 8 at 15:53

















          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%2f281225%2fhow-to-save-custom-value-in-sales-flat-order-grid-on-order-placement%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