[英]Reuse Magento product list block - custom collection
I want to use the default magento product list block and template but use it with my own custom product collection. 我想使用默认的magento产品列表块和模板,但将其与我自己的自定义产品集合一起使用。
The collection is not part of a category, but a collection that is being created by my own module. 该集合不是类别的一部分,而是由我自己的模块创建的集合。
how do i tie the two up? 我如何将两者捆绑在一起?
You need to create your own block class, inheriting from Mage_Catalog_Block_Product_List
, and to override at least its _getProductCollection()
method, to make it load your collection. 您需要创建自己的块类(继承自
Mage_Catalog_Block_Product_List
,并至少覆盖其_getProductCollection()
方法,以使其加载您的集合。
And regarding the template, you can assign the default one to your block in your layout definition. 对于模板,您可以在布局定义中为模块分配默认模板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.