Skip to content

Commit 245453e

Browse files
Merge branch '2.4-develop' into fix-26976
2 parents a6cf5cb + f442fa9 commit 245453e

File tree

102 files changed

+1157
-1000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1157
-1000
lines changed

app/code/Magento/Backup/Model/ResourceModel/View/CreateViewsBackup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ public function getViewHeader(string $viewName): string
111111
public function getDropViewSql(string $viewName): string
112112
{
113113
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
114-
return sprintf('DROP VIEW IF EXISTS %s;\n', $quotedViewName);
114+
return sprintf("DROP VIEW IF EXISTS %s;\n", $quotedViewName);
115115
}
116116
}

app/code/Magento/Bundle/Test/Mftf/Test/AdminAddDefaultVideoBundleProductTest.xml

Lines changed: 0 additions & 70 deletions
This file was deleted.

app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultVideoBundleProductTest.xml

Lines changed: 0 additions & 70 deletions
This file was deleted.

app/code/Magento/Catalog/Helper/Product/ProductList.php

Lines changed: 46 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,37 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Catalog\Helper\Product;
89

10+
use Magento\Catalog\Model\Config;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\Registry;
14+
use Magento\Store\Model\ScopeInterface;
15+
916
/**
10-
* Class ProductList
17+
* Returns data for toolbars of Sorting and Pagination
1118
*
1219
* @api
1320
* @since 100.0.2
1421
*/
1522
class ProductList
1623
{
17-
/**
18-
* List mode configuration path
19-
*/
20-
const XML_PATH_LIST_MODE = 'catalog/frontend/list_mode';
24+
public const XML_PATH_LIST_MODE = 'catalog/frontend/list_mode';
25+
public const DEFAULT_SORT_DIRECTION = 'asc';
2126

2227
const VIEW_MODE_LIST = 'list';
2328
const VIEW_MODE_GRID = 'grid';
2429

25-
const DEFAULT_SORT_DIRECTION = 'asc';
2630
/**
27-
* @var \Magento\Framework\App\Config\ScopeConfigInterface
31+
* @var ScopeConfigInterface
2832
*/
2933
protected $scopeConfig;
3034

3135
/**
32-
* @var \Magento\Framework\Registry
36+
* @var Registry
3337
*/
3438
private $coreRegistry;
3539

@@ -38,20 +42,18 @@ class ProductList
3842
*
3943
* @var array
4044
*/
41-
protected $_defaultAvailableLimit = [10 => 10,20 => 20,50 => 50];
45+
protected $_defaultAvailableLimit = [10 => 10, 20 => 20, 50 => 50];
4246

4347
/**
44-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
45-
* @param \Magento\Framework\Registry $coreRegistry
48+
* @param ScopeConfigInterface $scopeConfig
49+
* @param Registry $coreRegistry
4650
*/
4751
public function __construct(
48-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
49-
\Magento\Framework\Registry $coreRegistry = null
52+
ScopeConfigInterface $scopeConfig,
53+
Registry $coreRegistry = null
5054
) {
5155
$this->scopeConfig = $scopeConfig;
52-
$this->coreRegistry = $coreRegistry ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
53-
\Magento\Framework\Registry::class
54-
);
56+
$this->coreRegistry = $coreRegistry ?? ObjectManager::getInstance()->get(Registry::class);
5557
}
5658

5759
/**
@@ -61,31 +63,23 @@ public function __construct(
6163
*/
6264
public function getAvailableViewMode()
6365
{
64-
$value = $this->scopeConfig->getValue(
65-
self::XML_PATH_LIST_MODE,
66-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
67-
);
66+
$value = $this->scopeConfig->getValue(self::XML_PATH_LIST_MODE, ScopeInterface::SCOPE_STORE);
67+
6868
switch ($value) {
6969
case 'grid':
70-
$availableMode = ['grid' => __('Grid')];
71-
break;
70+
return ['grid' => __('Grid')];
7271

7372
case 'list':
74-
$availableMode = ['list' => __('List')];
75-
break;
73+
return ['list' => __('List')];
7674

7775
case 'grid-list':
78-
$availableMode = ['grid' => __('Grid'), 'list' => __('List')];
79-
break;
76+
return ['grid' => __('Grid'), 'list' => __('List')];
8077

8178
case 'list-grid':
82-
$availableMode = ['list' => __('List'), 'grid' => __('Grid')];
83-
break;
84-
default:
85-
$availableMode = null;
86-
break;
79+
return ['list' => __('List'), 'grid' => __('Grid')];
8780
}
88-
return $availableMode;
81+
82+
return null;
8983
}
9084

9185
/**
@@ -99,12 +93,14 @@ public function getDefaultViewMode($options = [])
9993
if (empty($options)) {
10094
$options = $this->getAvailableViewMode();
10195
}
96+
10297
return current(array_keys($options));
10398
}
10499

105100
/**
106101
* Get default sort field
107102
*
103+
* @FIXME Helper should be context-independent
108104
* @return null|string
109105
*/
110106
public function getDefaultSortField()
@@ -114,59 +110,46 @@ public function getDefaultSortField()
114110
return $currentCategory->getDefaultSortBy();
115111
}
116112

117-
return $this->scopeConfig->getValue(
118-
\Magento\Catalog\Model\Config::XML_PATH_LIST_DEFAULT_SORT_BY,
119-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
120-
);
113+
return $this->scopeConfig->getValue(Config::XML_PATH_LIST_DEFAULT_SORT_BY, ScopeInterface::SCOPE_STORE);
121114
}
122115

