Skip to content

Commit e121887

Browse files
committed
MC-15250: Explicit product sorting in PageBuilder Products Content type
1 parent fbd9f89 commit e121887

File tree

20 files changed

+105
-114
lines changed

20 files changed

+105
-114
lines changed

app/code/Magento/PageBuilder/Model/Catalog/Sorting.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,31 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog;
810

911
/**
1012
* Sorting of Catalog Widget Products
11-
*
12-
* @package Magento\PageBuilder\Model
1313
*/
1414
class Sorting
1515
{
1616
/**
1717
* @var array
1818
*/
19-
private $sortClasses = [
20-
'date_newest_top' => Sorting\Date\NewestTop::class
21-
];
19+
private $sortClasses;
2220

2321
/**
2422
* @var Sorting\Factory
2523
*/
2624
private $factory;
2725

2826
/**
29-
* @var array
27+
* @var Sorting\SortInterface[]
3028
*/
3129
private $sortInstances = [];
3230

3331
/**
34-
* Sorting constructor.
3532
* @param Sorting\Factory $factory
3633
* @param array $sortClasses
3734
* @throws \Magento\Framework\Exception\LocalizedException
@@ -40,7 +37,7 @@ public function __construct(
4037
Sorting\Factory $factory,
4138
array $sortClasses
4239
) {
43-
$this->sortClasses = array_merge($this->sortClasses, $sortClasses);
40+
$this->sortClasses = $sortClasses;
4441
$this->factory = $factory;
4542
foreach ($this->sortClasses as $key => $className) {
4643
$this->sortInstances[$key] = $this->factory->create($className);
@@ -65,14 +62,13 @@ public function getSortingOptions(): array
6562
* Get the instance of the first option which is None
6663
*
6764
* @param string $sortOption
68-
* @return Sorting\SortInterface|null
65+
* @return Sorting\SortInterface
6966
*/
7067
public function getSortingInstance($sortOption): Sorting\SortInterface
7168
{
7269
if (isset($this->sortInstances[$sortOption])) {
7370
return $this->sortInstances[$sortOption];
7471
}
75-
return $this->sortInstances['date_newest_top'];
7672
}
7773

7874
/**

app/code/Magento/PageBuilder/Model/Catalog/Sorting/AttributeAbstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting;
810

9-
use \Magento\Framework\DB\Select;
11+
use Magento\Framework\DB\Select;
1012

1113
/**
1214
* Class AttributeAbstract
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting
1515
*/
1616
abstract class AttributeAbstract extends SortAbstract implements SortInterface
1717
{

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Date/NewestTop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting\Date;
810

9-
use \Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
11+
use Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
1012

1113
/**
1214
* Class NewestTop
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting\Date
1515
*/
1616
class NewestTop extends AttributeAbstract
1717
{
@@ -34,7 +34,7 @@ protected function getSortDirection()
3434
/**
3535
* @inheritdoc
3636
*/
37-
public function getLabel(): string
37+
public function getLabel(): \Magento\Framework\Phrase
3838
{
3939
return __('Newest products first');
4040
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Date/OldestTop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting\Date;
810

9-
use \Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
11+
use Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
1012

1113
/**
1214
* Class OldestTop
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting\Date
1515
*/
1616
class OldestTop extends AttributeAbstract
1717
{
@@ -34,7 +34,7 @@ protected function getSortDirection()
3434
/**
3535
* @inheritdoc
3636
*/
37-
public function getLabel(): string
37+
public function getLabel(): \Magento\Framework\Phrase
3838
{
3939
return __('Oldest products first');
4040
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting;
810

911
/**
1012
* Class Factory
11-
*
12-
* @package Magento\PageBuilder\Model\Catalog\Sorting
1313
*/
1414
class Factory
1515
{

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Name/Ascending.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting\Name;
810

9-
use \Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
11+
use Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
1012

1113
/**
1214
* Class Name\Ascending
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting\Name
1515
*/
1616
class Ascending extends AttributeAbstract
1717
{
@@ -34,7 +34,7 @@ protected function getSortDirection()
3434
/**
3535
* @inheritdoc
3636
*/
37-
public function getLabel(): string
37+
public function getLabel(): \Magento\Framework\Phrase
3838
{
3939
return __('Name: A - Z');
4040
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Name/Descending.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting\Name;
810

9-
use \Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
11+
use Magento\PageBuilder\Model\Catalog\Sorting\AttributeAbstract;
1012

1113
/**
1214
* Class Name\Descending
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting\Name
1515
*/
1616
class Descending extends AttributeAbstract
1717
{
@@ -34,7 +34,7 @@ protected function getSortDirection()
3434
/**
3535
* @inheritdoc
3636
*/
37-
public function getLabel(): string
37+
public function getLabel(): \Magento\Framework\Phrase
3838
{
3939
return __('Name: Z - A');
4040
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Options.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\PageBuilder\Model\Catalog\Sorting;
710

811
/**
912
* Class Sorting Options
10-
*
11-
* @package Magento\PageBuilder\Model\Catalog\Sorting
1213
*/
1314
class Options implements \Magento\Framework\Data\OptionSourceInterface
1415
{
@@ -18,8 +19,6 @@ class Options implements \Magento\Framework\Data\OptionSourceInterface
1819
private $sorting;
1920

2021
/**
21-
* Options constructor.
22-
*
2322
* @param \Magento\PageBuilder\Model\Catalog\Sorting $sorting
2423
*/
2524
public function __construct(

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Price/HighToLow.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting\Price;
810

9-
use \Magento\PageBuilder\Model\Catalog\Sorting\PriceAbstract;
11+
use Magento\PageBuilder\Model\Catalog\Sorting\PriceAbstract;
1012

1113
/**
1214
* Class Price\HighToLow
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting\Price
1515
*/
1616
class HighToLow extends PriceAbstract
1717
{
@@ -26,7 +26,7 @@ protected function getSortDirection()
2626
/**
2727
* @inheritdoc
2828
*/
29-
public function getLabel(): string
29+
public function getLabel(): \Magento\Framework\Phrase
3030
{
3131
return __('Price: high to low');
3232
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting/Price/LowToHigh.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\PageBuilder\Model\Catalog\Sorting\Price;
810

9-
use \Magento\PageBuilder\Model\Catalog\Sorting\PriceAbstract;
11+
use Magento\PageBuilder\Model\Catalog\Sorting\PriceAbstract;
1012

1113
/**
1214
* Class Price\LowToHigh
13-
*
14-
* @package Magento\PageBuilder\Model\Catalog\Sorting\Price
1515
*/
1616
class LowToHigh extends PriceAbstract
1717
{
@@ -26,7 +26,7 @@ protected function getSortDirection()
2626
/**
2727
* @inheritdoc
2828
*/
29-
public function getLabel(): string
29+
public function getLabel(): \Magento\Framework\Phrase
3030
{
3131
return __('Price: low to high');
3232
}

0 commit comments

Comments
 (0)