Я пытаюсь разместить баннер в заголовке прямо из правила цены без необходимости каждый раз кодировать его.
Я создал 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) из правила каталога и правила корзины покупок.
ПОЖАЛУЙСТА, ПОРЕКОМЕНДУЙТЕ!!
Спасибо!
<?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(array('gteq' => $todayDate), array('null' => true)))//Make these changes
->addFieldToFilter('to_date', array(array('lteq' => $todayDate), array('null' => true)))//Make these changes
->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(array('gteq' => $todayDate), array('null' => true)))//Make these changes
->addFieldToFilter('to_date', array(array('lteq' => $todayDate), array('null' => true)))//Make these changes
->addFieldToSelect('description');
foreach ($cartrules as $rule)
{
//echo "cart rule:<br>";
echo $rule->getData('description');
echo "<br>";
}
?>
Других решений пока нет …