Skip to content

Commit 45169c1

Browse files
committed
Merge branch 'develop' of github.com:magento-commerce/magento2-page-builder into jquery-upgrade
2 parents 657d0e9 + cad5f5d commit 45169c1

File tree

7 files changed

+1207
-1001
lines changed

7 files changed

+1207
-1001
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Model\Catalog\Sorting\Category;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
11+
use Magento\Framework\DB\Select;
12+
use Magento\Framework\Phrase;
13+
use Magento\PageBuilder\Model\Catalog\Sorting\OptionInterface;
14+
use Magento\Store\Model\Store;
15+
16+
/**
17+
* Sort catalog products by their positions in the category
18+
*/
19+
class Position implements OptionInterface
20+
{
21+
/**
22+
* @var string
23+
*/
24+
private $label;
25+
26+
/**
27+
* @var string
28+
*/
29+
private $sortDirection;
30+
31+
/**
32+
* @var string
33+
*/
34+
private $secondarySortDirection;
35+
36+
/**
37+
* @param string $label
38+
* @param string $sortDirection
39+
* @param string|null $secondarySortDirection
40+
*/
41+
public function __construct(
42+
string $label,
43+
string $sortDirection = Select::SQL_ASC,
44+
?string $secondarySortDirection = null
45+
) {
46+
$this->label = $label;
47+
$this->sortDirection = $sortDirection;
48+
$this->secondarySortDirection = $secondarySortDirection ?? $sortDirection;
49+
}
50+
51+
/**
52+
* @inheritDoc
53+
*/
54+
public function sort(Collection $collection): Collection
55+
{
56+
$collection->getSelect()->reset(Select::ORDER);
57+
$filters = $collection->getLimitationFilters();
58+
if ($collection->getStoreId() === Store::DEFAULT_STORE_ID && isset($filters['category_id'])) {
59+
$collection->getSelect()->order("cat_index_position $this->sortDirection");
60+
} else {
61+
$collection->addAttributeToSort('position', $this->sortDirection);
62+
}
63+
if ($this->secondarySortDirection) {
64+
$collection->addAttributeToSort('entity_id', $this->secondarySortDirection);
65+
}
66+
return $collection;
67+
}
68+
69+
/**
70+
* @inheritdoc
71+
*/
72+
public function getLabel(): Phrase
73+
{
74+
return __($this->label);
75+
}
76+
}

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderBannerPosterAppearanceTest/BannerPosterVideoBackgroundNoFallbackImageDisabledLoopAndPlayWhenVisibleAndLazyLoad.xml

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
<!-- Validate Edit Panel After Save -->
111111
<actionGroup ref="openPageBuilderEditPanel" stepKey="openEditPanelAfterSave">
112112
<argument name="contentType" value="PageBuilderBannerContentType"/>
113+
<argument name="offsetXCoordinate" value="null"/>
114+
<argument name="offsetYCoordinate" value="null"/>
113115
</actionGroup>
114116
<actionGroup ref="seeInFieldSlideOutProperty" stepKey="validateBackgroundColorEmptyAfterSave">
115117
<argument name="property" value="PageBuilderBackgroundColor_Default"/>

app/code/Magento/PageBuilder/Ui/DataProvider/Product/ProductCollection.php

+30
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,34 @@ protected function _productLimitationJoinPrice()
3838
$this->_productLimitationFilters->setUsePriceIndex($this->getStoreId() !== Store::DEFAULT_STORE_ID);
3939
return $this->_productLimitationPrice(false);
4040
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
protected function _applyZeroStoreProductLimitations()
46+
{
47+
$conditions = [
48+
'cat_pro.product_id=e.entity_id',
49+
$this->getConnection()->quoteInto(
50+
'cat_pro.category_id = ?',
51+
$this->_productLimitationFilters['category_id'],
52+
\Zend_Db::INT_TYPE
53+
),
54+
];
55+
$joinCond = join(' AND ', $conditions);
56+
$fromPart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::FROM);
57+
if (isset($fromPart['cat_pro'])) {
58+
$fromPart['cat_pro']['joinCondition'] = $joinCond;
59+
$this->getSelect()->setPart(\Magento\Framework\DB\Select::FROM, $fromPart);
60+
} else {
61+
$this->getSelect()->joinLeft(
62+
['cat_pro' => $this->getTable('catalog_category_product')],
63+
$joinCond,
64+
['cat_index_position' => $this->getConnection()->getIfNullSql('position', '~0')]
65+
);
66+
}
67+
$this->_joinFields['position'] = ['table' => 'cat_pro', 'field' => 'position'];
68+
69+
return $this;
70+
}
4171
}

app/code/Magento/PageBuilder/etc/di.xml

+9-1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
<argument name="sortDirection" xsi:type="const">\Magento\Framework\DB\Select::SQL_ASC</argument>
266266
</arguments>
267267
</virtualType>
268+
<!-- @deprecated no longer used -->
268269
<virtualType name="Magento\PageBuilder\Model\Catalog\Sorting\Position" type="Magento\PageBuilder\Model\Catalog\Sorting\SimpleOption">
269270
<arguments>
270271
<argument name="label" xsi:type="string">Position</argument>
@@ -290,10 +291,17 @@
290291
<argument name="sortDirection" xsi:type="const">\Magento\Framework\DB\Select::SQL_ASC</argument>
291292
</arguments>
292293
</virtualType>
294+
<virtualType name="Magento\PageBuilder\Model\Catalog\Sorting\Position\Ascending" type="Magento\PageBuilder\Model\Catalog\Sorting\Category\Position">
295+
<arguments>
296+
<argument name="label" xsi:type="string">Position</argument>
297+
<argument name="sortDirection" xsi:type="const">\Magento\Framework\DB\Select::SQL_ASC</argument>
298+
<argument name="secondarySortDirection" xsi:type="const">\Magento\Framework\DB\Select::SQL_DESC</argument>
299+
</arguments>
300+
</virtualType>
293301
<type name="Magento\PageBuilder\Model\Catalog\Sorting">
294302
<arguments>
295303
<argument name="sortClasses" xsi:type="array">
296-
<item name="position" xsi:type="string">Magento\PageBuilder\Model\Catalog\Sorting\Position</item>
304+
<item name="position" xsi:type="string">Magento\PageBuilder\Model\Catalog\Sorting\Position\Ascending</item>
297305
<item name="position_by_sku" xsi:type="string">Magento\PageBuilder\Model\Catalog\Sorting\PositionBySku</item>
298306
<item name="date_newest_top" xsi:type="string">Magento\PageBuilder\Model\Catalog\Sorting\Date\NewestTop</item>
299307
<item name="date_oldest_top" xsi:type="string">Magento\PageBuilder\Model\Catalog\Sorting\Date\OldestTop</item>

0 commit comments

Comments
 (0)