Magento: Test order email with filled variables

20. Februar 2015 at 10:13

magento ecommerce logo

If you would edit order emails you can use the following code to check the order emails with filled variables with order data:

<?php
require_once 'app/Mage.php';
Mage::app();
// loads the proper email template
$emailTemplate  = Mage::getModel('core/email_template')
    ->loadDefault('sales_email_order_template');
$templateId = "Neue Bestellung (Template)";
$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId);
// All variables your error log tells you that are missing can be placed like this:
$emailTemplateVars = array();
$emailTemplateVars['usermessage'] = "test message";
$emailTemplateVars['store'] = Mage::app()->getStore();
$emailTemplateVars['sendername'] = 'sender name';
$emailTemplateVars['receivername'] = 'receiver name';
// order you want to load by ID
$emailTemplateVars['order'] = Mage::getModel('sales/order')->load(673);
// load payment details:
// usually rendered by this template:
// web/app/design/frontend/base/default/template/payment/info/default.phtml
$paymentBlock = Mage::helper('payment')->getInfoBlock($emailTemplateVars['order']->getPayment())
    ->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore(Mage::app()->getStore());
$emailTemplateVars['payment_html'] = $paymentBlock->toHtml();
//displays the rendered email template
echo $emailTemplate->getProcessedTemplate($emailTemplateVars);
// you can send this email template
$receiveName = 'Daniel Briegert';
$receiveEmail = 'test@test.com';
//$emailTemplate->send($receiveEmail,$receiveName, $vars);

 

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

GD Star Rating
loading...
GD Star Rating
loading...

Handling Magento errors

20. Januar 2015 at 09:35

magento ecommerce logo

Magento ships with a new feature, which effectively hides errors from your visitors. If some kind of error occurs – a PHP Fatal Error, or PHP Notice Error, or database error – the actual error is written to file and not shown on screen. But when developing Magento sites, this behaviour might actually become annoying. Luckily you can easily re-enable the error-displaying again.

Showing errors anyway

Displaying the error on screen is much easier to work with. To enable the error-displaying again, navigate to the errors-folder in the Magento root, and rename the file local.xml.sample to local.xml. The XML-file should contain a line similar to this:

 <skin>myskin</skin> 

You can see that the action here is configured to print the message on screen, while the original dump is also left on the filesystem (in var/cache). You could also change the XML-code a bit to remove the dump-file instead:

 <trash>delete</trash> 

Mail me if an error occurs

Even cooler is that the XML-code also allows you to define an email-address to which mail should be sent if some error occurs:

<config>
<skin>default</skin>
<report>
<action>email</action>
<subject>Whoops, something went wrong in Magento</subject>
<email_address>info@example.com</email_address>
<trash>delete</trash>
</report>
</config>

Those of you who have wondered why errors were displayed using the original skin, can also see that the skin can be changed as well here:

<skin>myskin</skin>

Hope you find this all usefull.

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

GD Star Rating
loading...
GD Star Rating
loading...

If your Magento Admin Backend is down by activated the magento compiler mode

19. Januar 2015 at 14:06

magento ecommerce logo

If your Magento Admin Backend is down by activated the magento compiler mode,
here some reasons and solutions.

A possible reason is an active compilation status, check it about the console/bash/ssh
and if it is active, Disabling Magento compiler when Magento Admin Backend is inaccessible / down.

The Solution to deactivate the compiler mode

Console/SSH

    Check current compilation status

$ php -f shell/compiler.php — state
Compiler Status:          Enabled
Compilation State:        Compiled
Collected Files Count:    8764
Compiled Scopes Count:    4

    Disable Magento compilation:

$ php -f shell/compiler.php — disable
Compiler include path disabled

   Clear all compiled files

$ php -f shell/compiler.php — clear
Compilation successfully cleared

    Ensure that compiler is disabled now by checking its status:

$ php -f shell/compiler.php — state
Compiler Status:          Disabled
Compilation State:        Not Compiled
Collected Files Count:    0
Compiled Scopes Count:    0

   Flush Magento cache

Very often installation of new extensions with Compilation Mode enabled breaks your site. You cannot view the front-end and back-end. Nothing works. In this case the only solution is to disable Compilation Mode to get the site back to normal state.

1) Connect to your server using FTP Manager

2) Go inside “includes” folder

3) Open the file “config.php” for editing

