最模板试了下获取magento最近订单,与初学者分享下代码片段。 首先在你的block的相关php文件中获取订单的Collection,获取所有的订单。
public function getordercollection()
{
$model = Mage::getModel(‘sales/order_item’);
$collection = $model
->getCollection()
->load();
return $collection->getItems();
}
然后使用在你的模板文件phtml中使用php循环输出下
$thisorders = $this->getordercollection();
if ($thisorders) {
$thisorders2 = array_reverse($thisorders, TRUE);
foreach ($thisorders2 as $i=>$thisorder) {
$pmodel = Mage::getModel(‘catalog/product’);
$thisproduct = $pmodel->load($thisorder->getProductId());
echo “<img src=”.$thisproduct->getThumbnailUrl().” >”;
echo “<a href=”.$thisproduct->getProductUrl().”>”.$thisorder->getName().”</a>”;
echo “<p>价格:”.$thisproduct->getPrice().”</p>”;
echo “<P>—————————————————</P>”;
}
}
不要用最模板的输出代码,最模板懒,随便写下,大家是用magento的filter方法筛选下需要输出的东西。 (责任编辑:最模板) |

电子数码工业化工用品程
人气:979
仿rutaobao俄文淘宝代购系统
人气:1130
免费ecshop仿某公司模板商
人气:3936
ecshop仿聚美模板免费整站
人气:3737
Printshop 印刷业通用magent
人气:104
仿趣qu.cc成人用品ecshop模板
人气:1154