Magento-获取所有产品的产品集合 [英] Magento - get product collection of all products

查看:203
本文介绍了Magento-获取所有产品的产品集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要所有产品的自定义产品集合.当前没有包含商店所有产品的类别(因为有8000种产品,我们不能将它们添加到一个额外的类别中.)

I need a custom product collection of all products. Currently there are no categories which contain all products of the store (as there are 8000 products we can not add them in to one extra category).

我需要的是在特定的CMS页面上,显示所有产品的产品集合. 到目前为止,我的CMS页面带有以下块:

What I need is on a particular CMS page the product collection of all products is displayed. So far I have a CMS page with the block:

{{block type="catalog/product_list" template="catalog/product/list.phtml"}}

我创建了一个模块来覆盖"Mage_Catalog_Block_Product_List"

I have created an module to override 'Mage_Catalog_Block_Product_List'

我认为我需要编辑的功能将是受保护的功能_getProductCollection()"

I believe the function I need to edit would be 'protected function _getProductCollection()'

我们可以在块调用中看到,没有指定类别.我需要的是_getProductCollection函数中隐藏的是退货商店中的所有产品.

As we can see in the block call theres no category specified. What I need is in the overidden _getProductCollection function is all products in the store returned.

有什么方法可以实现?

推荐答案

有几种方法可以从商店获取产品列表. 尝试这种方式:

<?php
$_productCollection = Mage::getModel('catalog/product')
                        ->getCollection()
                        ->addAttributeToSort('created_at', 'DESC')
                        ->addAttributeToSelect('*')
                        ->load();
foreach ($_productCollection as $_product){
   echo $_product->getId().'</br>';
   echo $_product->getName().'</br>';
   echo $_product->getProductUrl().'</br>';
   echo $_product->getPrice().'</br>';
}
?>

这篇关于Magento-获取所有产品的产品集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