Month: January 2011

  • Why I love Android

    Many reasons.

    Today I add a new one reason why I love Android – Android never gild the lily “sent from my Android” as iPhone or BlackBerry does.

  • Improve Magento entity setup

    Magento 文档鼓励用 entity setup (Mage_Eav_Model_Entity_Setup) 的方式去定义实体。这个类很强大,但我觉得不够灵活,因为无法用它精确控制 attribute, attribute group 和 attribute set。

    Attribute group 和 attribute set 是在两个维度分组 attribute,这样来组织 attribute 基本够用。但 setup 这个类添加 attribute 时,有不够周到的逻辑:

    如果 $attr[‘user_defined’] == 1 && empty($attr[‘group’]),那么这个 attribute 不会被添加到任何 attribute group 和 attribute set。我觉得更好的逻辑是添加到 general attribute group。

    如果 empty($attr[‘user_defined’]) && !empty($attr[‘group’]),那么 $attr[‘group’] 会被忽略,attribute 总是被添加到 general attribute group。

    没办法,已经这样啦,提供 install entities array 时,就避免进入这两种逻辑吧。

    如果我来重写 setup 类里的 addAttribute 方法,我会:

    1. 忽略 $attr[‘user_defined’] 对逻辑的影响。一个 attribute 的 user_defined 值只决定是否允许用户用 GUI 修改该 attribute。
    2. 增加对 $attr[‘attribute_set_name’] 的检查。如果 !empty($attr[‘attribute_set_name’]),则添加该 attribute 进相应的 attribute set 或 attribute sets。现有逻辑是把 attribute 一股脑地添加进所有的 attribute sets。
  • PAYG handset is not locked to network carriers

    Today, I went into Churchill Square shopping centre. To my surprise, most shops are open on the New Years Day.

    I bought a white HTC Wildfire with an O2 SIM from Phones4u, as a gift for my mother. Phones4u is doing a promotion on 4 or 5 mobiles, and Wildfire is one of them. It is priced at £129.95 with £10 airtime purchase. It claims to be half price, but actually, I find the second cheapest supplier is Tesco, price is £159.97 without airtime purchase.

    HTC Wildfire in white
    HTC Wildfire in white

    Anyway, Phones4u is the cheapest. So I go for it. Then a second surprise – I find the handset is not locked to O2 network. I google for a while, and find it is not just my luck. Pay As You Go handset purchased from independent retailer is usually unlocked.

    This saves me about £10 to buy SIM unlock code.

    I feel very happy for trying to insert an Orange SIM before paying for unlock code.

  • Dataflow profile back to work in Magento 1.5.0.0

    Magento 1.5.0.0 目前还是 alpha2 版,因为安装到第二步就有一个很明显的 bug,本来想等等再用的。

    可是 1.4.2.0 正式版 dataflow profile 跑不起来,一点 “Run Profile in Popup”,出来的 popup 就是空白。我很喜欢用外部编辑器格式化好数据,然后用 dataflow import 到 Magento 数据库。我有很多 modules 也用到 dataflow 来完成初始化,如果 dataflow 跑不起来,会给我造成很大的麻烦。

    联想到 Magento 1.5.0.0 在 release note 里说到它对 dataflow 作了改进,我想很可能修正了 1.4.2.0 带来的 bug。两害取其轻,所以我跳过 Magento 1.5.0.0 的全新安装过程,用 1.4.2.0 的数据库让 Magento 1.5.0.0 跑了起来。果然如我所料,dataflow profile 在 1.5.0.0 下工作正常。

    Dataflow profile back to work in Magento 1.5.0.0
    Dataflow profile back to work in Magento 1.5.0.0