How to override order sales model in magento 1.9












0














I have stuck with this. I am trying to override sales/ order model _saveafter function with my custom module. I have the following code



appcodelocalRktSalesNewetcconfig.xml



<modules>
<Rkt_SalesNew>
<version>0.0.1</version>
</Rkt_SalesNew>
</modules>
<global>
<models>
<salesnew>
<rewrite>
<method>Rkt_SalesNew_Model_Order</method>
</rewrite>
</salesnew>
</models>
</global>


appcodelocalRktSalesNewModelOrder.php



class Rkt_SalesNew_Model_Order extends Mage_Sales_Model_Abstract


{



   protected function _afterSave()
{
if (null !== $this->_addresses) {
$this->_addresses->save();
$billingAddress = $this->getBillingAddress();
$attributesForSave = array();
if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
$this->setBillingAddressId($billingAddress->getId());
$attributesForSave = 'billing_address_id';
}

$shippingAddress = $this->getShippingAddress();
if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
$this->setShippingAddressId($shippingAddress->getId());
$attributesForSave = 'shipping_address_id';
}

if (!empty($attributesForSave)) {
$this->_getResource()->saveAttribute($this, $attributesForSave);
}

}
if (null !== $this->_items) {
$this->_items->save();
}
if (null !== $this->_payments) {
$this->_payments->save();
}
if (null !== $this->_statusHistory) {
$this->_statusHistory->save();
}
foreach ($this->getRelatedObjects() as $object) {
$object->save();
}
return parent::_afterSave();
}

}


I am unable to override this function. Can any one please help me out.