4) Find the lines:

define(’COMPILER_INCLUDE_PATH’, dirname(__FILE__).DIRECTORY_SEPARATOR.’src’);
#define(’COMPILER_COLLECT_PATH’, dirname(__FILE__).DIRECTORY_SEPARATOR.’stat’);

and comment them out:

#define(’COMPILER_INCLUDE_PATH’, dirname(__FILE__).DIRECTORY_SEPARATOR.’src’);
#define(’COMPILER_COLLECT_PATH’, dirname(__FILE__).DIRECTORY_SEPARATOR.’stat’);

5) Save the changes.

Now you can get into your back-end. If you need to enable the Compilation mode again you should use “Run Compilation” button and NOT just enable it again (as it will break your site again). Running it will compile all new files correctly.

or the other way

FTP/Filemanager/Filesystem

delete includes directory or rename it to any other name (_includes.unused for example):

ftp :~> mv ./includes ./includes.unused

Flush Magento cache

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

GD Star Rating
loading...
GD Star Rating
loading...

Magento: DHL Intraship-Modul Netresearch korrekt konfigurieren

13. Januar 2015 at 12:34

magento-intraship-module-connect-screenshot

Das Magento Intraship-Module

Das von DHL angebotene Intraship-Module von Netresearch macht ggf. Probleme bei der Verwendung über das neue VLS 2.0.

Laut DHL wird Intraship derzeit abgelöst und durch das neue VLS 2.0 Versand-System ersetzt.

Das Magento-Module könnt ihr kostenfrei laden über den Magento-Connect-Manager, selbiges findet ihr hier:

http://www.magentocommerce.com/magento-connect/dhl-intraship.html

Bei dem Intraship-User tragt ihr ein im DHL-Geschäftskundenportal angelegten Benutzer an. Laut DHL-Support darf dieser nur max. 8 Zeichen haben. Das dazugehörige Passwort hinterlegt ihr bei Intraship Passwort.

Bei EKP tragt ihr die DHL-Kundennummer.

Die “Halbautomatische Sendungserstellung” sollte auf “Ja” gestelt werden (daher Aktiviert: ja).

Fehlermeldungen

Erhaltet ihr eine Fehlermeldung ähnlich

“Hard validation error occured. | hard validation error occured. | die ausgewählte abrechnungsnummer steht nicht zur verfügung. | die ausgewählte abrechnungsnummer steht nicht zur verfügung.”

so ist höchstwahrscheinlich die hinterlegte Abrechnungsnummer falsch.

Diese findet ihr im DHL-Geschäftskundenportal unter “Verwalten -> Stammdaten”.
Die dort angezeigte Abrechnungsnummer (14-stellig, z.b. 6XXXXXXXXXXXXX) muss in Magento bei der Konfiguration des DHL-Moduls jeweils bei den Versandoptionen im Feld DHL Paket – Teilnahme eingetragen werden.
WICHTIG: Da das Module nur zweistellige Zahlen erlaubt, müsst ihr die system.xml Konfiguration anpassen, daher die Datei

app/code/community/Dhl/Intraship/etc/system.xml wie folgt ändern:

<pre><standard translate="label comment" module="intraship">
    <label>DHL Package - Participation</label>
    <frontend_type>text</frontend_type>
    <validate>validate-digits validate-length minimum-length-14 maximum-length-14</validate>
    <sort_order>15</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>0</show_in_website>
    <show_in_store>0</show_in_store>
</standard></pre>

Erhaltet ihr eine Fehlermeldung ähnlich

Invalid fieldlength in element ‘PartnerID’. Please refer to documentation.

so ist die Partner-ID falsch. Diese ist in der Regel entweder 01 oder 02.

Sollte diese nicht korrekt aus der Konfig ausgelesen werden, so könnt ihr diese in der Datei

app/code/community/Dhl/Intraship/Model/Config.php in Zeile 402 setzen bzw. aus der Konfig auslesen, z.b. durch:

<pre>$partnerId = '02';
$profile->offsetSet('partnerId', $partnerId);</pre>

Schnittstellen-URLs

Die Schnittstellen-URLs sollten von dem Module schon vorkonfiguriert sein, falls nicht sind diese wie folgt:

