Magento: Cancel old orders / Alte Bestellungen stornieren

24. März 2015 at 15:18

php code

Um alte Bestellungen in Magento zu stornieren könnt ihr den folgenden php-code verwenden:

To cancel old orders in Magento, e.g. with state „pending“, „holded“ or „pending_payment“ you can use the following php-code:

    public function autocancelPendingOrders()
        $orderCollection = Mage::getResourceModel('sales/order_collection');
                    array('eq' => 'pending'),
                    array('eq' => 'holded'),
                    array('eq' => 'pending_payment')
        $orderCollection->addFieldToFilter('created_at', array(
                'lt' =>  new Zend_Db_Expr("DATE_ADD('".now()."', INTERVAL 2 HOUR)")))
//            ->limit(20)
        foreach($orderCollection->getItems() as $order)
            $orderModel = Mage::getModel('sales/order');
            if($orderModel->getState() == 'holded') {
                if(!$orderModel->canUnhold()) {
                } else {
            if(!$orderModel->canCancel()) {

Magento: Fixing error „[unknown object].fireEvent()“

8. Januar 2015 at 10:02

Recently I’ve encountered the following Javascript error in my Magento store:

error: error in [unknown object].fireEvent():
event name: address_country_changed
error message: zipElement.up(…).down(…) is undefined

This error pops out when creating the order from admin panel and entering customer shipping address. It pops out when editing every filed in the address, which is quite annoying.

Regarding to this forum post, this has something to do with defining the zip code as not required filed in the database. Specialists recommend to set zip code as required filed in the database and then setting it as not required on the country basis. But people report that setting so will still not make zip code as optional field.

So I decided to do my own fix. Here it is:

1. Copy the file app\design\adminhtml\default\default\template\directory\js\optional_zip_countries.phtml to your local design-folder like


2. Navigate approximately to line 57.

3. Find the function setPostcodeOptional(zipElement, country)

4. Find the following line: zipElement.up(1).down(‚label > span.required‘).hide();

5. Change it to the following code:

var zipElementLabel = zipElement.up(1).down('label > span.required');
 if (zipElementLabel)

6. Find the following line: zipElement.up(1).down(‚label > span.required‘).show();

7. Change it to the following code:

var zipElementLabel = zipElement.up(1).down('label > span.required');
if (zipElementLabel);

Notice that this code repeats two times inside the function, but differs a little bit in „hide()“ and „show()“ calls at the end.

8. Save the file and upload to the server. Page reload might be required.

This helped me fighting the mentioned error in Magento version and other versions.

Please share this article von facebook & google plus or where you want, thank you!

Magento: Session Variable – Set Unset Session Variable

20. August 2010 at 15:48

Es wird eine individuelle Variable mit den Namen „magentoTest“ angelegt. Der Wert für diese ist in diesem Fall „hello magento“.

$session = Mage::getSingleton('core/session', array('name'=>'frontend'));
$session->setMagentoTest('hello magento');

Abfragen der Werte:

$test = Mage::getSingleton('core/session')->getMagentoTest();

Session Variable löschen / unset


Nur eine bestimmte Session-Variable löschen:


(Im Frontend die Customer oder Core Session benutzen. Im Backend die Adminhtml Session benutzen.)
Core Session:- Mage::getSingleton(‘core/session’)
Customer Session:- Mage::getSingleton(‘customer/session’)
Admin Session:- Mage::getSingleton(‘adminhtml/session’)