本文整理汇总了PHP中Mage_Sales_Model_Resource_Report_Collection_Abstract::_beforeLoad方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Resource_Report_Collection_Abstract::_beforeLoad方法的具体用法?PHP Mage_Sales_Model_Resource_Report_Collection_Abstract::_beforeLoad怎么用?PHP Mage_Sales_Model_Resource_Report_Collection_Abstract::_beforeLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Resource_Report_Collection_Abstract
的用法示例。
在下文中一共展示了Mage_Sales_Model_Resource_Report_Collection_Abstract::_beforeLoad方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeLoad
/**
* Redeclare parent method for applying filters after parent method
* but before adding unions and calculating totals
*
* @return Mage_Sales_Model_Resource_Report_Bestsellers_Collection
*/
protected function _beforeLoad()
{
parent::_beforeLoad();
$this->_applyStoresFilter();
if ($this->_period) {
//
$selectUnions = array();
// apply date boundaries (before calling $this->_applyDateRangeFilter())
$dtFormat = Varien_Date::DATE_INTERNAL_FORMAT;
$periodFrom = !is_null($this->_from) ? new Zend_Date($this->_from, $dtFormat) : null;
$periodTo = !is_null($this->_to) ? new Zend_Date($this->_to, $dtFormat) : null;
if ('year' == $this->_period) {
if ($periodFrom) {
// not the first day of the year
if ($periodFrom->toValue(Zend_Date::MONTH) != 1 || $periodFrom->toValue(Zend_Date::DAY) != 1) {
$dtFrom = $periodFrom->getDate();
// last day of the year
$dtTo = $periodFrom->getDate()->setMonth(12)->setDay(31);
if (!$periodTo || $dtTo->isEarlier($periodTo)) {
$selectUnions[] = $this->_makeBoundarySelect($dtFrom->toString($dtFormat), $dtTo->toString($dtFormat));
// first day of the next year
$this->_from = $periodFrom->getDate()->addYear(1)->setMonth(1)->setDay(1)->toString($dtFormat);
}
}
}
if ($periodTo) {
// not the last day of the year
if ($periodTo->toValue(Zend_Date::MONTH) != 12 || $periodTo->toValue(Zend_Date::DAY) != 31) {
$dtFrom = $periodTo->getDate()->setMonth(1)->setDay(1);
// first day of the year
$dtTo = $periodTo->getDate();
if (!$periodFrom || $dtFrom->isLater($periodFrom)) {
$selectUnions[] = $this->_makeBoundarySelect($dtFrom->toString($dtFormat), $dtTo->toString($dtFormat));
// last day of the previous year
$this->_to = $periodTo->getDate()->subYear(1)->setMonth(12)->setDay(31)->toString($dtFormat);
}
}
}
if ($periodFrom && $periodTo) {
// the same year
if ($periodFrom->toValue(Zend_Date::YEAR) == $periodTo->toValue(Zend_Date::YEAR)) {
$dtFrom = $periodFrom->getDate();
$dtTo = $periodTo->getDate();
$selectUnions[] = $this->_makeBoundarySelect($dtFrom->toString($dtFormat), $dtTo->toString($dtFormat));
$this->getSelect()->where('1<>1');
}
}
} else {
if ('month' == $this->_period) {
if ($periodFrom) {
// not the first day of the month
if ($periodFrom->toValue(Zend_Date::DAY) != 1) {
$dtFrom = $periodFrom->getDate();
// last day of the month
$dtTo = $periodFrom->getDate()->addMonth(1)->setDay(1)->subDay(1);
if (!$periodTo || $dtTo->isEarlier($periodTo)) {
$selectUnions[] = $this->_makeBoundarySelect($dtFrom->toString($dtFormat), $dtTo->toString($dtFormat));
// first day of the next month
$this->_from = $periodFrom->getDate()->addMonth(1)->setDay(1)->toString($dtFormat);
}
}
}
if ($periodTo) {
// not the last day of the month
if ($periodTo->toValue(Zend_Date::DAY) != $periodTo->toValue(Zend_Date::MONTH_DAYS)) {
$dtFrom = $periodTo->getDate()->setDay(1);
// first day of the month
$dtTo = $periodTo->getDate();
if (!$periodFrom || $dtFrom->isLater($periodFrom)) {
$selectUnions[] = $this->_makeBoundarySelect($dtFrom->toString($dtFormat), $dtTo->toString($dtFormat));
// last day of the previous month
$this->_to = $periodTo->getDate()->setDay(1)->subDay(1)->toString($dtFormat);
}
}
}
if ($periodFrom && $periodTo) {
// the same month
if ($periodFrom->toValue(Zend_Date::YEAR) == $periodTo->toValue(Zend_Date::YEAR) && $periodFrom->toValue(Zend_Date::MONTH) == $periodTo->toValue(Zend_Date::MONTH)) {
$dtFrom = $periodFrom->getDate();
$dtTo = $periodTo->getDate();
$selectUnions[] = $this->_makeBoundarySelect($dtFrom->toString($dtFormat), $dtTo->toString($dtFormat));
$this->getSelect()->where('1<>1');
}
}
}
}
$this->_applyDateRangeFilter();
// add unions to select
if ($selectUnions) {
$unionParts = array();
$cloneSelect = clone $this->getSelect();
$helper = Mage::getResourceHelper('core');
$unionParts[] = '(' . $cloneSelect . ')';
foreach ($selectUnions as $union) {
//.........这里部分代码省略.........