简体   繁体   English

list.phtml 模板中的随机产品 magento

[英]random products in list.phtml template in magento

Below is the code to get list of products on a category page in list.phtml.下面是在 list.phtml 中的类别页面上获取产品列表的代码。

$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');

I want another section below this list where I can list random products of any category.我想要此列表下方的另一个部分,我可以在其中列出任何类别的随机产品。 can I do something to tweek this same function and reuse it?我可以做些什么来改变这个相同的 function 并重新使用它吗?

It would be really easy if I could use the same helper.如果我可以使用相同的助手,那将非常容易。

I wanted a section for " you might be intrested in these " and I show random products there.我想要一个“你可能会对这些感兴趣”的部分,我在那里展示了随机产品。

Thanks Ab谢谢抗体

I can't imagine something in Magento being as simple as:我无法想象 Magento 中的东西会像这样简单:

shuffle($_productCollection);

In XML where you should define your block, something like this:在 XML 中你应该定义你的块,是这样的:

<block type="catalog/product_list_random" template="your random template" name="random" />

and in the category view page simply make call to your template like在类别视图页面中,只需调用您的模板即可

echo $this->getChildHtml('random');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM