Skip to content

Commit 84eaab4

Browse files
committed
Merge branch '2.3-develop' into reece-pr
2 parents 8ff9c74 + 515218f commit 84eaab4

File tree

100 files changed

+1378
-349
lines changed

Some content is hidden

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

100 files changed

+1378
-349
lines changed

app/code/Magento/AdvancedSearch/Model/Recommendations/DataProvider.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Search\Model\QueryInterface;
1111
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;
1212

13+
/**
14+
* Class DataProvider
15+
*/
1316
class DataProvider implements SuggestedQueriesInterface
1417
{
1518
/**
@@ -51,6 +54,8 @@ class DataProvider implements SuggestedQueriesInterface
5154
private $recommendationsFactory;
5255

5356
/**
57+
* DataProvider constructor.
58+
*
5459
* @param ScopeConfigInterface $scopeConfig
5560
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
5661
* @param \Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory $recommendationsFactory
@@ -69,18 +74,20 @@ public function __construct(
6974
}
7075

7176
/**
77+
* Is Results Count Enabled
78+
*
7279
* @return bool
7380
*/
7481
public function isResultsCountEnabled()
7582
{
76-
return (bool)$this->scopeConfig->getValue(
83+
return $this->scopeConfig->isSetFlag(
7784
self::CONFIG_RESULTS_COUNT_ENABLED,
7885
ScopeInterface::SCOPE_STORE
7986
);
8087
}
8188

8289
/**
83-
* {@inheritdoc}
90+
* @inheritdoc
8491
*/
8592
public function getItems(QueryInterface $query)
8693
{
@@ -102,6 +109,8 @@ public function getItems(QueryInterface $query)
102109
}
103110

104111
/**
112+
* Return Search Recommendations
113+
*
105114
* @param QueryInterface $query
106115
* @return array
107116
*/
@@ -126,17 +135,21 @@ private function getSearchRecommendations(\Magento\Search\Model\QueryInterface $
126135
}
127136

128137
/**
138+
* Is Search Recommendations Enabled
139+
*
129140
* @return bool
130141
*/
131142
private function isSearchRecommendationsEnabled()
132143
{
133-
return (bool)$this->scopeConfig->getValue(
144+
return $this->scopeConfig->isSetFlag(
134145
self::CONFIG_IS_ENABLED,
135146
ScopeInterface::SCOPE_STORE
136147
);
137148
}
138149

139150
/**
151+
* Return Search Recommendations Count
152+
*
140153
* @return int
141154
*/
142155
private function getSearchRecommendationsCount()

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,9 @@ class ImageUploader
6767
/**
6868
* List of allowed image mime types
6969
*
70-
* @var array
70+
* @var string[]
7171
*/
72-
private $allowedMimeTypes = [
73-
'image/jpg',
74-
'image/jpeg',
75-
'image/gif',
76-
'image/png',
77-
];
72+
private $allowedMimeTypes;
7873

7974
/**
8075
* ImageUploader constructor
@@ -87,6 +82,7 @@ class ImageUploader
8782
* @param string $baseTmpPath
8883
* @param string $basePath
8984
* @param string[] $allowedExtensions
85+
* @param string[] $allowedMimeTypes
9086
*/
9187
public function __construct(
9288
\Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase,
@@ -96,7 +92,8 @@ public function __construct(
9692
\Psr\Log\LoggerInterface $logger,
9793
$baseTmpPath,
9894
$basePath,
99-
$allowedExtensions
95+
$allowedExtensions,
96+
$allowedMimeTypes = []
10097
) {
10198
$this->coreFileStorageDatabase = $coreFileStorageDatabase;
10299
$this->mediaDirectory = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
@@ -106,6 +103,7 @@ public function __construct(
106103
$this->baseTmpPath = $baseTmpPath;
107104
$this->basePath = $basePath;
108105
$this->allowedExtensions = $allowedExtensions;
106+
$this->allowedMimeTypes = $allowedMimeTypes;
109107
}
110108

111109
/**
@@ -165,7 +163,7 @@ public function getBasePath()
165163
}
166164

167165
/**
168-
* Retrieve base path
166+
* Retrieve allowed extensions
169167
*
170168
* @return string[]
171169
*/

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
7171
*/
7272
const STORE_ID = 'store_id';
7373

74+
/**
75+
* Product Url path.
76+
*/
77+
const URL_PATH = 'url_path';
78+
7479
/**
7580
* @var string
7681
*/
@@ -591,6 +596,7 @@ public function getPrice()
591596
* @see \Magento\Catalog\Model\Product\Visibility
592597
*
593598
* @return int
599+
* @codeCoverageIgnoreStart
594600
*/
595601
public function getVisibility()
596602
{
@@ -813,6 +819,9 @@ public function getStoreIds()
813819
if (!$this->hasStoreIds()) {
814820
$storeIds = [];
815821
if ($websiteIds = $this->getWebsiteIds()) {
822+
if ($this->_storeManager->isSingleStoreMode()) {
823+
$websiteIds = array_keys($websiteIds);
824+
}
816825
foreach ($websiteIds as $websiteId) {
817826
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
818827
$storeIds = array_merge($storeIds, $websiteStores);
@@ -923,8 +932,8 @@ public function beforeSave()
923932
*
924933
* If value specified, it will be set.
925934
*
926-
* @param bool $value
927-
* @return bool
935+
* @param bool $value
936+
* @return bool
928937
*/
929938
public function canAffectOptions($value = null)
930939
{
@@ -1044,7 +1053,8 @@ public function reindex()
10441053
*
10451054
* Register indexing event before delete product
10461055
*
1047-
* @return \Magento\Catalog\Model\Product
1056+
* @return $this
1057+
* @throws \Magento\Framework\Exception\LocalizedException
10481058
*/
10491059
public function beforeDelete()
10501060
{
@@ -1718,8 +1728,6 @@ public function getIsSalable()
17181728
/**
17191729
* Check is a virtual product
17201730
*
1721-
* Data helper wrapper
1722-
*
17231731
* @return bool
17241732
*/
17251733
public function isVirtual()
@@ -2028,7 +2036,7 @@ public function getIsVirtual()
20282036
*
20292037
* @param string $code Option code
20302038
* @param mixed $value Value of the option
2031-
* @param int|Product $product Product ID
2039+
* @param int|Product|null $product Product ID
20322040
* @return $this
20332041
*/
20342042
public function addCustomOption($code, $value, $product = null)
@@ -2222,9 +2230,9 @@ public function getPreconfiguredValues()
22222230
}
22232231

22242232
/**
2225-
* Prepare product custom options.
2233+
* Prepare product custom options
22262234
*
2227-
* To be sure that all product custom options does not has ID and has product instance
2235+
* To be sure that all product custom options does not has ID and has product instance.
22282236
*
22292237
* @return \Magento\Catalog\Model\Product
22302238
*/
@@ -2581,10 +2589,11 @@ public function setExtensionAttributes(\Magento\Catalog\Api\Data\ProductExtensio
25812589
//@codeCoverageIgnoreEnd
25822590

25832591
/**
2584-
* Convert array to media gallery interface
2592+
* Convert Image to ProductAttributeMediaGalleryEntryInterface
25852593
*
25862594
* @param array $mediaGallery
25872595
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]
2596+
* @throws \Magento\Framework\Exception\LocalizedException
25882597
*/
25892598
protected function convertToMediaGalleryInterface(array $mediaGallery)
25902599
{
@@ -2603,6 +2612,7 @@ protected function convertToMediaGalleryInterface(array $mediaGallery)
26032612
* Returns media gallery entries
26042613
*
26052614
* @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]|null
2615+
* @throws \Magento\Framework\Exception\LocalizedException
26062616
*/
26072617
public function getMediaGalleryEntries()
26082618
{
@@ -2620,6 +2630,7 @@ public function getMediaGalleryEntries()
26202630
*
26212631
* @param ProductAttributeMediaGalleryEntryInterface[] $mediaGalleryEntries
26222632
* @return $this
2633+
* @throws \Magento\Framework\Exception\LocalizedException
26232634
*/
26242635
public function setMediaGalleryEntries(array $mediaGalleryEntries = null)
26252636
{

app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ public function execute($entity, $arguments = [])
9292
$productId = (int) $entity->getData($identifierField);
9393

9494
// prepare original data to compare
95-
$origPrices = $entity->getOrigData($attribute->getName());
95+
$origPrices = [];
96+
$originalId = $entity->getOrigData($identifierField);
97+
if (empty($originalId) || $entity->getData($identifierField) == $originalId) {
98+
$origPrices = $entity->getOrigData($attribute->getName());
99+
}
100+
96101
$old = $this->prepareOriginalDataToCompare($origPrices, $isGlobal);
97102
// prepare data for save
98103
$new = $this->prepareNewDataForSave($priceRows, $isGlobal);

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
namespace Magento\Catalog\Model\Product;
99

1010
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Catalog\Model\Product;
1112

13+
/**
14+
* The copier creates product duplicates.
15+
*/
1216
class Copier
1317
{
1418
/**
@@ -49,7 +53,7 @@ public function __construct(
4953
* @param \Magento\Catalog\Model\Product $product
5054
* @return \Magento\Catalog\Model\Product
5155
*/
52-
public function copy(\Magento\Catalog\Model\Product $product)
56+
public function copy(Product $product)
5357
{
5458
$product->getWebsiteIds();
5559
$product->getCategoryIds();
@@ -79,6 +83,7 @@ public function copy(\Magento\Catalog\Model\Product $product)
7983
? $matches[1] . '-' . ($matches[2] + 1)
8084
: $urlKey . '-1';
8185
$duplicate->setUrlKey($urlKey);
86+
$duplicate->setData(Product::URL_PATH, null);
8287
try {
8388
$duplicate->save();
8489
$isDuplicateSaved = true;
@@ -94,6 +99,8 @@ public function copy(\Magento\Catalog\Model\Product $product)
9499
}
95100

96101
/**
102+
* Returns product option repository.
103+
*
97104
* @return Option\Repository
98105
* @deprecated 101.0.0
99106
*/
@@ -107,6 +114,8 @@ private function getOptionRepository()
107114
}
108115

109116
/**
117+
* Returns metadata pool.
118+
*
110119
* @return \Magento\Framework\EntityManager\MetadataPool
111120
* @deprecated 101.0.0
112121
*/

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,17 @@
420420
<data key="status">1</data>
421421
<requiredEntity type="product_extension_attribute">EavStock100</requiredEntity>
422422
</entity>
423+
<entity name="ApiSimpleSingleQty" type="product2">
424+
<data key="sku" unique="suffix">api-simple-product</data>
425+
<data key="type_id">simple</data>
426+
<data key="attribute_set_id">4</data>
427+
<data key="visibility">4</data>
428+
<data key="name" unique="suffix">Api Simple Product</data>
429+
<data key="price">123.00</data>
430+
<data key="urlKey" unique="suffix">api-simple-product</data>
431+
<data key="status">1</data>
432+
<data key="quantity">1</data>
433+
<requiredEntity type="product_extension_attribute">EavStock1</requiredEntity>
434+
<requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity>
435+
</entity>
423436
</entities>

app/code/Magento/Catalog/Test/Mftf/Data/ProductExtensionAttributeData.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
<entity name="EavStock10" type="product_extension_attribute">
1818
<requiredEntity type="stock_item">Qty_10</requiredEntity>
1919
</entity>
20+
<entity name="EavStock1" type="product_extension_attribute">
21+
<requiredEntity type="stock_item">Qty_1</requiredEntity>
22+
</entity>
2023
</entities>

app/code/Magento/Catalog/Test/Mftf/Data/StockItemData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@
2828
<data key="qty">101</data>
2929
<data key="is_in_stock">true</data>
3030
</entity>
31+
<entity name="Qty_1" type="stock_item">
32+
<data key="qty">1</data>
33+
<data key="is_in_stock">true</data>
34+
</entity>
3135
</entities>

app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ public function testExecute(): void
120120
['entity_id', $productId]
121121
]
122122
);
123-
$product->expects($this->atLeastOnce())->method('getOrigData')->with('tier_price')
124-
->willReturn($originalTierPrices);
123+
$product->expects($this->atLeastOnce())->method('getOrigData')
124+
->willReturnMap(
125+
[
126+
['tier_price', $originalTierPrices],
127+
['entity_id', $productId]
128+
]
129+
);
125130
$product->expects($this->atLeastOnce())->method('getStoreId')->willReturn(0);
126131
$product->expects($this->atLeastOnce())->method('setData')->with('tier_price_changed', 1);
127132
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)

app/code/Magento/Catalog/Test/Unit/Model/ImageUploaderTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ class ImageUploaderTest extends \PHPUnit\Framework\TestCase
6969
/**
7070
* Allowed extensions
7171
*
72-
* @var string
72+
* @var array
7373
*/
7474
private $allowedExtensions;
7575

76+
/**
77+
* Allowed mime types
78+
*
79+
* @var array
80+
*/
81+
private $allowedMimeTypes;
82+
7683
protected function setUp()
7784
{
7885
$this->coreFileStorageDatabaseMock = $this->createMock(
@@ -97,6 +104,7 @@ protected function setUp()
97104
$this->baseTmpPath = 'base/tmp/';
98105
$this->basePath = 'base/real/';
99106
$this->allowedExtensions = ['.jpg'];
107+
$this->allowedMimeTypes = ['image/jpg', 'image/jpeg', 'image/gif', 'image/png'];
100108

101109
$this->imageUploader =
102110
new \Magento\Catalog\Model\ImageUploader(
@@ -107,7 +115,8 @@ protected function setUp()
107115
$this->loggerMock,
108116
$this->baseTmpPath,
109117
$this->basePath,
110-
$this->allowedExtensions
118+
$this->allowedExtensions,
119+
$this->allowedMimeTypes
111120
);
112121
}
113122

0 commit comments

Comments
 (0)