2

I am working on module in which I need to add a custom attribute to the Order Entity but as I tried and failed I found out that Orders Entity is no longer using EAV attributes (or at least EAV table). Is there any way to use custom attribute to filter Orders ?

I am using Magento 1.7.2

3

Installer (Some/Module/sql/some_module_setup/mysql4-install-0.1.0.php):

/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
//add real field to orders table
$installer->getConnection()
    ->addColumn($installer->getTable('sales/order'), 'some_attribute', array(
    'TYPE' => Varien_Db_Ddl_Table::TYPE_INTEGER, //TYPE_VARCHAR,TYPE_DECIMAL,TYPE_DATETIME
    'LENGTH' => 255,
    'NULLABLE' => true,
    'COMMENT' => 'Some Attribute Definition'
));
$installer->endSetup();

Filter Collection:

$collection = Mage::getModel('sales/order')
            ->getCollection()
            ->addFieldToFilter('some_attribute', 'some_value');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.