123116
/**
124117
* Retrieve available limits for specified view mode
125118
*
126-
* @param string $mode
119+
* @param string $viewMode
127120
* @return array
128121
*/
129-
public function getAvailableLimit($mode)
122+
public function getAvailableLimit($viewMode): array
130123
{
131-
if (!in_array($mode, [self::VIEW_MODE_GRID, self::VIEW_MODE_LIST])) {
124+
$availableViewModes = $this->getAvailableViewMode();
125+
126+
if (!isset($availableViewModes[$viewMode])) {
132127
return $this->_defaultAvailableLimit;
133128
}
134-
$perPageConfigKey = 'catalog/frontend/' . $mode . '_per_page_values';
135-
$perPageValues = (string)$this->scopeConfig->getValue(
136-
$perPageConfigKey,
137-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
138-
);
129+
130+
$perPageConfigPath = 'catalog/frontend/' . $viewMode . '_per_page_values';
131+
$perPageValues = (string)$this->scopeConfig->getValue($perPageConfigPath, ScopeInterface::SCOPE_STORE);
139132
$perPageValues = explode(',', $perPageValues);
140133
$perPageValues = array_combine($perPageValues, $perPageValues);
141-
if ($this->scopeConfig->isSetFlag(
142-
'catalog/frontend/list_allow_all',
143-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
144-
)) {
134+
if ($this->scopeConfig->isSetFlag('catalog/frontend/list_allow_all', ScopeInterface::SCOPE_STORE)) {
145135
return ($perPageValues + ['all' => __('All')]);
146136
} else {
147137
return $perPageValues;
148138
}
149139
}
150140

151141
/**
152-
* Retrieve default per page values
142+
* Returns default value of `per_page` for view mode provided
153143
*
154144
* @param string $viewMode
155-
* @return string (comma separated)
145+
* @return int
156146
*/
157-
public function getDefaultLimitPerPageValue($viewMode)
147+
public function getDefaultLimitPerPageValue($viewMode): int
158148
{
159-
if ($viewMode == self::VIEW_MODE_LIST) {
160-
return $this->scopeConfig->getValue(
161-
'catalog/frontend/list_per_page',
162-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
163-
);
164-
} elseif ($viewMode == self::VIEW_MODE_GRID) {
165-
return $this->scopeConfig->getValue(
166-
'catalog/frontend/grid_per_page',
167-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
168-
);
169-
}
170-
return 0;
149+
$xmlConfigPath = sprintf('catalog/frontend/%s_per_page', $viewMode);
150+
$defaultLimit = $this->scopeConfig->getValue($xmlConfigPath, ScopeInterface::SCOPE_STORE);
151+
152+
$availableLimits = $this->getAvailableLimit($viewMode);
153+
return (int)($availableLimits[$defaultLimit] ?? current($availableLimits));
171154
}
172155
}

app/code/Magento/Catalog/Model/Product.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
7373
const STORE_ID = 'store_id';
7474

7575
/**
76-
* @var string
76+
* @var string|bool
7777
*/
78-
protected $_cacheTag = self::CACHE_TAG;
78+
protected $_cacheTag = false;
7979

8080
/**
8181
* @var string
@@ -878,7 +878,6 @@ public function getAttributes($groupId = null, $skipSuper = false)
878878
*/
879879
public function beforeSave()
880880
{
881-
$this->cleanCache();
882881
$this->setTypeHasOptions(false);
883882
$this->setTypeHasRequiredOptions(false);
884883
$this->setHasOptions(false);

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1010
<section name="AdminProductGridSection">
1111
<element name="productRowBySku" type="block" selector="//td[count(../../..//th[./*[.='SKU']]/preceding-sibling::th) + 1][./*[.='{{sku}}']]" parameterized="true" />
12+
<element name="productRowByName" type="block" selector="//td[count(../../..//th[./*[.='Name']]/preceding-sibling::th) + 1][./*[.='{{sku}}']]" parameterized="true" />
1213
<element name="productRowCheckboxBySku" type="block" selector="//td[count(../../..//th[./*[.='SKU']]/preceding-sibling::th) + 1][./*[.='{{sku}}']]/../td//input[@data-action='select-row']" parameterized="true" />
1314
<element name="loadingMask" type="text" selector=".admin__data-grid-loading-mask[data-component*='product_listing']"/>
1415
<element name="columnHeader" type="button" selector="//div[@data-role='grid-wrapper']//table[contains(@class, 'data-grid')]/thead/tr/th[contains(@class, 'data-grid-th')]/span[text() = '{{label}}']" parameterized="true" timeout="30"/>
@@ -35,5 +36,6 @@
3536
<element name="productGridContentsOnRow" type="checkbox" selector="//*[@id='container']//tr[{{row}}]/td" parameterized="true"/>
3637
<element name="selectRowBasedOnName" type="input" selector="//td/div[text()='{{var1}}']" parameterized="true"/>
3738
<element name="changeStatus" type="button" selector="//div[contains(@class,'admin__data-grid-header-row') and contains(@class, 'row')]//div[contains(@class, 'action-menu-item')]//ul/li/span[text() = '{{status}}']" parameterized="true"/>
39+
<element name="productRowByTypeAndName" type="block" selector="//div[@data-role='grid-wrapper']//table[contains(@class, 'data-grid')]//td[count(../../..//th[./*[.='Type']]/preceding-sibling::th) + 1][./*[.='{{type}}']]/../td[contains(.,'{{name}}')]" parameterized="true" />
3840
</section>
3941
</sections>

0 commit comments

Comments
 (0)