0
我試圖直接從價格規則在我的標題上顯示橫幅,而不必每次都編碼。PHP - 過濾價格規則按日期最近距離從
我創建了一個PHP文件看起來像:
<?php
/* Gets all the Magento store rules */
require 'app/Mage.php';
umask(0);
Mage::app('default');
//echo "test1<br>";
$todayDate = date("Y-m-d");
//echo $todayDate;
$limit = 1;
/* Get all the active Catalog Rules */
$catalogrules = Mage::getModel('catalogrule/rule')->getCollection()
->addFieldToFilter('is_active', 1)
// ->addFieldToFilter('sort_order', 1)
->addFieldToFilter('from_date', array('lteq' => $todayDate))
->addFieldToFilter('to_date', array('gteq' => $todayDate))
->addFieldToSelect('description');
foreach ($catalogrules as $rule)
{
//echo "catalog rule:<br>";
echo $rule->getData('description');
echo "<br>";
}
/* Get all active Shopping Cart Rules */
$cartrules = Mage::getModel('salesrule/rule')->getCollection()
->addFieldToFilter('is_active', 1)
// ->addFieldToFilter('sort_order', 1)
->addFieldToFilter('from_date', array('lteq' => $todayDate))
->addFieldToFilter('to_date', array('gteq' => $todayDate))
->addFieldToSelect('description');
foreach ($cartrules as $rule)
{
//echo "cart rule:<br>";
echo $rule->getData('description');
echo "<br>";
}
?>
我需要過濾,只需要最近啓動(FROM_DATE)規則從兩個目錄規則和購物車規則的代碼。
請告知!
謝謝!