在magento前端显示延期交货状态

Sim*_*mon 6 frontend magento

我需要在产品页面(前端)上显示当前商品仅用于延期交货且没有库存.

我现在有库存显示可用的数量和延期交货的产品没有显示任何东西.

有没有人知道我可以放在view.phtml文件中的代码,该文件只会在那些设置为延期交货的产品上显示消息?

谢谢!

西蒙.

Muf*_*dal 7

要执行此操作,请确保已从"库存"选项卡启用了延期交货.

如果您在产品页面上,那么首先检索产品数量.

<?php
$inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);

if( (int)$inventory->getQty() == 0 && $inventory->getBackorders() )
{
  // No Backorders => getBackorders() = 0
  // Allow Qty Below 0 => getBackorders() = 1
  // Allow Qty Below 0 and Notify Customer => getBackorders() = 2
  echo "display your backordedr message";
}
?>
Run Code Online (Sandbox Code Playgroud)

您也可以将此代码放在 app\design\frontend\base\default\template\catalog\product\view\type\default.phtml产品可用性消息来自的文件中.