checkout_cart_save_after is not workingWe're open extension not working[Solved]Cannot override...

Injecting creativity into a cookbook

Which one of these password policies is more secure?

Can an insurance company drop you after receiving a bill and refusing to pay?

Why would space fleets be aligned?

Incorporating research and background: How much is too much?

Using only 1s, make 29 with the minimum number of digits

Word or phrase for showing great skill at something WITHOUT formal training in it

How can my powered armor quickly replace its ceramic plates?

Citing paywalled articles accessed via illegal web sharing

CREATE ASSEMBLY System.DirectoryServices.AccountManagement.dll without enabling TRUSTWORTHY

awk + sum all numbers

Writing a character who is going through a civilizing process without overdoing it?

Why do neural networks need so many training examples to perform?

Are there any modern advantages of a fire piston?

Could a phylactery of a lich be a mirror or does it have to be a box?

How to say "Brexit" in Latin?

Advice for a new journal editor

Dilemma of explaining to interviewer that he is the reason for declining second interview

Why do stocks necessarily drop during a recession?

Eww, those bytes are gross

Can a hotel cancel a confirmed reservation?

Why isn't there a non-conducting core wire for high-frequency coil applications

Publishing research using outdated methods

Can making a creature unable to attack after it has been assigned as an attacker remove it from combat?



checkout_cart_save_after is not working


We're open extension not working[Solved]Cannot override Pdf/Total/Default.php modelcheckout steps are not workingMagento extension not working in my layoutgetAddToCartUrl not workingExtension not working correctlyWYSING editor not workingDiscount code not working on mobile in Magento 1.9Magento Product More Views Not working in Responsive Mobile ThemeShow Shipping cost in checkout page not in cart page













1















The little project is to export all items (sku and quantity) of an order using the Magento (1.9.3.2) events.



My NvM2MfExport.xml in /app/etc/modules:



<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<NvM2MfExport>
<active>true</active>
<codePool>community</codePool>
<depends>
<Mage_Checkout />
</depends>
</NvM2MfExport>
</modules>
</config>


My config.xml in /app/code/community/NV/M2MfExport/etc:



<?xml version="1.0"?>
<config>

<modules>
<NvM2MfExport>
<version>1.0.0</version>
</NvM2MfExport>
</modules>

<global>
<models>
<nvm2mfexport>
<class>Nv_Export_Model</class>
</nvm2mfexport>
</models>
<events>
<checkout_cart_save_after>
<observers>
<nvm2mfexport>
<class>nvm2mfexport/observer</class>
<method>orderExport</method>
</nvm2mfexport>
</observers>
</checkout_cart_save_after>
</events>
</global>

</config>


My Observer.php in /app/code/community/Nv/M2MfExport/Model:



<?php

class Nv_Export_Model_Observer
{
public function orderExport($observer)
{
//require_once '../app/Mage.php';
//Mage::app();

// Übergebenes Quote und Order Objekt holen
$order = $observer->getEvent()->getOrder();
$quote = $observer->getEvent()->getQuote();

// Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
if ($quote->getDistributorEmail())
{
// Lieferadresse als Text formatiert holen
$shipTo = $order->getShippingAddress()->format('text');
$itemsTxt = "Itemsn-----------------------n";

foreach ($order->getAllVisibleItems() as $item)
$itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

$mail = Mage::getModel('core/email')
->setFromEmail('~@~.de')
->setSubject('Neue Bestellung')
->setToEmail('~@~.de')
->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
->send();
}

/*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doen";
fwrite($myfile, $txt);
$txt = "Jane Doen";
fwrite($myfile, $txt);
fclose($myfile);*/
}
}


The module is shown in the admin and enabled.



After a successfully order submit inside the backend (admin) I expected getting an email with some information. But nothing - not even a system log entry (logging is set on).



I also changed something in my php file that should result in throwing an error and another log entry. But nothing too. That's why I suggest that my Observer.php will not be called.










