checkout_cart_save_after is not workingHolepunching of header in magento store[Solved]Cannot override Pdf/Total/Default.php modelMagento extension not working in my layoutSimple Observer not firing on eventOut of stock mail subscription Not workingExtension not working correctlyPackage extension not working: MagentoDiscount 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
What about the virus in 12 Monkeys?
How can saying a song's name be a copyright violation?
Little known, relatively unlikely, but scientifically plausible, apocalyptic (or near apocalyptic) events
Why can't we play rap on piano?
ssTTsSTtRrriinInnnnNNNIiinngg
Arrow those variables!
Avoiding direct proof while writing proof by induction
Solving a recurrence relation (poker chips)
How do I handle a potential work/personal life conflict as the manager of one of my friends?
Short story with a alien planet, government officials must wear exploding medallions
Why is consensus so controversial in Britain?
Plagiarism or not?
Should I tell management that I intend to leave due to bad software development practices?
Why is this clock signal connected to a capacitor to gnd?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
Am I breaking OOP practice with this architecture?
Im going to France and my passport expires June 19th
Would Slavery Reparations be considered Bills of Attainder and hence Illegal?
Mathematica command that allows it to read my intentions
Why didn't Boeing produce its own regional jet?
Avoiding the "not like other girls" trope?
How much of data wrangling is a data scientist's job?
How dangerous is XSS?
How to prevent "they're falling in love" trope
checkout_cart_save_after is not working
Holepunching of header in magento store[Solved]Cannot override Pdf/Total/Default.php modelMagento extension not working in my layoutSimple Observer not firing on eventOut of stock mail subscription Not workingExtension not working correctlyPackage extension not working: MagentoDiscount 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
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.
magento-1.9 checkout extensions magento-1.9.3.2
add a comment |
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.
magento-1.9 checkout extensions magento-1.9.3.2
add a comment |
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.
magento-1.9 checkout extensions magento-1.9.3.2
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.
magento-1.9 checkout extensions magento-1.9.3.2
magento-1.9 checkout extensions magento-1.9.3.2
edited 2 days ago
Muhammad Anas
350115
350115
asked Apr 27 '17 at 13:33
SebastianSebastian
113
113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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();
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
edited Apr 29 '17 at 4:08
answered Apr 27 '17 at 13:41


Jaimin SutariyaJaimin Sutariya
9,39322055
9,39322055
add a comment |
add a comment |
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();
add a comment |
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();
add a comment |
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();
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();
answered Apr 27 '17 at 13:41


Raphael at Digital PianismRaphael at Digital Pianism
55k22122279
55k22122279
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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