Category: 小小草

IT 技术领域学海无涯。其实任何领域都学海无涯,无非 IT 发展太快了,让我有更多嘘唏。希望我掌握的技术有如小小草,虽然渺小,却有旺盛的生命力。

  • cp -f does not switch off prompt?

    我在 Fedora 下执行大量的文件拷贝操作,我使用了

    cp -fr [SOURCE] [DEST]

    我使用了 -f 开关就是不想被询问文件是否覆盖。但

    cp: overwrite `(filename)’? 提示还是出现。

    这是什么原因?原来 Fedora 带有几个 alias,可以用 alias 命名查看。

    # alias
    alias cp=’cp -i’
    alias l.=’ls -d .* –color=auto’
    alias ll=’ls -l –color=auto’
    alias ls=’ls –color=auto’
    alias mv=’mv -i’
    alias rm=’rm -i’
    alias which=’alias | /usr/bin/which –tty-only –read-alias –show-dot –show-tilde’

    cp 被 alias 了!-i switch 优先于 -f,所以 cp -fr [SOURCE] [DEST] 其实是执行了

    cp -ir [SOURCE] [DEST]

    怎么才能让 overwrite 提示不出现呢?办法有二:

    办法一是使用 unalias 解开 cp -i。但 cp 默认使用 -i 确实很不错,我不想放弃 Fedora 的体贴。于是——

    办法二是使用
    /bin/cp -ir [SOURCE] [DEST]

  • Magento 1.3 cannot work with memcached 1.4

    今天我注意到一个还未来得及升级的 Magento 1.3.2.3 的安装 down 了,原因是 Magento 1.3.2.3 无法和 memcached 1.4.4.2 协同工作(memcached 1.4.4.2 服务器环境自动升级带来的)。

    错误提示如下

    Notice: MemcachePool::delete() [memcachepool.delete]: Server 127.0.0.1 (tcp 11211, udp 0) failed with: CLIENT_ERROR bad command line format. Usage: delete [noreply]
    (0) in /……/magento/app/code/core/Zend/Cache/Backend/Memcached.php on line 271

    我按提示找到 Memcached.php 把第271行改为

    return $this->_memcache->delete($id, 0);
    

    仍旧无效。

    尝试着升级安装到 Magento 1.4.0.1,能支持 memcached 1.4.4.2 了。

    但网站布局变得乱七八糟,需要调整很多 template, layout 及 css 文件,这不是一时半会能完成的,只好暂用备份文件降级到 Magento 1.3.2.3,改用 apc backend cache。还好网站在单台服务器上运行,没涉及到分布式缓存,memcached 不是必需的。我装了 memcached 也没怎么玩它,缺乏掌控,暂时先搁置。

  • Customise Magento order number

    After I put a lot of test orders into Magento, now I want to delete them for a clean start. I also want to shorten the length of order number, and the order number from various stores share the global increment. I want the similar settings on Matgento invoice, shipment, and creditmemo.

    I have concluded these steps after some trials and errors.

    Firstly, empty orders, invoices, shipments, and creditmemo by executing mysql commands:

    
    TRUNCATE `magento_sales_flat_order_item`;
    TRUNCATE `magento_sales_flat_quote`;
    TRUNCATE `magento_sales_flat_quote_address`;
    TRUNCATE `magento_sales_flat_quote_address_item`;
    TRUNCATE `magento_sales_flat_quote_item`;
    TRUNCATE `magento_sales_flat_quote_item_option`;
    TRUNCATE `magento_sales_flat_quote_payment`;
    TRUNCATE `magento_sales_flat_quote_shipping_rate`;
    TRUNCATE `magento_sales_invoiced_aggregated`;
    TRUNCATE `magento_sales_invoiced_aggregated_order`;
    TRUNCATE `magento_sales_order`;
    TRUNCATE `magento_sales_order_aggregated_created`;
    TRUNCATE `magento_sales_order_datetime`;
    TRUNCATE `magento_sales_order_decimal`;
    TRUNCATE `magento_sales_order_entity`;
    TRUNCATE `magento_sales_order_entity_datetime`;
    TRUNCATE `magento_sales_order_entity_decimal`;
    TRUNCATE `magento_sales_order_entity_int`;
    TRUNCATE `magento_sales_order_entity_text`;
    TRUNCATE `magento_sales_order_entity_varchar`;
    TRUNCATE `magento_sales_order_int`;
    TRUNCATE `magento_sales_order_tax`;
    TRUNCATE `magento_sales_order_text`;
    TRUNCATE `magento_sales_order_varchar`;
    TRUNCATE `magento_sales_payment_transaction`;
    TRUNCATE `magento_sales_refunded_aggregated`;
    TRUNCATE `magento_sales_refunded_aggregated_order`;
    TRUNCATE `magento_sales_shipping_aggregated`;
    TRUNCATE `magento_sales_shipping_aggregated_order`;
    

    Then, go to table magento_eav_entity_type, find entity order, invoice, shipment, creditmemo, change increment_per_store to or not to share global increment (default is 1 which means each store has its own increment), change increment_pad_length to shorten or longer numbers (increment_pad_length does not include prefix: 1 digit by default).

    Then, empty table magento_eav_entity_store by executing:

    
    TRUNCATE `magento_eav_entity_store`;
    

    With an empty table, Magento generate default increment_prefix which is store id (with global increment setting, it is 0), and increment starts from 0.

    I want the first order, invoice, shipment, creditmemo number look like 100001, I set magento_eav_entity_type.increment_pad_length at 5, and insert 4 records into magento_eav_entity_store.

    Customise order, invoice, shipment, creditmemo number in Magento
    Customise order, invoice, shipment, creditmemo number in Magento

    And that’s it.

    2010年6月22日更新:我想提醒一下,光有几个 store_id = 0 的记录不够保险。因为几天后,我发现每个 storeview 都有了各自的记录,显然 storeview 的记录优先于 default (store_id = 0)。increment_prefix 默认为 store_id,这让每个 storeview 有了不同的前缀,与我初衷(所有 storeview 统一使用 “1” 为前缀)相悖。我不清楚后来这些自动添加的记录是由什么事件引发的。既然 increment_prefix 被改了,我只好接受这个事实,改来改后会让后台订单号看起来没有连续性。

    More data added to eav_entity_store
    More data added to eav_entity_store
  • Comparison in PHP

    除非使用 === 或 !== 进行比较,PHP 尽可能地将值转化为数字进行比较。因此,看到比较 “10” == “1e1” 的结果是 true,千万不要大惊小怪。

    “尽可能”如何理解?

    1. 如果等式一边是数字,另一边是字符串,那么字符串一定要 cast to int 后再比较。因此,比较 “10” == 1e1 的结果是 true,比较 “10 ” == 1e1 的结果也是 true。
    2. 如果等式两边都是字符串,且字符串中均不含数学字符以外的字符(包括white space),那么两边的字符串会在 cast to int 后再比较;否则,直接比较字符串。因此,比较 “10” == “1e1” 的结果是 true,但比较 “10 ” == “1e1” 的结果是 false。
    3. 如果等式有一边或两边是数组,则先比较数组结构是否相同,再逐个比较数组元素。在比较数组元素时,索引不会 cast,但值按上述两条规则“尽可能” cast。因此,比较 1 == array(1) 的结果是 false,比较 array(“10”) == array(“1e1”) 的结果是 true,比较 array(10 => 10) == array(“1e1” => 10) 的结果是 false。
  • Paypal vs PaypalUk in Magento

    Magento 里有两个有关 Paypal 支付的模块:Paypal and PaypalUk。我尚未查到文档有关它们的区别,只知道 PaypalUK 依赖于 Paypal,在同时启用 Paypal and PaypalUk 时,后台可以看到

    Configuration Paypal section when PaypalUk is enabled
    Configuration Paypal section when PaypalUk is enabled

    Configuration Payment Methods section when PaypalUk is enabled
    Configuration Payment Methods section when PaypalUk is enabled

    若不启用 PaypalUk 模块,后台变成:

    Configuration Paypal section when PaypalUk is disabled
    Configuration Paypal section when PaypalUk is disabled

    Configuration Payment Methods section when PaypalUk is disabled
    Configuration Payment Methods section when PaypalUk is disabled

    对比可见后台多了 Payflow Edition,估计 PaypalUk 是面向开发者的称呼,Payflow 是面向普通用户的称呼。更多区别还有待摸索。

  • OpenPassword

    Inspired by OpenId, I want to start a project – OpenPassword.

    What is it for?
    People are hesitate to register themselves from site to site. One of the reasons is people are afraid of giving password to the web sites they do not trust much. Most people do not have big memory, so they have to use the same password for all web sites. They may or may not aware that any webmaster / web owner who has access to the password database could try the same password on other sites (or even worse – for online banking). Whether people’s passwords are in safe depends on how honest the webmaster / web owner is. Even the webmaster / web owner is honest, does he have basic skills to keep password in safe? I see a lot of web sites save passwords unencrypted, which could be a disaster.

    OpenId comes to solve this problem. But currently not all web sites support OpenId. What if you are in a position you have to use some web sites which do not support OpenId? You have to take care of security yourself. My proposal is:

    1. You register different web sites with different passwords.
    2. The passwords are generated with one-way encryption.
    3. You host encryption algorithm and salt in a safe place, so you do not need remember the passwords. Every time you need them, you generate / retrieve them on the fly.
  • Dispatched events on a simple Magento homepage

    每访问一次我一个并不复杂的 Magento 站点主页,将会触发多少个事件?我记了下来:


    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    controller_front_init_before

    controller_front_init_routers

    resource_get_tablename

    resource_get_tablename

    model_load_after

    core_abstract_load_after

    resource_get_tablename

    core_locale_set_locale

    controller_action_predispatch

    controller_action_predispatch_cms

    controller_action_predispatch_cms_index_index

    resource_get_tablename

    resource_get_tablename

    model_load_after

    cms_page_load_after

    resource_get_tablename

    model_load_after

    core_abstract_load_after

    cms_page_render

    controller_action_layout_load_before

    customer_session_init

    resource_get_tablename

    model_load_after

    core_abstract_load_after

    resource_get_tablename

    controller_action_layout_generate_xml_before

    controller_action_layout_generate_blocks_before

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    resource_get_tablename

    resource_get_tablename

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    controller_action_layout_generate_blocks_after

    controller_action_layout_render_before

    controller_action_layout_render_before_cms_index_index

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_to_html_before

    model_load_after

    core_abstract_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    resource_get_tablename

    model_load_after

    catalog_entity_attribute_load_after

    model_load_after

    catalog_entity_attribute_load_after

    model_load_after

    catalog_entity_attribute_load_after

    model_load_after

    catalog_entity_attribute_load_after

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    model_load_after

    customer_load_after

    resource_get_tablename

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    model_load_after

    core_abstract_load_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    resource_get_tablename

    resource_get_tablename

    model_load_after

    core_abstract_load_after

    core_block_abstract_prepare_layout_before

    core_block_abstract_prepare_layout_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    model_load_after

    core_abstract_load_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    model_load_after

    core_abstract_load_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    resource_get_tablename

    model_load_after

    sales_quote_load_after

    resource_get_tablename

    model_load_after

    customer_group_load_after

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    resource_get_tablename

    sales_quote_item_collection_products_after_load

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    eav_collection_abstract_load_before

    catalog_product_collection_load_before

    catalog_product_collection_load_after

    resource_get_tablename

    sales_quote_item_set_product

    sales_quote_item_qty_set_after

    resource_get_tablename

    core_collection_abstract_load_before

    core_collection_abstract_load_after

    resource_get_tablename

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    model_load_after

    core_abstract_load_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_after

    core_block_abstract_to_html_before

    core_block_abstract_to_html_after

    controller_action_postdispatch_cms_index_index

    controller_action_postdispatch_cms

    controller_action_postdispatch

    model_save_before

    core_abstract_save_before

    resource_get_tablename

    resource_get_tablename

    resource_get_tablename

    model_save_after

    core_abstract_save_after

    model_save_commit_after

    core_abstract_save_commit_after

    http_response_send_before

    controller_front_send_response_after

  • No way to control inline elements’ height

    今天在 css 里遇上一个以前不曾注意的细节:
    假设<a>和<img>的 border, margin 和 padding均为0,一个被<a> wrapped 的 <img> (<a><img/></a>) 比单独一个 <img/> 在 Firefox 中 render 要高 3px,在 chrome 和 ie 下也会高一些(但我未测量数值)。

    实例代码

    
    <style type="text/css">
    a { text-decoration:none; }
    a, img { border:0; padding:0; margin:0; }
    .col-1 { float:left; text-align:right; width:49%; }
    .col-2 { float:right; text-align:left; width:49%; }
    .line { height:1px; border-top:1px solid orange; }
    </style>
    
    <div class='col-set'>
    <div class='col-1'>
    <a href="#">
    <img src="not-lineup.jpg"/>
    </a>
    <div class='line'>&nbsp;</div>
    </div>
    <div class='col-2'>
    <img src="not-lineup.jpg"/>
    <div class='line'>&nbsp;</div>
    </div>
    </div>
    
    
    Inline elements 不等高实例截图
    Inline elements 不等高实例截图

    我想了很久才知道这都是因为<a>和<img>是inline elements。Inline elements 有一些特性

    • they flow with text.
    • they have line-height.
    • the element height and width is dependent on the content and will not collapse to the borders of the parent element.

    Inline elements 没有 height,在上例中也无法用 line-height 去控制高度:<a>的底部与<img>的底部有 3px 间距,我试遍我能想到的所有 css 属性都无法消除这个间距,除非——

    将<a>设为display:block!Block elements 的 border, margin 和 padding 都是有效的,控制高度就不是问题了。

  • Manage magento catalog images on the local server

    Magento 的 Image / Media / Gallery 模型非常好用,可以迅速在全站范围内调整输出图片的尺寸。如果用户习惯于用上传图片的方式管理图片库,他会觉得 Magento 很方便。Magento 自动把上传的图片保存到 media/catalog/product/(文件名首字母)/(文件名第二字母)/(文件名或拖尾_1, _2, … 以防重名)。

    在产品库初建时,要输入大量的图片路径。虽然 product import dataflow 也很好用,但图片的保存位置规则跟上传时一样,我觉得不够好。因为:

    1. 原始图片是静态文件,可以独立于 Magento,存放在服务器的某个本地路径,也方便共享给其他程序使用;
    2. 如果 Magento 自行保存图片,浪费了服务器空间(对我来说,这倒没什么,服务器上空了好几百 G),而且按 media/catalog/product/(文件名首字母)/(文件名第二字母)/(文件名或拖尾_1, _2, … 以防重名) 去查找图片非常不方便,产品图片理应按 category 归入各个子目录。

    所以,我想把 Magento 的 Image / Media / Gallery 模型改进一下,做到:

    1. 原始图片存放于 static_file_server/catalog/product/category_1/subcategory_1/image_name。
    2. Magento 不保存原始图片,只要记牢原始图片在服务器上的某个位置。
    3. 喜欢 upload 的用户仍可以使用 upload,但为喜欢 ftp / ssh 的用户增加指定 local path 的功能。
    4. import product 接受 local_path。
    5. Magento 缓存图片的机制不变。
  • How magento deducts stock level

    我心里一直有个疑问,收到订单后,Magento 是怎么更新库存数量的?是直接用一个新库存数字去更新,还是用 upadte magento_cataloginventory_stock_item set qty=qty-qty_ordered 之类的办法。

    通过跟踪 sql 语句,我感觉前者的可能性很大。

    UPDATE `magento_cataloginventory_stock_item` SET `item_id` = '125', `product_id` = '125', `stock_id` = '1', `qty` = '93.000000', `min_qty` = '0.000000', `use_config_min_qty` = '1', `is_qty_decimal` = '0', `backorders` = '1', `use_config_backorders` = '0', `min_sale_qty` = '1.000000', `use_config_min_sale_qty` = '1', `max_sale_qty` = '0.000000', `use_config_max_sale_qty` = '1', `is_in_stock` = '1', `low_stock_date` = NULL, `notify_stock_qty` = '0.000000', `use_config_notify_stock_qty` = '1', `manage_stock` = '1', `use_config_manage_stock` = '0', `stock_status_changed_automatically` = '0', `shelf` = '' WHERE (item_id='125')
    

    这样很不好,如果几个人同时买同一个产品,会搞乱库存数。不知道被破坏的几率有多大,有空要搞一个并发下单的测试。