Vote count:
0
I'd like to programmatically change the customer address attribute option values so I've created a file and searched around and came to this solution:
<?php
require_once 'app/Mage.php';
Mage::app();
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'geslacht');
$data['option']['value'] = array(
8649 => array(
0 => 'De heer',
1 => 'heer',
2 => 'heer'
),
8648 => array(
0 => 'Mevrouw',
1 => 'mevrouw',
2 => 'mevrouw'
)
);
$data['store_labels'] = array(
0 => 'Geslacht',
1 => 'Aanhef',
2 => 'Aanhef'
);
$attribute->addData($data)->save();
And it works perfectly! But... Now I'd like to use this in a setup file for a module I'm creating so I've copied it to a install file and came to this:
<?php
$installer = $this;
$installer->startSetup();
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer_address', 'geslacht');
$data['option']['value'] = array(
8649 => array(
0 => 'De heer',
1 => 'heer',
2 => 'heer'
),
8648 => array(
0 => 'Mevrouw',
1 => 'mevrouw',
2 => 'mevrouw'
)
);
$data['store_labels'] = array(
0 => 'Geslacht',
1 => 'Aanhef',
2 => 'Aanhef'
);
$attribute->addData($data)->save();
$installer->endSetup();
Now only the store labels are being saved and all option values are cleared! Why can't I use this code in a install file?
asked 2 mins ago
Magento setup doesn't save customer attribute option values?
Aucun commentaire:
Enregistrer un commentaire