Login Produktiv: https://www.intraship.de/intraship/jsp/Login_WS.jsp
Login Test: https://test-intraship.dhl.com/intra…p/Login_WS.jsp
WSDL Produktiv: http://www.intraship.de/ws/1_0/ISService/DE.wsdl
WSDL Test: http://test-intraship.dhl.com/ws/1_0/ISService/DE.wsdl

Support

Den Intraship-Module Support erreicht ihr per E-Mail an dhl.support@nr-apps.com

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

GD Star Rating
loading...
GD Star Rating
loading...

Change Copyright Year At Footer Of magento

9. Januar 2015 at 10:21

Was asked once by client how to make the copyright year at the footer of Magento site so that it changes automatically every year without doing it manually every year.

Solution one about Template Change and PHP

Copy the file app/design/frontend/default/default/template/page/html/footer.phtml
to your them-folder e.g. app/design/frontend/default/fly2marsmedia/template/page/html/footer.phtml
and open this file in your editor.

Change the

<address><?php echo $this->getCopyright() ?></address>

to

<address>&copy; <?php echo Mage::getModel('core/date')->date('Y') . ' ' . $this->getCopyright() ?></address>

Then
1) Log in to your Magento admin panel

2) Navigate to system > configuration > General > Design.

3) Click to expand the Footer section

4) Inside the Copyright text field remove the “&copy 2014″ part, this first part is changed automatically!

Solution Two about Magento-Admin-Panel configuration and javascript

1) Log in to your Magento admin panel

2) Navigate to system > configuration > General > Design.

3) Click to expand the Footer section

4) Inside the Copyright text field replace the @copy; YYYY with

&copy; <script type="text/javascript">
var d = new Date();
document.write(d.getFullYear())
</script>

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

GD Star Rating
loading...
GD Star Rating
loading...

notepad+ per tastatur steuern – notepad+ cheat sheet

8. Januar 2015 at 15:02

Legende

← → ↑ ↓ Pfeiltasten
Umschalttaste (shift)
Strg Steuerungstaste (Ctlr)
Alt Alt-Taste
Pos1 Pos1-Taste Nummernblock
Ende Ende-Taste Nummernblock
Einfg Einfügetaste (Überschreibmodus)
Entf Entfernen-Taste (Del)
Rücktaste (backspace)
Tabulatortaste
Entertaste (Return)
Bild↑ Bildtaste Nummernblock
Bild↓ Bildtaste Nummernblock
F1-F12 Funktionstasten 1-12
A-Z normale Zeichentasten

Navigation

ein Zeichen nach rechts
ein Zeichen nach links
eine Zeile nach oben
eine Zeile nach unten
Strg + → ein Wort nach rechts
Strg + ← ein Wort nach links
Ende an das Zeilenende springen
Pos1 an den Zeilenanfang springen
Strg + Ende an das Dokumentenende springen
Strg + Pos1 an den Dokumentenanfang springen
Strg + ↑ eine Zeile nach oben scrollen
Strg + ↓ eine Zeile nach unten scrollen
Bild↑ eine Seite nach oben scrollen
Bild↓ eine Seite nach unten scrollen
Strg + G öffnet Gehe zu Dialog

Auswählen (selektieren)

⇑ + → Zeichen nach Cursor selektieren
⇑ + ← Zeichen vor Cursor selektieren
Strg + ⇑ + → bis zum Wortende selektieren
Strg + ⇑ + ← bis zum Wortanfang selektieren
⇑ + Ende bis Zeilenende selektieren
⇑ + Pos1 bis Zeilenanfang selektieren
Strg + ⇑ + Pos1 bis Dokumentenanfang selektieren
Strg + ⇑ + Pos1 bis Dokumentenende selektieren
Strg + A alles selektieren
Alt + C + ←↑↓→ Spaltenmodus

Löschen

Entf Zeichen nach Cursor löschen
Zeichen vor Cursor löschen
Strg + ⇐ bis Wortanfang löschen
Strg + Entf bis zum Wortende (nächstes Wort) löschen
Strg + ⇑ + ⇐ bis zum Zeilenanfang löschen
Strg + ⇑ + Entf bis zum Zeilenende löschen
Strg + L aktuelle Zeile löschen
⇑ + ⇐ löscht Auswahl
Entf löscht Auswahl
löscht Auswahl und fügt neue Zeile ein

Suchen und Ersetzen

