如何通过在list.phtml上创建来获取magento集合


how to get magento collection by created at on list.phtml

我试图获得新产品。。。bt如果。。。我没有把最新的产品放在magento。。

我为在magento获得新产品编写了一些代码。。。bt它不是建立在..的基础上

我需要知道,我应该在新产品的代码中更改什么。。。

我需要在magento产品列表页面中的list.phtml上显示新产品

我的密码如下。

 $todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
    $collection = $this->_addProductAttributesAndPrices($collection)
        ->addStoreFilter()
        ->addAttributeToFilter('news_from_date', array('or'=> array(
            0 => array('date' => true, 'to' => $todayDate),
            1 => array('is' => new Zend_Db_Expr('null')))
        ), 'left')
        ->addAttributeToFilter('news_to_date', array('or'=> array(
            0 => array('date' => true, 'from' => $todayDate),
            1 => array('is' => new Zend_Db_Expr('null')))
        ), 'left')
        ->addAttributeToFilter(
            array(
                array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
                array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
                )
          )
        ->addAttributeToSort('news_from_date', 'desc')
        ->setPageSize($this->getProductsCount())
        ->setCurPage(1)
    ;

步骤1:重写与要覆盖的.phtml关联的块。

步骤2:添加与块相关的xml,并将.phtml与此块关联。

步骤3:现在创建这个.phtml文件,并使用新的块调用来填充.phtml文件部分的动态部分。