Skip to content

Commit 8f4a473

Browse files
committed
Merge branch '2.3-develop' of github.com:magento-engcom/magento2ce into 2.3-develop
2 parents a9e49f9 + f710f9b commit 8f4a473

File tree

113 files changed

+1788
-358
lines changed

Some content is hidden

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

113 files changed

+1788
-358
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/ActionGroup/AdminProductActionGroup.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,10 @@
257257
<arguments>
258258
<argument name="website" type="string"/>
259259
</arguments>
260-
<scrollTo selector="{{CreateProductSection.productInWebsite}}" stepKey="ScrollToWebsites"/>
261-
<click selector="{{CreateProductSection.productInWebsite}}" stepKey="ClickTpOpenProductInWebsite"/>
260+
<scrollTo selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="scrollToWebsites"/>
261+
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="clickToOpenProductInWebsite"/>
262262
<waitForPageLoad stepKey="waitForPageOpened"/>
263-
<click selector="{{CreateProductSection.isSelected(website)}}" stepKey="SelectWebsite"/>
264-
<click selector="{{CreateProductSection.saveButton}}" stepKey="clickSaveProduct"/>
263+
<checkOption selector="{{ProductInWebsitesSection.website(website)}}" stepKey="selectWebsite"/>
265264
</actionGroup>
266265

267266
<!--Switch to New Store view-->

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,26 @@
2020
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow"/>
2121
<waitForPageLoad stepKey="waitForPageLoad2" />
2222
</actionGroup>
23+
<actionGroup name="navigateToEditProductAttribute">
24+
<arguments>
25+
<argument name="ProductAttribute" type="string"/>
26+
</arguments>
27+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/>
28+
<waitForPageLoad stepKey="waitForPageLoad1"/>
29+
<fillField selector="{{AdminProductAttributeGridSection.GridFilterFrontEndLabel}}" userInput="{{ProductAttribute}}" stepKey="navigateToAttributeEditPage1" />
30+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="navigateToAttributeEditPage2" />
31+
<waitForPageLoad stepKey="waitForPageLoad2" />
32+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="navigateToAttributeEditPage3" />
33+
<waitForPageLoad stepKey="waitForPageLoad3" />
34+
</actionGroup>
35+
<actionGroup name="changeUseForPromoRuleConditionsProductAttribute">
36+
<arguments>
37+
<argument name="option" type="string"/>
38+
</arguments>
39+
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStoreFrontPropertiesTab"/>
40+
<waitForPageLoad stepKey="waitForPageLoad"/>
41+
<selectOption selector="{{StorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="{{option}}" stepKey="changeOption"/>
42+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveAttribute"/>
43+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product attribute." stepKey="successMessage"/>
44+
</actionGroup>
2345
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
<argument name="mode" type="string"/>
1616
<argument name="numOfProductsPerPage" type="string"/>
1717
<argument name="sortBy" type="string" defaultValue="position"/>
18+
<argument name="sort" type="string" defaultValue="asc"/>
1819
</arguments>
1920
<!-- Go to storefront category page -->
20-
<amOnPage url="{{StorefrontCategoryPage.url(category)}}?product_list_limit={{numOfProductsPerPage}}&amp;product_list_mode={{mode}}&amp;product_list_order={{sortBy}}" stepKey="onCategoryPage"/>
21+
<amOnPage url="{{StorefrontCategoryPage.url(category)}}?product_list_limit={{numOfProductsPerPage}}&amp;product_list_mode={{mode}}&amp;product_list_order={{sortBy}}&amp;product_list_dir={{sort}}" stepKey="onCategoryPage"/>
2122
<waitForPageLoad stepKey="waitForPageLoad"/>
2223
</actionGroup>
2324

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@
1616
<data key="store_id">0</data>
1717
<data key="label" unique="suffix">attributeTwo</data>
1818
</entity>
19+
<entity name="ProductAttributeFrontendLabelThree" type="FrontendLabel">
20+
<data key="store_id">0</data>
21+
<data key="label" unique="suffix">attributeThree</data>
22+
</entity>
1923
</entities>

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>

0 commit comments

Comments
 (0)