share|improve this question





























    1















    The little project is to export all items (sku and quantity) of an order using the Magento (1.9.3.2) events.



    My NvM2MfExport.xml in /app/etc/modules:



    <?xml version="1.0" encoding="UTF-8"?>
    <config>
    <modules>
    <NvM2MfExport>
    <active>true</active>
    <codePool>community</codePool>
    <depends>
    <Mage_Checkout />
    </depends>
    </NvM2MfExport>
    </modules>
    </config>


    My config.xml in /app/code/community/NV/M2MfExport/etc:



    <?xml version="1.0"?>
    <config>

    <modules>
    <NvM2MfExport>
    <version>1.0.0</version>
    </NvM2MfExport>
    </modules>

    <global>
    <models>
    <nvm2mfexport>
    <class>Nv_Export_Model</class>
    </nvm2mfexport>
    </models>
    <events>
    <checkout_cart_save_after>
    <observers>
    <nvm2mfexport>
    <class>nvm2mfexport/observer</class>
    <method>orderExport</method>
    </nvm2mfexport>
    </observers>
    </checkout_cart_save_after>
    </events>
    </global>

    </config>


    My Observer.php in /app/code/community/Nv/M2MfExport/Model:



    <?php

    class Nv_Export_Model_Observer
    {
    public function orderExport($observer)
    {
    //require_once '../app/Mage.php';
    //Mage::app();

    // Übergebenes Quote und Order Objekt holen
    $order = $observer->getEvent()->getOrder();
    $quote = $observer->getEvent()->getQuote();

    // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
    if ($quote->getDistributorEmail())
    {
    // Lieferadresse als Text formatiert holen
    $shipTo = $order->getShippingAddress()->format('text');
    $itemsTxt = "Itemsn-----------------------n";

    foreach ($order->getAllVisibleItems() as $item)
    $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

    $mail = Mage::getModel('core/email')
    ->setFromEmail('~@~.de')
    ->setSubject('Neue Bestellung')
    ->setToEmail('~@~.de')
    ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
    ->send();
    }

    /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
    $txt = "John Doen";
    fwrite($myfile, $txt);
    $txt = "Jane Doen";
    fwrite($myfile, $txt);
    fclose($myfile);*/
    }
    }


    The module is shown in the admin and enabled.



    After a successfully order submit inside the backend (admin) I expected getting an email with some information. But nothing - not even a system log entry (logging is set on).



    I also changed something in my php file that should result in throwing an error and another log entry. But nothing too. That's why I suggest that my Observer.php will not be called.










    share|improve this question



























      1












      1








      1








      The little project is to export all items (sku and quantity) of an order using the Magento (1.9.3.2) events.



      My NvM2MfExport.xml in /app/etc/modules:



      <?xml version="1.0" encoding="UTF-8"?>
      <config>
      <modules>
      <NvM2MfExport>
      <active>true</active>
      <codePool>community</codePool>
      <depends>
      <Mage_Checkout />
      </depends>
      </NvM2MfExport>
      </modules>
      </config>


      My config.xml in /app/code/community/NV/M2MfExport/etc:



      <?xml version="1.0"?>
      <config>

      <modules>
      <NvM2MfExport>
      <version>1.0.0</version>
      </NvM2MfExport>
      </modules>

      <global>
      <models>
      <nvm2mfexport>
      <class>Nv_Export_Model</class>
      </nvm2mfexport>
      </models>
      <events>
      <checkout_cart_save_after>
      <observers>
      <nvm2mfexport>
      <class>nvm2mfexport/observer</class>
      <method>orderExport</method>
      </nvm2mfexport>
      </observers>
      </checkout_cart_save_after>
      </events>
      </global>

      </config>


      My Observer.php in /app/code/community/Nv/M2MfExport/Model:



      <?php

      class Nv_Export_Model_Observer
      {
      public function orderExport($observer)
      {
      //require_once '../app/Mage.php';
      //Mage::app();

      // Übergebenes Quote und Order Objekt holen
      $order = $observer->getEvent()->getOrder();
      $quote = $observer->getEvent()->getQuote();

      // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
      if ($quote->getDistributorEmail())
      {
      // Lieferadresse als Text formatiert holen
      $shipTo = $order->getShippingAddress()->format('text');
      $itemsTxt = "Itemsn-----------------------n";

      foreach ($order->getAllVisibleItems() as $item)
      $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

      $mail = Mage::getModel('core/email')
      ->setFromEmail('~@~.de')
      ->setSubject('Neue Bestellung')
      ->setToEmail('~@~.de')
      ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
      ->send();
      }

      /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
      $txt = "John Doen";
      fwrite($myfile, $txt);
      $txt = "Jane Doen";
      fwrite($myfile, $txt);
      fclose($myfile);*/
      }
      }


      The module is shown in the admin and enabled.



      After a successfully order submit inside the backend (admin) I expected getting an email with some information. But nothing - not even a system log entry (logging is set on).



      I also changed something in my php file that should result in throwing an error and another log entry. But nothing too. That's why I suggest that my Observer.php will not be called.










      share|improve this question
















      The little project is to export all items (sku and quantity) of an order using the Magento (1.9.3.2) events.



      My NvM2MfExport.xml in /app/etc/modules:



      <?xml version="1.0" encoding="UTF-8"?>
      <config>
      <modules>
      <NvM2MfExport>
      <active>true</active>
      <codePool>community</codePool>
      <depends>
      <Mage_Checkout />
      </depends>
      </NvM2MfExport>
      </modules>
      </config>


      My config.xml in /app/code/community/NV/M2MfExport/etc:



      <?xml version="1.0"?>
      <config>

      <modules>
      <NvM2MfExport>
      <version>1.0.0</version>
      </NvM2MfExport>
      </modules>

      <global>
      <models>
      <nvm2mfexport>
      <class>Nv_Export_Model</class>
      </nvm2mfexport>
      </models>
      <events>
      <checkout_cart_save_after>
      <observers>
      <nvm2mfexport>
      <class>nvm2mfexport/observer</class>
      <method>orderExport</method>
      </nvm2mfexport>
      </observers>
      </checkout_cart_save_after>
      </events>
      </global>

      </config>


      My Observer.php in /app/code/community/Nv/M2MfExport/Model:



      <?php

      class Nv_Export_Model_Observer
      {
      public function orderExport($observer)
      {
      //require_once '../app/Mage.php';
      //Mage::app();

      // Übergebenes Quote und Order Objekt holen
      $order = $observer->getEvent()->getOrder();
      $quote = $observer->getEvent()->getQuote();

      // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
      if ($quote->getDistributorEmail())
      {
      // Lieferadresse als Text formatiert holen
      $shipTo = $order->getShippingAddress()->format('text');
      $itemsTxt = "Itemsn-----------------------n";

      foreach ($order->getAllVisibleItems() as $item)
      $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

      $mail = Mage::getModel('core/email')
      ->setFromEmail('~@~.de')
      ->setSubject('Neue Bestellung')
      ->setToEmail('~@~.de')
      ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
      ->send();
      }

      /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
      $txt = "John Doen";
      fwrite($myfile, $txt);
      $txt = "Jane Doen";
      fwrite($myfile, $txt);
      fclose($myfile);*/
      }
      }


      The module is shown in the admin and enabled.



      After a successfully order submit inside the backend (admin) I expected getting an email with some information. But nothing - not even a system log entry (logging is set on).



      I also changed something in my php file that should result in throwing an error and another log entry. But nothing too. That's why I suggest that my Observer.php will not be called.







      checkout extensions magento-1.9.3.2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 7 mins ago









      Teja Bhagavan Kollepara

      2,96341847




      2,96341847










      asked Apr 27 '17 at 13:33









      SebastianSebastian

      63




      63






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You need to update some of the names.



          Rename NvM2MfExport.xml to Nv_M2MfExport.xml and add below code



          <?xml version="1.0" encoding="UTF-8"?>
          <config>
          <modules>
          <Nv_M2MfExport>
          <active>true</active>
          <codePool>community</codePool>
          <depends>
          <Mage_Checkout />
          </depends>
          </Nv_M2MfExport>
          </modules>
          </config>


          Update your config.xml



          <?xml version="1.0"?>
          <config>

          <modules>
          <Nv_M2MfExport>
          <version>1.0.0</version>
          </Nv_M2MfExport>
          </modules>

          <global>
          <models>
          <nvm2mfexport>
          <class>Nv_M2MfExport_Model</class>
          </nvm2mfexport>
          </models>
          <events>
          <checkout_cart_save_after>
          <observers>
          <nvm2mfexport>
          <class>nvm2mfexport/observer</class>
          <method>orderExport</method>
          </nvm2mfexport>
          </observers>
          </checkout_cart_save_after>
          </events>
          </global>

          </config>


          Your observer class is also wrong.



          <?php

          class Nv_M2MfExport_Model_Observer
          {
          public function orderExport($observer)
          {
          //require_once '../app/Mage.php';
          //Mage::app();

          // Übergebenes Quote und Order Objekt holen
          $order = $observer->getEvent()->getOrder();
          $quote = $observer->getEvent()->getQuote();

          // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
          if ($quote->getDistributorEmail())
          {
          // Lieferadresse als Text formatiert holen
          $shipTo = $order->getShippingAddress()->format('text');
          $itemsTxt = "Itemsn-----------------------n";

          foreach ($order->getAllVisibleItems() as $item)
          $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

          $mail = Mage::getModel('core/email')
          ->setFromEmail('~@~.de')
          ->setSubject('Neue Bestellung')
          ->setToEmail('~@~.de')
          ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
          ->send();
          }

          /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
          $txt = "John Doen";
          fwrite($myfile, $txt);
          $txt = "Jane Doen";
          fwrite($myfile, $txt);
          fclose($myfile);*/
          }
          }


          And it should work.






          share|improve this answer

































            1














            The following code will never give you anything:



                $order = $observer->getEvent()->getOrder();
            $quote = $observer->getEvent()->getQuote();


            Because the checkout_cart_save_after event only lets you retrieve the cart, see in Mage_Checkout_Model_Cart :



            Mage::dispatchEvent('checkout_cart_save_after', array('cart'=>$this));


            So, you can do the following:



            $cart = $observer->getEvent()->getCart();
            $quote = $cart->getQuote();


            But you still have the problem of retrieving the corresponding order information. The reason behind that is because this event is not triggered necessarily after an order is placed, it's triggered after a change happens to the cart. So if one updates the quantity of an item in the cart, it's gonna trigger it and there's no order linked to it.



            IMHO you should use the sales_order_place_after event and do the following:



            $order = $observer->getEvent()->getOrder();
            $quote = $order->getQuote();





            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%2f172081%2fcheckout-cart-save-after-is-not-working%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









              2














              You need to update some of the names.



              Rename NvM2MfExport.xml to Nv_M2MfExport.xml and add below code



              <?xml version="1.0" encoding="UTF-8"?>
              <config>
              <modules>
              <Nv_M2MfExport>
              <active>true</active>
              <codePool>community</codePool>
              <depends>
              <Mage_Checkout />
              </depends>
              </Nv_M2MfExport>
              </modules>
              </config>


              Update your config.xml



              <?xml version="1.0"?>
              <config>

              <modules>
              <Nv_M2MfExport>
              <version>1.0.0</version>
              </Nv_M2MfExport>
              </modules>

              <global>
              <models>
              <nvm2mfexport>
              <class>Nv_M2MfExport_Model</class>
              </nvm2mfexport>
              </models>
              <events>
              <checkout_cart_save_after>
              <observers>
              <nvm2mfexport>
              <class>nvm2mfexport/observer</class>
              <method>orderExport</method>
              </nvm2mfexport>
              </observers>
              </checkout_cart_save_after>
              </events>
              </global>

              </config>


              Your observer class is also wrong.



              <?php

              class Nv_M2MfExport_Model_Observer
              {
              public function orderExport($observer)
              {
              //require_once '../app/Mage.php';
              //Mage::app();

              // Übergebenes Quote und Order Objekt holen
              $order = $observer->getEvent()->getOrder();
              $quote = $observer->getEvent()->getQuote();

              // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
              if ($quote->getDistributorEmail())
              {
              // Lieferadresse als Text formatiert holen
              $shipTo = $order->getShippingAddress()->format('text');
              $itemsTxt = "Itemsn-----------------------n";

              foreach ($order->getAllVisibleItems() as $item)
              $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

              $mail = Mage::getModel('core/email')
              ->setFromEmail('~@~.de')
              ->setSubject('Neue Bestellung')
              ->setToEmail('~@~.de')
              ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
              ->send();
              }

              /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
              $txt = "John Doen";
              fwrite($myfile, $txt);
              $txt = "Jane Doen";
              fwrite($myfile, $txt);
              fclose($myfile);*/
              }
              }


              And it should work.






              share|improve this answer






























                2














                You need to update some of the names.



                Rename NvM2MfExport.xml to Nv_M2MfExport.xml and add below code



                <?xml version="1.0" encoding="UTF-8"?>
                <config>
                <modules>
                <Nv_M2MfExport>
                <active>true</active>
                <codePool>community</codePool>
                <depends>
                <Mage_Checkout />
                </depends>
                </Nv_M2MfExport>
                </modules>
                </config>


                Update your config.xml



                <?xml version="1.0"?>
                <config>

                <modules>
                <Nv_M2MfExport>
                <version>1.0.0</version>
                </Nv_M2MfExport>
                </modules>

                <global>
                <models>
                <nvm2mfexport>
                <class>Nv_M2MfExport_Model</class>
                </nvm2mfexport>
                </models>
                <events>
                <checkout_cart_save_after>
                <observers>
                <nvm2mfexport>
                <class>nvm2mfexport/observer</class>
                <method>orderExport</method>
                </nvm2mfexport>
                </observers>
                </checkout_cart_save_after>
                </events>
                </global>

                </config>


                Your observer class is also wrong.



                <?php

                class Nv_M2MfExport_Model_Observer
                {
                public function orderExport($observer)
                {
                //require_once '../app/Mage.php';
                //Mage::app();

                // Übergebenes Quote und Order Objekt holen
                $order = $observer->getEvent()->getOrder();
                $quote = $observer->getEvent()->getQuote();

                // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
                if ($quote->getDistributorEmail())
                {
                // Lieferadresse als Text formatiert holen
                $shipTo = $order->getShippingAddress()->format('text');
                $itemsTxt = "Itemsn-----------------------n";

                foreach ($order->getAllVisibleItems() as $item)
                $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

                $mail = Mage::getModel('core/email')
                ->setFromEmail('~@~.de')
                ->setSubject('Neue Bestellung')
                ->setToEmail('~@~.de')
                ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
                ->send();
                }

                /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
                $txt = "John Doen";
                fwrite($myfile, $txt);
                $txt = "Jane Doen";
                fwrite($myfile, $txt);
                fclose($myfile);*/
                }
                }


                And it should work.






                share|improve this answer




























                  2












                  2








                  2







                  You need to update some of the names.



                  Rename NvM2MfExport.xml to Nv_M2MfExport.xml and add below code



                  <?xml version="1.0" encoding="UTF-8"?>
                  <config>
                  <modules>
                  <Nv_M2MfExport>
                  <active>true</active>
                  <codePool>community</codePool>
                  <depends>
                  <Mage_Checkout />
                  </depends>
                  </Nv_M2MfExport>
                  </modules>
                  </config>


                  Update your config.xml



                  <?xml version="1.0"?>
                  <config>

                  <modules>
                  <Nv_M2MfExport>
                  <version>1.0.0</version>
                  </Nv_M2MfExport>
                  </modules>

                  <global>
                  <models>
                  <nvm2mfexport>
                  <class>Nv_M2MfExport_Model</class>
                  </nvm2mfexport>
                  </models>
                  <events>
                  <checkout_cart_save_after>
                  <observers>
                  <nvm2mfexport>
                  <class>nvm2mfexport/observer</class>
                  <method>orderExport</method>
                  </nvm2mfexport>
                  </observers>
                  </checkout_cart_save_after>
                  </events>
                  </global>

                  </config>


                  Your observer class is also wrong.



                  <?php

                  class Nv_M2MfExport_Model_Observer
                  {
                  public function orderExport($observer)
                  {
                  //require_once '../app/Mage.php';
                  //Mage::app();

                  // Übergebenes Quote und Order Objekt holen
                  $order = $observer->getEvent()->getOrder();
                  $quote = $observer->getEvent()->getQuote();

                  // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
                  if ($quote->getDistributorEmail())
                  {
                  // Lieferadresse als Text formatiert holen
                  $shipTo = $order->getShippingAddress()->format('text');
                  $itemsTxt = "Itemsn-----------------------n";

                  foreach ($order->getAllVisibleItems() as $item)
                  $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

                  $mail = Mage::getModel('core/email')
                  ->setFromEmail('~@~.de')
                  ->setSubject('Neue Bestellung')
                  ->setToEmail('~@~.de')
                  ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
                  ->send();
                  }

                  /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
                  $txt = "John Doen";
                  fwrite($myfile, $txt);
                  $txt = "Jane Doen";
                  fwrite($myfile, $txt);
                  fclose($myfile);*/
                  }
                  }


                  And it should work.






                  share|improve this answer















                  You need to update some of the names.



                  Rename NvM2MfExport.xml to Nv_M2MfExport.xml and add below code



                  <?xml version="1.0" encoding="UTF-8"?>
                  <config>
                  <modules>
                  <Nv_M2MfExport>
                  <active>true</active>
                  <codePool>community</codePool>
                  <depends>
                  <Mage_Checkout />
                  </depends>
                  </Nv_M2MfExport>
                  </modules>
                  </config>


                  Update your config.xml



                  <?xml version="1.0"?>
                  <config>

                  <modules>
                  <Nv_M2MfExport>
                  <version>1.0.0</version>
                  </Nv_M2MfExport>
                  </modules>

                  <global>
                  <models>
                  <nvm2mfexport>
                  <class>Nv_M2MfExport_Model</class>
                  </nvm2mfexport>
                  </models>
                  <events>
                  <checkout_cart_save_after>
                  <observers>
                  <nvm2mfexport>
                  <class>nvm2mfexport/observer</class>
                  <method>orderExport</method>
                  </nvm2mfexport>
                  </observers>
                  </checkout_cart_save_after>
                  </events>
                  </global>

                  </config>


                  Your observer class is also wrong.



                  <?php

                  class Nv_M2MfExport_Model_Observer
                  {
                  public function orderExport($observer)
                  {
                  //require_once '../app/Mage.php';
                  //Mage::app();

                  // Übergebenes Quote und Order Objekt holen
                  $order = $observer->getEvent()->getOrder();
                  $quote = $observer->getEvent()->getQuote();

                  // Nur schicken wenn tatsächlich eine Adresse zugewiesen wurde
                  if ($quote->getDistributorEmail())
                  {
                  // Lieferadresse als Text formatiert holen
                  $shipTo = $order->getShippingAddress()->format('text');
                  $itemsTxt = "Itemsn-----------------------n";

                  foreach ($order->getAllVisibleItems() as $item)
                  $itemsTxt .= 'SKU: ' . $item->getSku() . ' QTY: ' . $item->getQtyOrdered() . "n";

                  $mail = Mage::getModel('core/email')
                  ->setFromEmail('~@~.de')
                  ->setSubject('Neue Bestellung')
                  ->setToEmail('~@~.de')
                  ->setBody("Lieferadresse:nn" . $shipTo . "n" . $itemsTxt)
                  ->send();
                  }

                  /*$myfile = fopen("/var/www/magento-1.9.3.2/newfile.txt", "w") or die("Unable to open file!");
                  $txt = "John Doen";
                  fwrite($myfile, $txt);
                  $txt = "Jane Doen";
                  fwrite($myfile, $txt);
                  fclose($myfile);*/
                  }
                  }


                  And it should work.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 29 '17 at 4:08

























                  answered Apr 27 '17 at 13:41









                  Jaimin SutariyaJaimin Sutariya

                  9,30821955




                  9,30821955

























                      1














                      The following code will never give you anything:



                          $order = $observer->getEvent()->getOrder();
                      $quote = $observer->getEvent()->getQuote();


                      Because the checkout_cart_save_after event only lets you retrieve the cart, see in Mage_Checkout_Model_Cart :



                      Mage::dispatchEvent('checkout_cart_save_after', array('cart'=>$this));


                      So, you can do the following:



                      $cart = $observer->getEvent()->getCart();
                      $quote = $cart->getQuote();


                      But you still have the problem of retrieving the corresponding order information. The reason behind that is because this event is not triggered necessarily after an order is placed, it's triggered after a change happens to the cart. So if one updates the quantity of an item in the cart, it's gonna trigger it and there's no order linked to it.



                      IMHO you should use the sales_order_place_after event and do the following:



                      $order = $observer->getEvent()->getOrder();
                      $quote = $order->getQuote();





                      share|improve this answer




























                        1














                        The following code will never give you anything:



                            $order = $observer->getEvent()->getOrder();
                        $quote = $observer->getEvent()->getQuote();


                        Because the checkout_cart_save_after event only lets you retrieve the cart, see in Mage_Checkout_Model_Cart :



                        Mage::dispatchEvent('checkout_cart_save_after', array('cart'=>$this));


                        So, you can do the following:



                        $cart = $observer->getEvent()->getCart();
                        $quote = $cart->getQuote();


                        But you still have the problem of retrieving the corresponding order information. The reason behind that is because this event is not triggered necessarily after an order is placed, it's triggered after a change happens to the cart. So if one updates the quantity of an item in the cart, it's gonna trigger it and there's no order linked to it.



                        IMHO you should use the sales_order_place_after event and do the following:



                        $order = $observer->getEvent()->getOrder();
                        $quote = $order->getQuote();





                        share|improve this answer


























                          1












                          1








                          1







                          The following code will never give you anything:



                              $order = $observer->getEvent()->getOrder();
                          $quote = $observer->getEvent()->getQuote();


                          Because the checkout_cart_save_after event only lets you retrieve the cart, see in Mage_Checkout_Model_Cart :



                          Mage::dispatchEvent('checkout_cart_save_after', array('cart'=>$this));


                          So, you can do the following:



                          $cart = $observer->getEvent()->getCart();
                          $quote = $cart->getQuote();


                          But you still have the problem of retrieving the corresponding order information. The reason behind that is because this event is not triggered necessarily after an order is placed, it's triggered after a change happens to the cart. So if one updates the quantity of an item in the cart, it's gonna trigger it and there's no order linked to it.



                          IMHO you should use the sales_order_place_after event and do the following:



                          $order = $observer->getEvent()->getOrder();
                          $quote = $order->getQuote();





                          share|improve this answer













                          The following code will never give you anything:



                              $order = $observer->getEvent()->getOrder();
                          $quote = $observer->getEvent()->getQuote();


                          Because the checkout_cart_save_after event only lets you retrieve the cart, see in Mage_Checkout_Model_Cart :



                          Mage::dispatchEvent('checkout_cart_save_after', array('cart'=>$this));


                          So, you can do the following:



                          $cart = $observer->getEvent()->getCart();
                          $quote = $cart->getQuote();


                          But you still have the problem of retrieving the corresponding order information. The reason behind that is because this event is not triggered necessarily after an order is placed, it's triggered after a change happens to the cart. So if one updates the quantity of an item in the cart, it's gonna trigger it and there's no order linked to it.



                          IMHO you should use the sales_order_place_after event and do the following:



                          $order = $observer->getEvent()->getOrder();
                          $quote = $order->getQuote();






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Apr 27 '17 at 13:41









                          Raphael at Digital PianismRaphael at Digital Pianism

                          54.4k22118276




                          54.4k22118276






























                              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%2f172081%2fcheckout-cart-save-after-is-not-working%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

                              “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                              How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                              夢乃愛華...