Magento: Setting a custom attribute on the sales/order_shipment model

限于喜欢 提交于 2019-12-06 17:25:40

Adding an entity to an EAV model takes more than just adding a row to the eav_entity_type table. EAV Setup Resources (the classes that run the installer scripts) have a installEntities method that takes care of this for you. It's best to treat the entire thing as a black box unless you really want to trace out everything that's going on. Randomly adding data and tables around the EAV system until something works almost always leads to a system that's broken in some subtle way. It's similar to directly fiddling with memory values in RAM.

My article on EAV models should cover what you need to know. If you're still having problems after that, come back with specific questions.

This worked:

// ModuleNamespace/ModuleName/sql/vendorping_setup/mysql4-install-0.1.0.php

$this->startSetup();

if (version_compare(Mage::getVersion(), '1.4.1.0', '>=')) { // If sales data is stored flat
    $w = $this->_conn;
    $w->addColumn($this->getTable('sales_flat_shipment'), 'vendorping', 'int');
} else {
    $eav = new Mage_Eav_Model_Entity_Setup('sales_setup');
    $eav->addAttribute('shipment', 'vendorping', array('type' => 'int'));
}

$this->endSetup();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!