share|improve this question





























    0














    I have stuck with this. I am trying to override sales/ order model _saveafter function with my custom module. I have the following code



    appcodelocalRktSalesNewetcconfig.xml



    <modules>
    <Rkt_SalesNew>
    <version>0.0.1</version>
    </Rkt_SalesNew>
    </modules>
    <global>
    <models>
    <salesnew>
    <rewrite>
    <method>Rkt_SalesNew_Model_Order</method>
    </rewrite>
    </salesnew>
    </models>
    </global>


    appcodelocalRktSalesNewModelOrder.php



    class Rkt_SalesNew_Model_Order extends Mage_Sales_Model_Abstract


    {



       protected function _afterSave()
    {
    if (null !== $this->_addresses) {
    $this->_addresses->save();
    $billingAddress = $this->getBillingAddress();
    $attributesForSave = array();
    if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
    $this->setBillingAddressId($billingAddress->getId());
    $attributesForSave = 'billing_address_id';
    }

    $shippingAddress = $this->getShippingAddress();
    if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
    $this->setShippingAddressId($shippingAddress->getId());
    $attributesForSave = 'shipping_address_id';
    }

    if (!empty($attributesForSave)) {
    $this->_getResource()->saveAttribute($this, $attributesForSave);
    }

    }
    if (null !== $this->_items) {
    $this->_items->save();
    }
    if (null !== $this->_payments) {
    $this->_payments->save();
    }
    if (null !== $this->_statusHistory) {
    $this->_statusHistory->save();
    }
    foreach ($this->getRelatedObjects() as $object) {
    $object->save();
    }
    return parent::_afterSave();
    }

    }


    I am unable to override this function. Can any one please help me out.










    share|improve this question



























      0












      0








      0







      I have stuck with this. I am trying to override sales/ order model _saveafter function with my custom module. I have the following code



      appcodelocalRktSalesNewetcconfig.xml



      <modules>
      <Rkt_SalesNew>
      <version>0.0.1</version>
      </Rkt_SalesNew>
      </modules>
      <global>
      <models>
      <salesnew>
      <rewrite>
      <method>Rkt_SalesNew_Model_Order</method>
      </rewrite>
      </salesnew>
      </models>
      </global>


      appcodelocalRktSalesNewModelOrder.php



      class Rkt_SalesNew_Model_Order extends Mage_Sales_Model_Abstract


      {



         protected function _afterSave()
      {
      if (null !== $this->_addresses) {
      $this->_addresses->save();
      $billingAddress = $this->getBillingAddress();
      $attributesForSave = array();
      if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
      $this->setBillingAddressId($billingAddress->getId());
      $attributesForSave = 'billing_address_id';
      }

      $shippingAddress = $this->getShippingAddress();
      if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
      $this->setShippingAddressId($shippingAddress->getId());
      $attributesForSave = 'shipping_address_id';
      }

      if (!empty($attributesForSave)) {
      $this->_getResource()->saveAttribute($this, $attributesForSave);
      }

      }
      if (null !== $this->_items) {
      $this->_items->save();
      }
      if (null !== $this->_payments) {
      $this->_payments->save();
      }
      if (null !== $this->_statusHistory) {
      $this->_statusHistory->save();
      }
      foreach ($this->getRelatedObjects() as $object) {
      $object->save();
      }
      return parent::_afterSave();
      }

      }


      I am unable to override this function. Can any one please help me out.










      share|improve this question















      I have stuck with this. I am trying to override sales/ order model _saveafter function with my custom module. I have the following code



      appcodelocalRktSalesNewetcconfig.xml



      <modules>
      <Rkt_SalesNew>
      <version>0.0.1</version>
      </Rkt_SalesNew>
      </modules>
      <global>
      <models>
      <salesnew>
      <rewrite>
      <method>Rkt_SalesNew_Model_Order</method>
      </rewrite>
      </salesnew>
      </models>
      </global>


      appcodelocalRktSalesNewModelOrder.php



      class Rkt_SalesNew_Model_Order extends Mage_Sales_Model_Abstract


      {



         protected function _afterSave()
      {
      if (null !== $this->_addresses) {
      $this->_addresses->save();
      $billingAddress = $this->getBillingAddress();
      $attributesForSave = array();
      if ($billingAddress && $this->getBillingAddressId() != $billingAddress->getId()) {
      $this->setBillingAddressId($billingAddress->getId());
      $attributesForSave = 'billing_address_id';
      }

      $shippingAddress = $this->getShippingAddress();
      if ($shippingAddress && $this->getShippigAddressId() != $shippingAddress->getId()) {
      $this->setShippingAddressId($shippingAddress->getId());
      $attributesForSave = 'shipping_address_id';
      }

      if (!empty($attributesForSave)) {
      $this->_getResource()->saveAttribute($this, $attributesForSave);
      }

      }
      if (null !== $this->_items) {
      $this->_items->save();
      }
      if (null !== $this->_payments) {
      $this->_payments->save();
      }
      if (null !== $this->_statusHistory) {
      $this->_statusHistory->save();
      }
      foreach ($this->getRelatedObjects() as $object) {
      $object->save();
      }
      return parent::_afterSave();
      }

      }


      I am unable to override this function. Can any one please help me out.







      magento-1.9 php xml






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday

























      asked yesterday









      teja123

      12




      12






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can rewrite abstract class just need to copy Mage_Sales_Model_Abstract file to community or local pool.



          And after that, you can edit that file in that scope. autoload functionality will load files from following orders:

          1. lib

          2. core

          3. community

          4. local



          app > code > community > Mage > Sales > Model > Abstract.php






          share|improve this answer























          • Thanks for the perfect reply
            – teja123
            yesterday










          • Please click on up arrow near my answer if it was useful for you.
            – Anton
            19 hours ago











          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%2f256734%2fhow-to-override-order-sales-model-in-magento-1-9%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














          You can rewrite abstract class just need to copy Mage_Sales_Model_Abstract file to community or local pool.



          And after that, you can edit that file in that scope. autoload functionality will load files from following orders:

          1. lib

          2. core

          3. community

          4. local



          app > code > community > Mage > Sales > Model > Abstract.php






          share|improve this answer























          • Thanks for the perfect reply
            – teja123
            yesterday










          • Please click on up arrow near my answer if it was useful for you.
            – Anton
            19 hours ago
















          0














          You can rewrite abstract class just need to copy Mage_Sales_Model_Abstract file to community or local pool.



          And after that, you can edit that file in that scope. autoload functionality will load files from following orders:

          1. lib

          2. core

          3. community

          4. local



          app > code > community > Mage > Sales > Model > Abstract.php






          share|improve this answer























          • Thanks for the perfect reply
            – teja123
            yesterday










          • Please click on up arrow near my answer if it was useful for you.
            – Anton
            19 hours ago














          0












          0








          0






          You can rewrite abstract class just need to copy Mage_Sales_Model_Abstract file to community or local pool.



          And after that, you can edit that file in that scope. autoload functionality will load files from following orders:

          1. lib

          2. core

          3. community

          4. local



          app > code > community > Mage > Sales > Model > Abstract.php






          share|improve this answer














          You can rewrite abstract class just need to copy Mage_Sales_Model_Abstract file to community or local pool.



          And after that, you can edit that file in that scope. autoload functionality will load files from following orders:

          1. lib

          2. core

          3. community

          4. local



          app > code > community > Mage > Sales > Model > Abstract.php







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday









          Himanshu

          704419




          704419










          answered yesterday









          Anton

          361




          361












          • Thanks for the perfect reply
            – teja123
            yesterday










          • Please click on up arrow near my answer if it was useful for you.
            – Anton
            19 hours ago


















          • Thanks for the perfect reply
            – teja123
            yesterday










          • Please click on up arrow near my answer if it was useful for you.
            – Anton
            19 hours ago
















          Thanks for the perfect reply
          – teja123
          yesterday




          Thanks for the perfect reply
          – teja123
          yesterday












          Please click on up arrow near my answer if it was useful for you.
          – Anton
          19 hours ago




          Please click on up arrow near my answer if it was useful for you.
          – Anton
          19 hours ago


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f256734%2fhow-to-override-order-sales-model-in-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

          1300-talet

          1300-talet

          Display a custom attribute below product name in the front-end Magento 1.9.3.8