Magento: Attribute zur Checkout-Quote hinzufügen

14. April 2011 at 17:01

Zuerst muss in der Datenbank die Quote Tabelle entsprechend mit dem neuen Attribute erweitert werden, dies geht wie gewohnt über die setup-scripte (z.B. mysql4-install-0.0.X.php):

$installer = $this;
$installer->startSetup();
$installer->addAttribute('quote', 'new_attribute', array(
 'label'                        => 'New Attribute',
 'type'                        => 'varchar',
));
$installer->endSetup();

Danach könnt ihr, z.b. im OnepageController.php dieses Attribute wie folgt mit Werten füllen:

Mage::getSingleton('checkout/session')->getQuote()->setNewAttribute('value');
 Mage::getSingleton('checkout/session')->getQuote()->collectTotals();
 Mage::getSingleton('checkout/session')->getQuote()->save();

Be careful on input and type. Input means the input type of the attribute. And type means the input type in database.

For textfield it will be:
'input' => 'text',
'type' => 'text',

For textarea it will be:
'input' => 'textarea',
'type' => 'text',

For date field it will be:
'input' => 'date',
'type' => 'datetime',

For select list it will be:
'input' => 'select',
'type' => 'text',

For boolean select it will be:
'input' => 'boolean',
'type' => 'int',

Daniel Briegert

Daniel Briegert

xing: https://www.xing.com/profile/Daniel_Briegert

More Posts - Website

Follow Me:
TwitterFacebook