Day: June 22, 2010

  • Magento extension: Root Category As Homepage

    It is my first time publish an Magento extension – Qian_Rcah. By default, Magento prevent root category from being shown at frontend, not to say use it as homepage. I do not see significant security leaks if showing root category. There are some benefits using root category as homepage:

    • Layered navigation starts with a complete product collection on site.
    • Selective products show on homepage without prerequisite knowledge of cms block.

    Download RootCategoryAsHomepage.tar.gz

    How to install:
    Copy the whole “app” folder to magento/app. That’s it.

    How to use:
    Log in Magento backend, go to System -> Configuration -> General -> Web -> Default Pages, change “Default web URL” to “rcah” (default is cms). Besides of root category, this module can load an arbitrary category page as homepage. In this case, change “Default web URL” to “rcah/index/index/id/ARBITRARY_CATEGORY_ID”.

    How is it created:
    This module is created by koukou1985’s module creator (http://www.magentocommerce.com/wiki/custom_module_with_custom_database_table). Thanks to koukou1985.

    How good is it:
    This module does not override any Mage classes. It is safe to use with other extensions as long as namespace and module name do not conflict.

  • How can Magento generate sitemap.xml belongs to root?

    今天看到 magento 目录下的 sitemap.xml 的属主和属组分别是 root:root,属性是644,而这一台的 webserver 是以 apache:apache 身份运行的,所以我觉得很奇怪:

    • apache 怎么能建立一个 root:root 的文件?
    • 如果这个文件不是 apache 建的,apache 怎么有权去更新它(最近更新就在今天)?

    想了好一会明白过来,sitemap.xml 是 cron job 建的,crontab 这么写

    */10 * * * * /usr/bin/php -f /path/to/magento/cron.php

    那么 sitemap.xml 归 root:root 所有就不奇怪了。

    我想这样写会好些:

    */10 * * * * sudo -u apache -g apache /usr/bin/php -f /path/to/magento/cron.php

    2010年6月29日更新:上行命令不对,设想在 cron job 里以 apache 身份运行 cron.php,但出错。正确的写法应该是:

    */10 * * * * su -c '/usr/bin/php -f /path/to/magento/cron.php' -s /bin/bash apache