[英]how to get magento collection by created at on list.phtml
我試圖獲取新產品...如果我沒有從magento放置新產品的話,這不會來。
我在magento中編寫了一些用於獲取新產品的代碼...它不是基於創建的..
我需要知道我應該如何更改新產品的代碼...
我需要在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文件部分的動態部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.