Skip to content

Instantly share code, notes, and snippets.

View abdev's full-sized avatar

Anda B. abdev

View GitHub Profile
@abdev
abdev / gist:2376792
Created April 13, 2012 13:17
Magento -update product attribute backend type
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $installer->getEntityTypeId('catalog_product');
// replace <my_attribute_code> with your attribute code
$idAttribute = $installer->getAttribute($entityTypeId, '<my_attribute_code>', 'attribute_id');
$installer->updateAttribute($entityTypeId, $idAttribute, array(
'backend_type' => 'varchar'
));
// let's see if it worked
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', '<my_attribute_code>');
@abdev
abdev / gist:3083037
Created July 10, 2012 12:44
Magento - format date from local format to magento internal format
$myDate = '07/10/12';//2012-07-10
$format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$date = Mage::app()->getLocale()->date(
$myDate,
Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
null,
false
);
@abdev
abdev / Configuration.php
Created July 27, 2012 10:19
Symfony2 array options config.yml parsing
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('my_root');
$rootNode
->children()