Day: December 8, 2010

  • Mage_Adminhtml_Controller_action

    今天发现,我的所有的 admin controller 都写成了 extends Mage_Adminhtml_Controller_action。虽然不影响使用,我还是想把它改规范的驼峰式 Mage_Adminhtml_Controller_Action。

    于是搜索了整个硬盘到底哪些文件里包含 Mage_Adminhtml_Controller_action,结果发现这个笔误还不少。而且不光我写的 modules 里有,Aheadworks, J2t, Plieninger 的代码里也有,最后发现源头是 koukou1985 的 Magento module creator。

    看来 Magento module creator 流传甚广。

  • Magento attribute’s attribute frontend_class

    Magento EAV framework is very promising, but not easy to understand. When the code is mixed with typos, it becomes even more confusing.

    Mage_Catalog_Model_Resource_Eav_Mysql4_Setup provides a template for setting up an attribute.

    'name' => array(
    'type'              => 'varchar',
    'backend'           => '',
    'frontend'          => '',
    'label'             => 'Name',
    'input'             => 'text',
    'class'             => '',
    'source'            => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
    'visible'           => true,
    'required'          => true,
    'user_defined'      => false,
    'default'           => '',
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'visible_on_front'  => false,
    'unique'            => false,
    )
    

    However, ‘class’ is wrong. It should be ‘frontend_class’. It refers to DOM class attribute assigned to this entity attribute output html. It can be used for value validation before submission. The possible classes can be found in js/prototype/validation.js. But frontend_class can be set anything you like for css styling or other purposes.