我已经创建了一个应用了特价的产品集合,但我不知道在应用目录价格规则时如何获取产品集合。
以下是获取特价产品的代码,
public function getSpecialPriceProducts()
{
$categoryID = $this->getCategoryId();
if($categoryID)
{
$category = new Mage_Catalog_Model_Category();
$category->load($categoryID); // this is category id
$collection = $category->getProductCollection();
} else
{
$collection = Mage::getResourceModel('catalog/product_collection');
}
$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);
Mage::getModel('catalog/layer')->prepareProductCollection($collection);
$collection->addAttributeToSort('created_at', 'desc');
$collection->addStoreFilter()
->addAttributeToSelect(array('name', 'price', 'short_description','image','small_image','url_key'), 'inner');
$collection->addAttributeToFilter('special_price', array('gt' => 0));
$collection->addAttributeToFilter('special_to_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_from_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');
return $collection;
}
谁能指导我如何获取应用目录价格规则的产品列表?提前致谢。