Strg + F Suchdialog öffnen
Strg + H Ersetzungsdialog öffnen
Strg + ⇑ + F in Dateien finden
Strg + Alt + I inkrementelle Suche starten
F3 nächstes Vorkommen finden
⇑ + F3 vorheriges Vorkommen finden
Strg + F3 Auswählen und nächstes Vorkommen finden
Strg + ⇑ + F3 Auswählen und vorheriges Vorkommen finden
Strg + Alt + F3 Wort am Cursor suchen
Strg + Alt + ⇑ + F3 Wort am Cursor rückwärts suchen
Strg + F2 Lesezeichen setzen/löschen
F2 zum nächsten Lesezeichen springen
⇑ + F2 zum vorherigen Lesezeichen springen
F7 ins Suchergebnisfenster wechseln
F4 zum nächsten Suchergebnis springen
⇑ + F4 zum vorherigen Suchergebnis springen
Strg + B zugehörige Klammer suchen

Textbearbeitung

Strg + I trennt Zeile am sichbaren rechten Rand
Strg + J verbindet selektierte Zeilen
Teilt Zeile am Cursor oder erzeugt neue Zeile
Einfg aktivieren/deaktivieren Überschreibmodus
Selektion einrücken
⇑ + ⇥ Selektion ausrücken
Strg + ⇑ + T Aktuelle Zeile kopieren
Strg + C Auswahl kopieren
Strg + X Auswahl ausschneiden
Strg + V Clipboard-Inhalt einfügen
Strg + Z Rückgängig
Strg + Y Wiederholen
Strg + ⇑ + ↑ Zeile nach oben schieben
Strg + ⇑ + ↓ Zeile nach unten schieben
Strg + T Aktuelle Zeile mit nächster Zeile vertauschen
Strg + U Wandelt Auswahl in Kleinbuchstaben
Strg + ⇑ + U Wandelt Auswahl in Großbuchstaben
Strg + ↵ Wort autovervollständigen
Strg + Leerzeichen Autovervollständigen (Liste)

Dateioperationen

Strg + N Neues Dokument
Strg + O Datei öffnen
Strg + S aktuelle Datei speichern
Strg + Alt + S Speichern unter (aktuelle Datei)
Strg + ⇑ + S alle Dateien speichern
Strg + W Datei schließen
Strg + T zum nächsten Reiter wechseln
Strg + ⇑ + T zum vorherigen Reiter wechseln

Makro und Ausführen

Strg + ⇑ + R Makroaufzeichnung starten/stoppen
Strg + ⇑ + P Marko starten
F5 Ausführen

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

GD Star Rating
loading...
GD Star Rating
loading...

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

app\design\adminhtml\default\fly2marsmedia\template\directory\js\optional_zip_countries.phtml

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)
 zipElementLabel.hide();

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)
zipElementLabel.show();

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 1.9.0.1 and other versions.

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

GD Star Rating
loading...
GD Star Rating
loading...

Magento Warenkorb Daten im Header / Warenkorb auslesen – Magento: get cart data

6. Januar 2015 at 14:58
Den Warenkorb von Magento kann man wie folgt auslesen:
<?php
      $_countHelper = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
      $_totalHelper = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
      if($count==0)
      {
        echo $this->__('<a href="/checkout/cart" class="cartgo">(0 ITEMS)</a>',$count);
      }
      if($count==1)
      {
        echo $this->__('<a href="/checkout/cart" class="cartgo">(1 ITEM)</a>',$count);
      }
      if($count>1)
      {
        echo $this->__('<a href="/checkout/cart" class="cartgo">(%s ITMES)</a>',$count);
      }
      echo $this->__('', $this->helper('core')->formatPrice($total, false));
    ?>

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

GD Star Rating
loading...
GD Star Rating
loading...

Magento: Add custom column in admin grid with own data & filter

29. August 2014 at 13:18

How to create a custom grid filter with a new column with own data (not from collection) and filter this data?

First Step

Enhance the grid, for example extends the Mage_Adminhtml_Block_Catalog_Category_Tab_Product

overwrite the  _prepareColumns() methode with new column

      $this->addColumn('price_yesno', array(
            'header'    => Mage::helper('catalog')->__('Price exist'),
            'sortable'  => true,
            'width'     => '60',
            'index'     => 'price',
            'type'      => 'options',
            'align'     => 'center',
            'renderer'  => 'Fly2mars_Catalog_Block_Adminhtml_Category_Renderer_Hasprice',
            'editable'  => 0,
            'options' => array('1' => 'Yes', '0' => 'No'),
            'filter_condition_callback' => array($this, '_filterHasPrice')
        ));
