checkout_cart_save_after is not working The Next CEO of Stack OverflowHolepunching 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
Ising model simulation
Is there a rule of thumb for determining the amount one should accept for of a settlement offer?
How seriously should I take size and weight limits of hand luggage?
What difference does it make matching a word with/without a trailing whitespace?
That's an odd coin - I wonder why
Car headlights in a world without electricity
logical reads on global temp table, but not on session-level temp table
Could you use a laser beam as a modulated carrier wave for radio signal?
Why does freezing point matter when picking cooler ice packs?
A hang glider, sudden unexpected lift to 25,000 feet altitude, what could do this?
Early programmable calculators with RS-232
Why can't we say "I have been having a dog"?
Man transported from Alternate World into ours by a Neutrino Detector
Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact
Can Sri Krishna be called 'a person'?
Is it OK to decorate a log book cover?
Why did early computer designers eschew integers?
Why doesn't Shulchan Aruch include the laws of destroying fruit trees?
How to unfasten electrical subpanel attached with ramset
Is it a bad idea to plug the other end of ESD strap to wall ground?
How exploitable/balanced is this homebrew spell: Spell Permanency?
Is it possible to make a 9x9 table fit within the default margins?
Free fall ellipse or parabola?
Does the Idaho Potato Commission associate potato skins with healthy eating?
checkout_cart_save_after is not working
The Next CEO of Stack OverflowHolepunching 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 12 hours ago
Muhammad Anas
330115
330115
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 |
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
55k22121279
55k22121279
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
