Skip to content

Commit

Permalink
fix: revert back constants
Browse files Browse the repository at this point in the history
  • Loading branch information
oxcom committed Aug 30, 2018
1 parent ba8e828 commit 9aac7b4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Model/ProductRepositoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,22 @@ public function getList($type, ProductSearchCriteriaInterface $searchCriteria =
*/
protected function getBestsellers($condition, ProductSearchCriteriaInterface $searchCriteria)
{
$allowed = [static::BEST_SELLING_PERIOD_DAILY, static::BEST_SELLING_PERIOD_MONTHLY, static::BEST_SELLING_PERIOD_YEARLY];
$allowed = [
ProductSearchCriteriaInterface::PERIOD_DAILY,
ProductSearchCriteriaInterface::PERIOD_MONTHLY,
ProductSearchCriteriaInterface::PERIOD_YEARLY
];

$period = $searchCriteria->getPeriod();
if (!\in_array($period, $allowed, true)) {
$period = static::BEST_SELLING_PERIOD_YEARLY;
$period = ProductSearchCriteriaInterface::PERIOD_YEARLY;
}

$from = new \DateTime();
$to = new \DateTime();

switch ($period) {
case static::BEST_SELLING_PERIOD_YEARLY:
case ProductSearchCriteriaInterface::PERIOD_YEARLY:
$from->setDate($from->format('Y'), 1, 1);
$from->modify('-1 year');

Expand All @@ -165,7 +170,7 @@ protected function getBestsellers($condition, ProductSearchCriteriaInterface $se
];
break;

case static::BEST_SELLING_PERIOD_MONTHLY:
case ProductSearchCriteriaInterface::PERIOD_MONTHLY:
$from->setDate($from->format('Y'), $from->format('m'), 1);
$from->modify('-1 month');

Expand All @@ -179,7 +184,7 @@ protected function getBestsellers($condition, ProductSearchCriteriaInterface $se
];
break;

case static::BEST_SELLING_PERIOD_DAILY:
case ProductSearchCriteriaInterface::PERIOD_DAILY:
default:
$range = [
'from' => $from->format('Y-m-d 00:00:00'),
Expand Down

0 comments on commit 9aac7b4

Please sign in to comment.