Skip to content

Commit 154dff4

Browse files
committed
PB-276: Error on PageBuilder if sortInstances[$sortOption] is not exists
- Don’t sort unless we have a sort builder
1 parent 4b1f0ef commit 154dff4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ public function applySorting(
8585
\Magento\Catalog\Model\ResourceModel\Product\Collection $collection
8686
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
8787
$sortBuilder = $this->getSortingInstance($option);
88-
$_collection = $sortBuilder->sort($collection);
88+
if ($sortBuilder) {
89+
$collection = $sortBuilder->sort($collection);
90+
}
8991

90-
if ($_collection->isLoaded()) {
91-
$_collection->clear();
92+
if ($collection->isLoaded()) {
93+
$collection->clear();
9294
}
9395

94-
return $_collection;
96+
return $collection;
9597
}
9698
}

0 commit comments

Comments
 (0)