Skip to content

Commit d7a4ddc

Browse files
authored
Merge pull request #7849 from magento-l3/PR_11_AUG_2022_odubovyk
L3 Bugfix Delivery
2 parents 9aa35fd + 8525691 commit d7a4ddc

File tree

14 files changed

+492
-57
lines changed

14 files changed

+492
-57
lines changed

app/code/Magento/Bundle/Model/Option/SaveAction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class SaveAction
5050
* @param Type $type
5151
* @param ProductLinkManagementInterface $linkManagement
5252
* @param StoreManagerInterface|null $storeManager
53+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5354
*/
5455
public function __construct(
5556
Option $optionResource,
@@ -84,11 +85,10 @@ public function save(ProductInterface $bundleProduct, OptionInterface $option)
8485
$optionId = $option->getOptionId();
8586
$linksToAdd = [];
8687
$optionCollection = $this->type->getOptionsCollection($bundleProduct);
87-
$optionCollection->setIdFilter($option->getOptionId());
88-
$optionCollection->setProductLinkFilter($parentId);
8988

9089
/** @var \Magento\Bundle\Model\Option $existingOption */
91-
$existingOption = $optionCollection->getFirstItem();
90+
$existingOption = $optionCollection->getItemById($option->getOptionId())
91+
?? $optionCollection->getNewEmptyItem();
9292
if (!$optionId || $existingOption->getParentId() != $parentId) {
9393
//If option ID is empty or existing option's parent ID is different
9494
//we'd need a new ID for the option.

app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class Currencysymbol
2727
protected $_symbolsData = [];
2828

2929
/**
30-
* Store id
30+
* Current store id
3131
*
3232
* @var string|null
3333
*/
3434
protected $_storeId;
3535

3636
/**
37-
* Website id
37+
* Current website id
3838
*
3939
* @var string|null
4040
*/
@@ -55,19 +55,19 @@ class Currencysymbol
5555
/**
5656
* Config path to custom currency symbol value
5757
*/
58-
const XML_PATH_CUSTOM_CURRENCY_SYMBOL = 'currency/options/customsymbol';
58+
public const XML_PATH_CUSTOM_CURRENCY_SYMBOL = 'currency/options/customsymbol';
5959

60-
const XML_PATH_ALLOWED_CURRENCIES = \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW;
60+
public const XML_PATH_ALLOWED_CURRENCIES = \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW;
6161

6262
/*
6363
* Separator used in config in allowed currencies list
6464
*/
65-
const ALLOWED_CURRENCIES_CONFIG_SEPARATOR = ',';
65+
public const ALLOWED_CURRENCIES_CONFIG_SEPARATOR = ',';
6666

6767
/**
6868
* Config currency section
6969
*/
70-
const CONFIG_SECTION = 'currency';
70+
public const CONFIG_SECTION = 'currency';
7171

7272
/**
7373
* Core event manager proxy
@@ -174,11 +174,11 @@ public function getCurrencySymbolsData()
174174

175175
if (isset($currentSymbols[$code]) && !empty($currentSymbols[$code])) {
176176
$this->_symbolsData[$code]['displaySymbol'] = $currentSymbols[$code];
177+
$this->_symbolsData[$code]['inherited'] = false;
177178
} else {
178179
$this->_symbolsData[$code]['displaySymbol'] = $this->_symbolsData[$code]['parentSymbol'];
180+
$this->_symbolsData[$code]['inherited'] = true;
179181
}
180-
$this->_symbolsData[$code]['inherited'] =
181-
($this->_symbolsData[$code]['parentSymbol'] == $this->_symbolsData[$code]['displaySymbol']);
182182
}
183183

184184
return $this->_symbolsData;
@@ -193,8 +193,8 @@ public function getCurrencySymbolsData()
193193
public function setCurrencySymbolsData($symbols = [])
194194
{
195195
if (!$this->_storeManager->isSingleStoreMode()) {
196-
foreach ($this->getCurrencySymbolsData() as $code => $values) {
197-
if (isset($symbols[$code]) && ($symbols[$code] == $values['parentSymbol'] || empty($symbols[$code]))) {
196+
foreach (array_keys($this->getCurrencySymbolsData()) as $code) {
197+
if (isset($symbols[$code]) && empty($symbols[$code])) {
198198
unset($symbols[$code]);
199199
}
200200
}

app/code/Magento/Deploy/Package/Processor/PreProcessor/Css.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ private function hasOverrides(PackageFile $parentFile, Package $package)
120120
return false;
121121
}
122122

123+
/**
124+
* See if given path is local or remote URL
125+
*
126+
* @param string $path
127+
* @return bool
128+
*/
129+
private function isLocal(string $path): bool
130+
{
131+
$pattern = '{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i';
132+
$result = preg_match($pattern, $path);
133+
134+
return is_int($result) ? (bool) $result : true;
135+
}
136+
123137
/**
124138
* Build map file
125139
*
@@ -138,10 +152,14 @@ private function buildMap($packagePath, $filePath, $fullPath)
138152
$content = $this->staticDir->readFile($this->minification->addMinifiedSign($fullPath));
139153

140154
$callback = function ($matchContent) use ($packagePath, $filePath, &$imports) {
141-
$importRelPath = $this->normalize(pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']);
142-
$imports[$importRelPath] = $this->normalize(
143-
$packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']
144-
);
155+
if ($this->isLocal($matchContent['path'])) {
156+
$importRelPath = $this->normalize(
157+
pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']
158+
);
159+
$imports[$importRelPath] = $this->normalize(
160+
$packagePath . '/' . pathinfo($filePath, PATHINFO_DIRNAME) . '/' . $matchContent['path']
161+
);
162+
}
145163
};
146164
preg_replace_callback(Import::REPLACE_PATTERN, $callback, $content);
147165

app/code/Magento/Paypal/Controller/Express/AbstractExpress/PlaceOrder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ public function execute()
112112
->setLastOrderStatus($order->getStatus());
113113
}
114114

115+
$this->_eventManager->dispatch(
116+
'checkout_submit_all_after',
117+
[
118+
'order' => $order,
119+
'quote' => $this->_getQuote()
120+
]
121+
);
122+
115123
$this->_eventManager->dispatch(
116124
'paypal_express_place_order_success',
117125
[

app/code/Magento/Paypal/Controller/Express/OnAuthorization.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ public function execute(): ResultInterface
142142
->setLastRealOrderId($order->getIncrementId())
143143
->setLastOrderStatus($order->getStatus());
144144

145+
$this->_eventManager->dispatch(
146+
'checkout_submit_all_after',
147+
[
148+
'order' => $order,
149+
'quote' => $quote
150+
]
151+
);
152+
145153
$this->_eventManager->dispatch(
146154
'paypal_express_place_order_success',
147155
[

dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66

77
namespace Magento\Bundle\Api;
88

9+
use Magento\Bundle\Test\Fixture\Option as BundleOptionFixture;
10+
use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
911
use Magento\Catalog\Api\Data\ProductInterface;
12+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1013
use Magento\Framework\Api\ExtensibleDataInterface;
14+
use Magento\Store\Test\Fixture\Store as StoreFixture;
15+
use Magento\TestFramework\Fixture\DataFixture;
16+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1117
use Magento\TestFramework\Helper\Bootstrap;
1218
use Magento\TestFramework\TestCase\WebapiAbstract;
1319
use Magento\Bundle\Api\Data\LinkInterface;
@@ -17,31 +23,39 @@
1723
*/
1824
class ProductServiceTest extends WebapiAbstract
1925
{
20-
const SERVICE_NAME = 'catalogProductRepositoryV1';
21-
const SERVICE_VERSION = 'V1';
22-
const RESOURCE_PATH = '/V1/products';
23-
const BUNDLE_PRODUCT_ID = 'sku-test-product-bundle';
26+
private const SERVICE_NAME = 'catalogProductRepositoryV1';
27+
private const SERVICE_VERSION = 'V1';
28+
private const RESOURCE_PATH = '/V1/products';
29+
private const BUNDLE_PRODUCT_ID = 'sku-test-product-bundle';
2430

2531
/**
2632
* @var \Magento\Catalog\Model\ResourceModel\Product\Collection
2733
*/
2834
protected $productCollection;
2935

36+
/**
37+
* @var bool
38+
*/
39+
private $cleanUpOnTearDown = true;
40+
3041
/**
3142
* Execute per test initialization
3243
*/
3344
protected function setUp(): void
3445
{
3546
$objectManager = Bootstrap::getObjectManager();
3647
$this->productCollection = $objectManager->get(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
48+
$this->cleanUpOnTearDown = true;
3749
}
3850

3951
/**
4052
* Execute per test cleanup
4153
*/
4254
protected function tearDown(): void
4355
{
44-
$this->deleteProductBySku(self::BUNDLE_PRODUCT_ID);
56+
if ($this->cleanUpOnTearDown) {
57+
$this->deleteProductBySku(self::BUNDLE_PRODUCT_ID);
58+
}
4559
parent::tearDown();
4660
}
4761

@@ -269,7 +283,6 @@ public function testUpdateFixedPriceBundleProductOptionSelectionPrice()
269283
$bundleProduct = $this->createFixedPriceBundleProduct();
270284
$bundleProductOptions = $this->getBundleProductOptions($bundleProduct);
271285

272-
$oldOptionId = $bundleProductOptions[0]['option_id'];
273286
//replace current option with a new option
274287
$bundleProductOptions[0] = [
275288
'title' => 'new option',
@@ -295,6 +308,52 @@ public function testUpdateFixedPriceBundleProductOptionSelectionPrice()
295308
$this->assertEquals($optionPrice, $bundleOptions[0]['product_links'][0]['price']);
296309
}
297310

311+
#[
312+
DataFixture(StoreFixture::class, as: 'store2'),
313+
DataFixture(ProductFixture::class, ['price' => 10], 'p1'),
314+
DataFixture(ProductFixture::class, ['price' => 20], 'p2'),
315+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$p1$']], 'opt1'),
316+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$p2$']], 'opt2'),
317+
DataFixture(
318+
BundleProductFixture::class,
319+
['_options' => ['$opt1$', '$opt2$']],
320+
'bundle1'
321+
),
322+
]
323+
324+
public function testUpdateBundleProductOptionsTitleOnStoreView(): void
325+
{
326+
$this->cleanUpOnTearDown = false;
327+
$fixtures = DataFixtureStorageManager::getStorage();
328+
$product = $fixtures->get('bundle1');
329+
$store2 = $fixtures->get('store2');
330+
$data = $this->getProduct($product->getSku());
331+
$defaultOptions = $this->getBundleProductOptions($data);
332+
$store2Options = $defaultOptions;
333+
$store2Options[0]['title'] .= ' - custom';
334+
$store2Options[1]['title'] .= ' - custom';
335+
$this->setBundleProductOptions($data, $store2Options);
336+
$this->saveProduct($data, $store2->getCode());
337+
338+
// check that option titles are updated on store 2
339+
$data = $this->getProduct($product->getSku(), $store2->getCode());
340+
$options = $this->getBundleProductOptions($data);
341+
$this->assertEquals($store2Options[0]['title'], $options[0]['title']);
342+
$this->assertEquals($store2Options[1]['title'], $options[1]['title']);
343+
344+
// check that option titles have not changed on default store
345+
$data = $this->getProduct($product->getSku(), 'default');
346+
$options = $this->getBundleProductOptions($data);
347+
$this->assertEquals($defaultOptions[0]['title'], $options[0]['title']);
348+
$this->assertEquals($defaultOptions[1]['title'], $options[1]['title']);
349+
350+
// check that option titles have not changed in global scope
351+
$data = $this->getProduct($product->getSku(), 'all');
352+
$options = $this->getBundleProductOptions($data);
353+
$this->assertEquals($defaultOptions[0]['title'], $options[0]['title']);
354+
$this->assertEquals($defaultOptions[1]['title'], $options[1]['title']);
355+
}
356+
298357
/**
299358
* Get the bundle_product_options custom attribute from product, null if the attribute is not set
300359
*
@@ -457,7 +516,7 @@ protected function convertCustomAttributes($customAttributes)
457516
* @param string $productSku
458517
* @return array the product data
459518
*/
460-
protected function getProduct($productSku)
519+
protected function getProduct($productSku, ?string $storeCode = null)
461520
{
462521
$serviceInfo = [
463522
'rest' => [
@@ -471,10 +530,9 @@ protected function getProduct($productSku)
471530
],
472531
];
473532

474-
$response = (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) ?
475-
$this->_webApiCall($serviceInfo, ['sku' => $productSku]) : $this->_webApiCall($serviceInfo);
476-
477-
return $response;
533+
return TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP
534+
? $this->_webApiCall($serviceInfo, ['sku' => $productSku], storeCode: $storeCode)
535+
: $this->_webApiCall($serviceInfo, storeCode: $storeCode);
478536
}
479537

480538
/**
@@ -530,9 +588,10 @@ protected function deleteProductBySku($productSku)
530588
* Save product
531589
*
532590
* @param array $product
591+
* @param string|null $storeCode
533592
* @return array the created product data
534593
*/
535-
protected function saveProduct($product)
594+
protected function saveProduct($product, ?string $storeCode = null)
536595
{
537596
if (isset($product['custom_attributes'])) {
538597
$count = count($product['custom_attributes']);
@@ -557,7 +616,7 @@ protected function saveProduct($product)
557616
],
558617
];
559618
$requestData = ['product' => $product];
560-
$response = $this->_webApiCall($serviceInfo, $requestData);
619+
$response = $this->_webApiCall($serviceInfo, $requestData, storeCode: $storeCode);
561620
return $response;
562621
}
563622
}

dev/tests/integration/testsuite/Magento/CurrencySymbol/Model/System/CurrencysymbolTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,31 @@ class CurrencysymbolTest extends \PHPUnit\Framework\TestCase
2020
*/
2121
protected $currencySymbolModel;
2222

23+
/**
24+
* @inheritDoc
25+
*/
2326
protected function setUp(): void
2427
{
2528
$this->currencySymbolModel = Bootstrap::getObjectManager()->create(
2629
\Magento\CurrencySymbol\Model\System\Currencysymbol::class
2730
);
2831
}
2932

33+
/**
34+
* @inheritDoc
35+
*/
3036
protected function tearDown(): void
3137
{
3238
$this->currencySymbolModel = null;
3339
Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class)->reinit();
3440
Bootstrap::getObjectManager()->create(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores();
3541
}
3642

43+
/**
44+
* Test that getCurrencySymbolsData method returns valid data
45+
*
46+
* @return void
47+
*/
3748
public function testGetCurrencySymbolsData()
3849
{
3950
$currencySymbolsData = $this->currencySymbolModel->getCurrencySymbolsData();
@@ -80,8 +91,37 @@ public function testSetCurrencySymbolsData()
8091
$this->assertEquals('@', $this->currencySymbolModel->getCurrencySymbol('EUR'), 'Symbol not set correctly.');
8192
}
8293

94+
/**
95+
* Test that method returns valid data
96+
*
97+
* @return void
98+
*/
8399
public function testGetCurrencySymbolNonExistent()
84100
{
85101
$this->assertFalse($this->currencySymbolModel->getCurrencySymbol('AUD'));
86102
}
103+
104+
/**
105+
* Test that default symbol can be set to use explicitly in the system
106+
*
107+
* @return void
108+
*/
109+
public function testSetCurrencySymbolLikeParent()
110+
{
111+
$currencySymbolsData = ['USD' => '$'];
112+
$this->currencySymbolModel->setCurrencySymbolsData($currencySymbolsData);
113+
114+
//Verify if the new symbol is set
115+
$this->assertEquals(
116+
'$',
117+
$this->currencySymbolModel->getCurrencySymbolsData()['USD']['displaySymbol'],
118+
'Symbol was not correctly set.'
119+
);
120+
121+
$this->assertEquals(
122+
false,
123+
$this->currencySymbolModel->getCurrencySymbolsData()['USD']['inherited'],
124+
'Symbol\'s inheritance was not correctly set.'
125+
);
126+
}
87127
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
/* To make sure the import directive will correctly parse external stylesheets */
2+
@import url("https://localhost/external-stylesheet.css");
3+
14
p{align:center}

0 commit comments

Comments
 (0)