【发布时间】:2011-04-09 03:38:46
【问题描述】:
我想在 .../template/catalog/product/view.phtml 模板上添加 3 个随机产品链接。
基于list.phtml,我尝试添加:
<?php
$_productCollection=$this->getLoadedProductCollection();
foreach ($_productCollection as $_randomProduct) {
echo $_randomProduct->getProductUrl();
}
?>
但我没有得到 URL 的列表。如何获取一系列其他产品的链接和图片?
【问题讨论】:
-
magento 数据对象支持语法 'RAND()' 。 $productCollection->getSelect()->order('rand());