MB200 week calculation bug

一个月前,我的 MB200 显示有系统更新可用,我就升级了一下。升级了以后很失望,firmware version 仍是 1.5,看来 motorola 不打算让 MB200 用上 android 1.6 以上版本了,有空了我还得自行升级。 用了一个月,我发现了 MB200 现有的版本 (Blur version 1.3.39) 居然有个日期计算上的 bug。比如今天是星期天,它会认为是星期一。这样,我设定的闹钟,闹周一到周五,结果它闹的是周日到周四;10月的最后一个星期天的凌晨从夏令时切换到冬令时,结果它提前一天星期六就让我用上冬令时了,搞得我周六一早起来看时间后总觉得怪怪的。 如果我来升级,我就上 android 2.2。

Magento promotional free shipping does not apply to tablerate

Magento 自有的 shipping calculation 已足够强大,如果谁还说不够用,我就会说是经营上的问题。 最近我被要求做这么一件事,在一个 storeview 下,对部分商品不论金额大小,一律 free shipping。一听之下我觉得可以用 cart salesrule free shipping action 来实现,实际尝试后却发现,cart salesrule free shipping 不能对 tablerate 起作用。而 tablerate 是 frontend 唯一一个 shipping method,被设置强制选择,顾客不会被问到 choose shipping method。在这个逻辑下,如果我启用 free shipping method,checkout 就多问一个问题,老板说这不好。而 flatrate 另有他用(backend 接单时对特殊地区额外征收运费),也无法拿它来实现部分商品 free shipping。 这件事最后用一个普通 discount 抵消 shipping charge 的方式迂回解决,但解决得很别扭。我认为 shipping rates 是一种全局设置,就算能,也不应该为某些商品创建例外的; 如果想为某些商品创建例外,那么再想一下为什么要创建例外,比如这些商品针对是一群特殊用户,如果 cross selling 对特殊用户不起作用,那就专门为他们建一个 store 或… Continue reading Magento promotional free shipping does not apply to tablerate

Place Magento model, resource, collection class at your will

Most Magento model, resource, collection are placed this way: Model is located at Model folder Resource is located at Model/Mysql4 Collection is located at Model/Mysql4/(ClassName) What if you want organise them in a different way? Say how place all of 3 classes under one folder? I enclose a complete a working sample. 1. Model class… Continue reading Place Magento model, resource, collection class at your will

this vs $(this) in jQuery

I don’t know why, but this is how it happens. When I make a jQuery plugin, the skeleton is And if I need an each operation inside plugin, the skeleton can be The interesting thing is inside each, I must use “$(this)” to run jQuery functions, but outside each, I can also use “this”. I… Continue reading this vs $(this) in jQuery

How to read Magento product custom options correctly?

Magento product custom options 的存储结构比较“绕”,我绕了好长时间才解开。 假设 $product 有两个 custom options,一个是 textarea input type,另一个是 multiple select input type: 先用 $product->getOptions(),得到是包含两个 custom options 的集合; 然后 foreach 一下,得到每个 $option。对第一个 textarea 类型的,处理起来相对简单,用 $option->getData(‘title’) 查看 title,以此类推。对第二个 multiple select 类型的,用 $option->getData() 只能查看概况,对于 select 里的每个 option (对应 <select><option>…</option></select>),还得用 $option->getValues(),然后再次 foreach 才能得到 select option。 够复杂吧。

How to pager array items in Magento

The Mage class Mage_Page_Block_Html_Pager is handy to pager collection items, but it is designed to work with a collection derived from Mage_Core_Model_Mysql4_Collection_Abstract. Now I run into a situation to pager arbitrary array items. The array items are pre-built and not loaded via a resource model, so the pager lost a clue how to control which… Continue reading How to pager array items in Magento

A universal recursion method for Magento

Magento 历遍 category 时用的 Tree/Node 模型,我看了一知半解。当我把 CMS page 整理成树状,想对所有 pages 如同 category 历遍操作时,我抛开 Tree/Node,就写了两个简单的方法来套用(感谢 php 5.3 让这方法成为可能)。 若要 CMS page 历遍 someOperation(),则只要临时定义一个 $function,然后调用 $page->recurseSubpages(),具体代码是 $params 是用来回传参数的,如果不需要回传,可以省略。 我认为这样让复杂的递归变得很简单,可是在想做一张 html 格式的 CMS page sitemap (用<ul><li>…</li></ul>层次嵌套体现 CMS page 的层次,如同 Magento top navigation 那段代码。顺便说一下,我认为 Magento category sitemap 的代码不够好,它把树形结构线性化了,不够 semantic)时,遇到困难。当时我觉得要在 _recurse() 里再次调用 _recurse() 之前和之后有条件地插入一些操作,不是简单定义一个 $function 可以做到的。 所以第一版的 CMS page sitemap… Continue reading A universal recursion method for Magento

Magento extension project: Grouped DIY Product

这是我用了 Magento 后站在需求分析的角度写得相对完整的文档,以前都直接 get hands dirty 了。 What is the motive? We want to sell Christmas selections of products. Usually each unit product is of very low value, but the total value of selection is significant. If we pre-define the selection as a product, we can only create a limited number of selection products. Actually,… Continue reading Magento extension project: Grouped DIY Product

Counter down for Magento CMS blocks

我做了一个 Magento CMS static blocks 里用的倒计时 block。虽然功能比较简单,但还是比较智能的,所以还是想自我表彰一下。这不是独立的模块,我也没打算就拿这么单一的功能去生成一个模块,类似的功能我都会合并在一个 Msdk (Magento SDK) 模块里。