return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns();

And add in the same class the following callback methode

    protected function _filterHasPrice($collection, $column)
    {
        $value = $column->getFilter()->getValue();
        $collection = $this->getCollection();
        if($value == 1) {
            $collection->addFieldToFilter('price', array('notnull' => true));
        } else {
            $collection->addFieldToFilter('price', array('null' => true));
        }
        return $this;
    }

Second Step

You need the renderer, for this example you add in the file Fly2mars_Catalog_Block_Adminhtml_Category_Renderer_Hasprice

class Fly2mars_Catalog_Block_Adminhtml_Category_Renderer_Hasprice
    extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    /**
     * Check if product has price
     *
     * @param   Varien_Object
     * @return  string
     */
    protected function _getValue(Varien_Object $row)
    {
        if($row->getData('price') != '') {
            return 'Yes';
        }
        return 'No';
    }
}

that’s it.

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

GD Star Rating
loading...
GD Star Rating
loading...

Magento: convert single select attribute to multiselect

7. August 2014 at 17:24

Add in your entity-model following functions:

    /**
     * Get a text for option value
     *
     * @param string $value
     * @return string|false
     */
    public function getOptionText($value)
    {
        $options = $this->getAllOptions();
        foreach ($options as $option) {
            if ($option['value'] == $value) {
                return $option['label'];
            }
        }
        return false;
    }
    public function getFlatColums()
    {
        $columns = array();
        $columns[$this->getAttribute()->getAttributeCode()] = array(
            'type'      => 'VARCHAR',
            'unsigned'  => false,
            'is_null'   => true,
            'default'   => null,
            'extra'     => null
        );
        return $columns;
    }
    /**
     * Retrieve Indexes for Flat
     *
     * @return array
     */
    public function getFlatIndexes()
    {
        $indexes = array();
        $index = 'IDX_' . strtoupper($this->getAttribute()->getAttributeCode());
        $indexes[$index] = array(
            'type'      => 'index',
            'fields'    => array($this->getAttribute()->getAttributeCode())
        );
        return $indexes;
    }
    /**
     * Retrieve Select for update Attribute value in flat table
     *
     * @param   int $store
     * @return  Varien_Db_Select|null
     */
    public function getFlatUpdateSelect($store)
    {
        return Mage::getResourceModel('eav/entity_attribute_option')
            ->getFlatUpdateSelect($this->getAttribute(), $store, false);
    }

Now the setup script to convert 2 attributes

$this->startSetup();
$installer = $this;
$attributes = array(array('name' => 'ENTER_ATTRIBUTE_KEY_HERE', 'attribute_id' => ''),  // enter the attribute_key for ENTER_ATTRIBUTE_KEY_HERE
                    array('name' => 'ENTER_ATTRIBUTE_KEY_HERE', 'attribute_id' => '')
            );
$productEntityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
foreach($attributes as $id => $value) {
    $attributeId = $installer->getAttributeId($productEntityTypeId, $value['name']);
    $attributes[$id]['attribute_id'] = $attributeId;
    $installer->updateAttribute($productEntityTypeId, $attributeId, array(
        'frontend_input' => 'multiselect',
        'backend_type' => 'varchar',
        'backend_model' => 'eav/entity_attribute_backend_array'
    ));
}
foreach($attributes as $id => $attributeData) {
    // now copy attribute values from old attribute to new
    $sql = 'INSERT INTO ' . $this->getTable('catalog_product_entity_varchar') . '(entity_type_id, attribute_id, store_id, entity_id, value)
            SELECT entity_type_id, attribute_id, store_id, entity_id, value
            FROM ' . $this->getTable('catalog_product_entity_int')
            . ' WHERE attribute_id = ' . $attributeData['attribute_id'] . ';';
    $installer->run($sql);
    // delete values from old attribute (you must do this)
    $sql = 'DELETE FROM ' . $this->getTable('catalog_product_entity_int')
        . ' WHERE entity_type_id = 4 and attribute_id = ' . $attributeData['attribute_id'] . ';';
    $installer->run($sql);
}
$this->endSetup();
GD Star Rating
loading...
GD Star Rating
loading...