Day: May 19, 2010

  • Magento 1.4 is not showing out of stock items in product list

    我用过 Magento 1.3。在 Magento 1.3 里,某产品脱销了,仍在前台出现,只是提示 out of stock。

    这其实很好,符合我的 business logic: 脱销总是暂时的,我不希望顾客在这段时间找不到这个产品而误以为该产品 discontinued。如果真遇到产品 discontinued,由 admin 在后台 disable product。Enable / disable 一个产品很方便,这样 admin 会感觉 everything is in control。

    可是 Magento 1.4 起,自动把脱销的产品从前台产品列表里过滤了。这个逻辑搞得我莫名其妙,一开始还以为是我搞错了设置或被我改动过的代码写错了,最后才发现 Magento 1.4 把 getLoadedProductCollection() 的返回值修改了。

    其实这个修改很糟糕,显然 Magento 1.4 在这点上考虑不成熟:如果顾客都找不到这个产品了,那 wishlist 还有用吗?再看 list.phtml 里

    
    <?php $_productCollection=$this->getLoadedProductCollection() ?>
    <?php if(!$_productCollection->count()): ?>
    <p><?php echo $this->__('There are no products matching the selection.') ?></p>
    <?php else: ?>
    <div>
    <?php echo $this->getToolbarHtml() ?>
    <?php // List mode ?>
    <?php if($this->getMode()!='grid'): ?>
    <?php $_iterator = 0; ?>
    <ol id="products-list">
    <?php foreach ($_productCollection as $_product): ?>
    
    ...
    
    <?php if($_product->isSaleable()): ?>
    <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
    <?php else: ?>
    <p><span><?php echo $this->__('Out of stock') ?></span></p>
    <?php endif; ?>
    
    

    $_productCollection 都过滤了脱销的产品,后面的 $_product->isSaleable() 岂不是多此一举?

    我还是得把 getLoadedProductCollection() 按 Magento 1.3 修改回去。

    2010 年 5 月 25 日更新:当我发现 Magento 把显示产品的逻辑从“默认包括 out of stock” 改为 “默认不包括 out of stock”,我想 Magento 应该会在后台提供一个修改默认值的地方。前几天我找了,没找到,所以抱怨说 Magento 自说自话地修改逻辑,其实我冤枉 Magento 了。

    今天我无意中发现这个默认值是可以被修改的,在 System configuration 的 Inventory tab。Inventory 的设置在全局生效,当选择 storeview 时是看不到 Inventory tab 的,所以当时我没发现它。

    Display out of stock products in Magento 1.4
    Display out of stock products in Magento 1.4
  • What happens when an order is cancelled in Magento?

    Order Status

    When you click Cancel button in an order view, order status changes to Cancelled if payment is not received (i.e. invoice is not raised).

    If payment is received before you click Cancel button, order status changes to Complete. You must raise a credit note to offset the payment, then the status changes to Closed. However, this order still counts in dashboard. This statistical result is not what I am expecting, but I think there is a reason inside.

    See table as summary

    Is payment received? No Yes
    Order status changes to >>>Cancelled >>>Complete (before credit note is raised)

    >>>Closed (after credit note is raised)

    What is order status when payment or credit is partially done?

    If an order is cancelled when payment is partially received, the status changes to Complete immediately as if full payment is received.

    If a Complete order is partially refunded, the status remains Complete. The status changes to Closed when customer is credited in full.

    See table as summary

    Payment is partially received >>>Complete (before credit note is raised)

    >>>Complete (credit noted is raised but partially)

    >>>Closed (after full refund)

    Will inventory level reverse itself when an order is cancelled? It depends.

    Reversal only happens if this order is not shipped AND payment is not received.

    See table as summary

    Order is not shipped

    AND

    payment is not received

    Order is shipped

    OR

    payment is received

    Inventory level Reversal No reversal on cancelling

    Will inventory level reverse itself when an order is cancelled after it is partially fulfilled? And how much is the reversed inventory?

    If an order is partially fulfilled (payment is partially received or shipment is partial), there are 3 types of quantity, Qty Ordered, Qty Invoiced, Qty Shipped, showing at order view. Then you click Cancel button, you get –

    Qty Cancelled = Qty Ordered – max (Qty Invoiced, Qty Shipped)

    Qty Cancelled is the quantity automatically reserved to inventory.