问题getLoadedProductCollection()
在于它已经被加载- 产品的数据已经从数据库中检索到。仅使用当前类别的产品集合也不足够,这将忽略“图层”(属性过滤器)。诀窍是先从列表中删除加载的产品。
// First make a copy, otherwise the rest of the page might be affected!
$_productCollection = clone $this->getLoadedProductCollection();
// Unset the current products and filter before loading the next.
$_productCollection->clear()
->addAttributeToFilter('type_id', 'configurable')
->load();
print_r($_productCollection)
也有问题,您不仅要输出产品,而且要输出资源的所有详细信息,即数据库连接,缓存的值以及产品的单个资源,等等。
在这种情况下,我认为您会更满意:
print_r($_productCollection->toArray())