不要重写List块,这会影响真正的产品列表页面。
简单的方法来将文件复制到本地命名空间并将其重命名:
来自:
app/code/core/Mage/Catalog/Block/Product/List.php
到:
app/code/local/Mage/Catalog/Block/Product/Fulllist.php
然后,您可以使用新的块不必须创建一个完整的模块,这将意味着您的List块将工作相同,并且不会破坏您商店中的任何内容。
然后,您可以安全地修改要求:
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
protected function _getProductCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection();
// this now has all products in a collection, you can add filters as needed.
//$collection
// ->addAttributeToSelect('*')
// ->addAttributeToFilter('attribute_name', array('eq' => 'value'))
// ->addAttributeToFilter('another_name', array('in' => array(1,3,4)))
//;
// Optionally filter as above..
return $collection;
}
然后,您可以使用新的块,像这样:
{{block type="catalog/product_fulllist" template="catalog/product/list.phtml"}}
你确实需要的所有产品的产品集合,或者你只需要显示所有产品在一个页面上,你要尝试的路线是产品系列? – 2013-02-26 11:28:38
我需要先获取网站的所有产品,然后进一步过滤,以便只显示具有特定属性值的产品。由于产品涉及多个类别,因此我认为我会首先获取产品集合中的所有产品,然后进一步对其进行过滤,以便与list.phtml视图显示类似。 – 2133215543 2013-02-26 11:32:03
糟糕的主意,这将使您的网站非常缓慢。你应该使用产品集合,但是* first *'addAttributeToFilter()'和* then *'load()'。 – 2013-02-26 16:32:37