Author: 芳草苑主

  • Best practices of merging multiple Gmail accounts

    工作需要对外使用多个邮箱,但阅读邮件时又不希望登录多个邮箱,而是希望在单一邮箱里查看和回复邮件。现以在邮箱A查看和回复来自邮箱B的邮件为例讲解设置。

    首先,登录邮箱B,在 Mail settings >> Filters 里 Create a new filter,在 “Doesn’t have” 一栏里填入长串不可能用到的乱字符,如 “J6dPFVFwnCsSBezVfSqRY5JTLNL567Ef”,然后点 “Next step”,选中 “Never send it to Spam“,最后点 “Create Filter”。这避免一些重要邮件被误判为 Spam,留在了邮箱B,不登录就查看不到,会误事。接着,还是在  Mail settings >> Forwarding and POP/IMAP 里 Add a forwarding address,填入邮箱A,follow instructions,不详述。

    然后,登录邮箱A,在 Mail settings >> Accounts >> Send mail as 里 Add another email address you own,填入 Name:whatever 和 Email address:邮箱B,然后点 “Next step”,选中 “Send through 邮箱B SMTP servers”,按 Gmail SMTP 配置去填写 SMTP Server, Username 和 Password,最后点 “Add Account“。

    大功告成。多罗嗦一句,不用邮箱A去POP邮箱B的方法来合并邮件是因为 Gmail 最多允许 POP 5个 accounts,无法合并6个以上邮箱;而且 POP 收取邮件没有从邮箱A转发过来即时。

  • 小美再加一个字

    女儿上学回家跟我说,老师这么称呼她:小美再加一个字
    ——人。

    然后作羞涩状。

  • Magento can edit order address since 1.5

    Magento 1.5 以后就允许修改订单地址了,Plieninger_Editable module 就没必要存在了,留着它反而会出错。

    当年想找一个修改订单地址的方案,就找到了 Plieninger_Editable,一用就用了一年。虽然一直不满意它的界面,一直想自己写一个,但一直忙于其他事务。现在跟它说 bye bye,还是很感谢它的。

  • php is_numeric

    某些 php 函数的返回值毫无规律可循。比如

    is_numeric("123")
    

    返回 true;

    is_numeric(" 123")
    

    (前导空格)返回 true;而

    is_numeric("123 ")
    

    (后导空格)返回 false。

    php 有灵活的语法,但每遇这种情况,我总是羡慕其他语言的严谨。

  • Change Magento configurable product to take associated products tax class

    Where and how to change the code?

    At first, I thought overriding Mage_Catalog_Model_Product_Type_Configurable::getOrderOptions().
    Original code

    $options['product_calculations'] = self::CALCULATE_PARENT;
    

    change to

    $options['product_calculations'] = self::CALCULATE_CHILD;
    

    However, it does not work.

    Then I tried to observe the event tax_rate_data_fetch and modify the rateRequest object. But inside rateRequest there is no reference to quoteItem. Only product tax_class_id is there. In the observer class, I do not know when to modify it without reference to quoteItem.

    At last, I had to modify the code in class Mage_Tax_Model_Sales_Total_Quote_Tax. There are several places to change depends on System Configuration. Change where is appropriate.
    Original code

    $taxRateRequest->setProductClassId($item->getProduct()->getTaxClassId());
    

    change to

    if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
    	$child = current($item->getChildren());
    	$taxRateRequest->setProductClassId($child->getProduct()->getTaxClassId());
    }
    else {
    	$taxRateRequest->setProductClassId($item->getProduct()->getTaxClassId());
    }
    

    It is not a neat approach. Let me know if you have a better idea.

  • I report very first bug to Magento

    Magento 里还是有不少 bugs,我能看出来的就不少。可是我一直懒于 report bug,总觉得我都能发现的 bug,大把有人发现。

    今天心血来潮,大概受“莫以善小而不为”驱使,平生第一次 report bug to Magento。事关 js/mage/adminhtml/product.js 文件里第406 行(Magento 1.5.0.1), 有个笔误,把 readonly 写成了redonly。Associated Products tab of Configurable Products 受此影响,本应只读模式的文本框仍可输入数据。

    非常小的错误。

    今后我把我的发现记载下来。

  • Reinstate thumbnails in jQuery UI theme switcher

    You might have noticed, some tools from jQuery are not fully functional recently. That could be caused by jQuery disabling hotlinks. jQuery UI theme switcher is affected. I call it a bug because jQuery team did not make necessary arrangement before enforcement of hotlink policy.

    Nevertheless, how to reinstate thumbnails in jQuery UI theme switcher while waiting for jQuery team to release a hotlink compatible theme switcher? Easy, with my code – Themeswitcher Launcher.

    
    jQuery(function($){
     $('body').prepend('<div id="msdk-themeswitcher"></div>');
     $('#msdk-themeswitcher').themeswitcher();
     var srcStart = "http://jqueryui.com/themeroller/images/";
     $('img[src^="http://jqueryui.com/themeroller/images/"]').each(
     function() {
     this.src = this.src.replace(srcStart,
     "http://static.jquery.com/ui/themeroller/images/");
     });
    });
    
    

    Themeswitcher Launcher just does a simple job: replacing images source in theme switcher to another source static.jquery.com, which still allow hotlinking. You can replace with your domain if you host these images.

    To save your time, I packaged jQuery UI theme switcher with my Themeswitcher Launcher. Please note I changed jQuery UI theme switcher slightly because I need it for Magento sites. I put function themeswitcher() into jQuery namespace to be standard jQuery plugin, so it can be working with javascript prototype framework.

    Download msdk-themeswitcher-launcher.js.tar.gz

    For those who are interested in my Magento modules: jQuery UI theme switcher and my Themeswitcher Launcher are integrated into my Msdk (Magento SDK) module – it is just an advertisement.

  • Machine convert xls to csv

    Linux is an excellent OS. Today something again proved my choice.

    I was looking for a solution to convert Excel xls to csv format. This conversion is required by a Magento dataflow project.

    Magento native dataflow comes with an XML Excel parser. For some reasons, it does not convert my xls files. I think it may be due to limited functionality of Magento XML Excel parser class, or encoding problem.

    I need something which can reliably convert xls files from 3rd parties, which we have no control over how they produce xls files.

    I was thinking of another php independent class called ExcelReader. However, ExcelReader goes beyond what I need. All I need is convert xls to csv, make ready for dataflow.

    After a day’s research, finally xls2csv caught my attention. I would have found it earlier if I had searched by “linux command line convert xls to csv” earlier. It runs perfectly well on Fedora and CentOS as I tested.

    Installation is straight forward. Run

    
    yum install catdoc
    
    

    FYI, yum install xls2csv, installs something totally different. I have not figured out what it is.

  • 一才难求

    有志开发网店的好手、生手请留言。工作地杭州。

  • When I had 31% off on Godaddy

    很多网站的促销都是做得不到位的。就是 Godaddy 难免也会有这错那错。比如我刚用它的一个 31% off no minimum voucher code 续了三个域名,付完钱以后她还在喋喋不休说再给个 20% off minimum $45。

    When I had 31% off
    When I had 31% off

    当然 Godaddy 整体促销还是不错的,我写这些只是提醒自己不要犯类似的错误。