Skip to content

Commit 63cf5b3

Browse files
authored
Merge pull request #4717 from magento-chaika/Chaika-PR-2019-09-01-2.3
Chaika-PR-2019-09-01-2.3
2 parents 9ae5ba2 + 2492d61 commit 63cf5b3

File tree

16 files changed

+447
-599
lines changed

16 files changed

+447
-599
lines changed

app/code/Magento/Braintree/Model/Paypal/Helper/OrderPlace.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/**
2020
* Class OrderPlace
2121
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2223
*/
2324
class OrderPlace extends AbstractHelper
2425
{
@@ -79,9 +80,10 @@ public function __construct(
7980
public function execute(Quote $quote, array $agreement)
8081
{
8182
if (!$this->agreementsValidator->isValid($agreement)) {
82-
throw new LocalizedException(__(
83+
$errorMsg = __(
8384
"The order wasn't placed. First, agree to the terms and conditions, then try placing your order again."
84-
));
85+
);
86+
throw new LocalizedException($errorMsg);
8587
}
8688

8789
if ($this->getCheckoutMethod($quote) === Onepage::METHOD_GUEST) {
@@ -91,12 +93,7 @@ public function execute(Quote $quote, array $agreement)
9193
$this->disabledQuoteAddressValidation($quote);
9294

9395
$quote->collectTotals();
94-
try {
95-
$this->cartManagement->placeOrder($quote->getId());
96-
} catch (\Exception $e) {
97-
$this->orderCancellationService->execute($quote->getReservedOrderId());
98-
throw $e;
99-
}
96+
$this->cartManagement->placeOrder($quote->getId());
10097
}
10198

10299
/**

app/code/Magento/Braintree/Plugin/OrderCancellation.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ public function aroundPlaceOrder(
7272
];
7373
if (in_array($payment->getMethod(), $paymentCodes)) {
7474
$incrementId = $quote->getReservedOrderId();
75-
$this->orderCancellationService->execute($incrementId);
75+
if ($incrementId) {
76+
$this->orderCancellationService->execute($incrementId);
77+
}
7678
}
7779

7880
throw $e;

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<annotations>
1414
<description>Sets the Admin Products grid view to the 'Default View'.</description>
1515
</annotations>
16-
16+
1717
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
1818
<click selector="{{AdminProductGridFilterSection.viewDropdown}}" stepKey="openViewBookmarksTab"/>
1919
<click selector="{{AdminProductGridFilterSection.viewBookmark('Default View')}}" stepKey="resetToDefaultGridView"/>
@@ -120,7 +120,7 @@
120120
<annotations>
121121
<description>Filters the Admin Products grid by the 'Enabled' Status. PLEASE NOTE: The Filter is Hardcoded.</description>
122122
</annotations>
123-
123+
124124
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
125125
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
126126
<selectOption selector="{{AdminProductGridFilterSection.statusFilter}}" userInput="Enabled" stepKey="selectEnabledStatusFilter"/>
@@ -286,6 +286,27 @@
286286
<see selector="{{AdminProductGridSection.productGridCell('1', 'Name')}}" userInput="{{name}}" stepKey="seeProductNameInGrid" after="clickApplyFilters"/>
287287
</actionGroup>
288288

289+
<actionGroup name="deleteProductsByKeyword">
290+
<annotations>
291+
<description>Delete products by keyword</description>
292+
</annotations>
293+
<arguments>
294+
<argument name="keyword" type="string"/>
295+
</arguments>
296+
297+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
298+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
299+
<fillField selector="{{AdminProductGridFilterSection.keywordSearch}}" userInput="{{keyword}}" stepKey="fillKeywordField"/>
300+
<click selector="{{AdminProductGridFilterSection.keywordSearchButton}}" stepKey="keywordSearchButton"/>
301+
<click selector="{{AdminProductGridSection.multicheckDropdown}}" stepKey="openMulticheckDropdown"/>
302+
<click selector="{{AdminProductGridSection.multicheckOption('Select All')}}" stepKey="selectAllProductInFilteredGrid"/>
303+
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickActionDropdown"/>
304+
<click selector="{{AdminProductGridSection.bulkActionOption('Delete')}}" stepKey="clickDeleteAction"/>
305+
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForConfirmModal"/>
306+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmProductDelete"/>
307+
<see selector="{{AdminMessagesSection.success}}" userInput="record(s) have been deleted." stepKey="seeSuccessMessage"/>
308+
</actionGroup>
309+
289310
<!--Open product for edit by clicking row X and column Y in product grid-->
290311
<actionGroup name="openProducForEditByClickingRowXColumnYInProductGrid">
291312
<annotations>
@@ -314,7 +335,7 @@
314335
<annotations>
315336
<description>Filters the ID column in Ascending Order.</description>
316337
</annotations>
317-
338+
318339
<conditionalClick selector="{{AdminProductGridTableHeaderSection.id('descend')}}" dependentSelector="{{AdminProductGridTableHeaderSection.id('ascend')}}" visible="false" stepKey="sortById"/>
319340
<waitForPageLoad stepKey="waitForPageLoad"/>
320341
</actionGroup>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@
1717
<remove keyForRemoval="AssertProductPrice"/>
1818
<see userInput="{{product.price}}" selector="{{StorefrontCategoryProductSection.ProductPriceByName(product.name)}}" stepKey="AssertProductPrice"/>
1919
</actionGroup>
20+
<actionGroup name="StorefrontAssertProductPriceOnCategoryPageActionGroup" extends="StorefrontAssertProductPriceOnProductPageActionGroup">
21+
<annotations>
22+
<description>Validate that the provided Product Price is correct on category page.</description>
23+
</annotations>
24+
<arguments>
25+
<argument name="productName" type="string"/>
26+
</arguments>
27+
28+
<see userInput="{{productPrice}}" selector="{{StorefrontCategoryProductSection.ProductPriceByName(productName)}}" stepKey="seeProductPrice"/>
29+
</actionGroup>
2030
</actionGroups>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,12 @@
368368
<data key="frontend_input">swatch_visual</data>
369369
<data key="attribute_code" unique="suffix">visual_swatch</data>
370370
</entity>
371+
<entity name="ProductColorAttribute" type="ProductAttribute">
372+
<data key="frontend_label">Color</data>
373+
<data key="attribute_code" unique="suffix">color_attr</data>
374+
</entity>
375+
<entity name="ProductSizeAttribute" type="ProductAttribute">
376+
<data key="frontend_label">Size</data>
377+
<data key="attribute_code" unique="suffix">size_attr</data>
378+
</entity>
371379
</entities>

app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<arguments>
1717
<argument name="product" defaultValue="_defaultProduct"/>
1818
</arguments>
19-
19+
2020
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
2121
<waitForPageLoad stepKey="waitForPageLoadInitial"/>
2222
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
@@ -108,6 +108,65 @@
108108
<seeInTitle userInput="{{product.name}}" stepKey="seeProductNameInTitle"/>
109109
</actionGroup>
110110

111+
<actionGroup name="createConfigurableProductWithTwoAttributes" extends="createConfigurableProduct">
112+
<annotations>
113+
<description>Goes to the Admin Product grid page. Creates a Configurable Product with 2 product attributes.</description>
114+
</annotations>
115+
<arguments>
116+
<argument name="attribute1" defaultValue="ProductColorAttribute"/>
117+
<argument name="attribute2" defaultValue="ProductSizeAttribute"/>
118+
</arguments>
119+
<remove keyForRemoval="clickOnNewAttribute"/>
120+
<remove keyForRemoval="waitForIFrame"/>
121+
<remove keyForRemoval="switchToNewAttributeIFrame"/>
122+
<remove keyForRemoval="fillDefaultLabel"/>
123+
<remove keyForRemoval="clickOnNewAttributePanel"/>
124+
<remove keyForRemoval="waitForSaveAttribute"/>
125+
<remove keyForRemoval="switchOutOfIFrame"/>
126+
<remove keyForRemoval="waitForFilters"/>
127+
<remove keyForRemoval="clickOnFilters"/>
128+
<remove keyForRemoval="fillFilterAttributeCodeField"/>
129+
<remove keyForRemoval="clickApplyFiltersButton"/>
130+
<remove keyForRemoval="clickOnFirstCheckbox"/>
131+
<click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox(attribute1.attribute_code)}}" stepKey="selectAttribute1" after="clickOnCreateConfigurations"/>
132+
<click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox(attribute2.attribute_code)}}" stepKey="selectAttribute2" after="selectAttribute1"/>
133+
<remove keyForRemoval="waitCreateNewValueAppears"/>
134+
<remove keyForRemoval="clickOnCreateNewValue1"/>
135+
<remove keyForRemoval="fillFieldForNewAttribute1"/>
136+
<remove keyForRemoval="clickOnSaveNewAttribute1"/>
137+
<remove keyForRemoval="clickOnCreateNewValue2"/>
138+
<remove keyForRemoval="fillFieldForNewAttribute2"/>
139+
<remove keyForRemoval="clickOnSaveNewAttribute2"/>
140+
<remove keyForRemoval="clickOnCreateNewValue3"/>
141+
<remove keyForRemoval="fillFieldForNewAttribute3"/>
142+
<remove keyForRemoval="clickOnSaveNewAttribute3"/>
143+
<remove keyForRemoval="clickOnSelectAll"/>
144+
<click selector="{{AdminCreateProductConfigurationsPanel.selectAllByAttribute(attribute1.frontend_label)}}" stepKey="selectAllOptionsOfAttribute1" before="clickOnNextButton2"/>
145+
<click selector="{{AdminCreateProductConfigurationsPanel.selectAllByAttribute(attribute2.frontend_label)}}" stepKey="selectAllOptionsOfAttribute2" before="clickOnNextButton2"/>
146+
<remove keyForRemoval="applyUniquePricesByAttributeToEachSku"/>
147+
<remove keyForRemoval="clickOnApplyUniquePricesByAttributeToEachSku"/>
148+
<remove keyForRemoval="selectAttributes"/>
149+
<remove keyForRemoval="fillAttributePrice1"/>
150+
<remove keyForRemoval="fillAttributePrice2"/>
151+
<remove keyForRemoval="fillAttributePrice3"/>
152+
<remove keyForRemoval="clickOnSaveButton2"/>
153+
<remove keyForRemoval="clickOnConfirmInPopup"/>
154+
<remove keyForRemoval="seeSaveProductMessage"/>
155+
<remove keyForRemoval="seeProductNameInTitle"/>
156+
</actionGroup>
157+
<actionGroup name="saveConfigurableProduct">
158+
<annotations>
159+
<description>Save configurable product</description>
160+
</annotations>
161+
<arguments>
162+
<argument name="product" defaultValue="_defaultProduct"/>
163+
</arguments>
164+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton"/>
165+
<click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/>
166+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessage"/>
167+
<seeInTitle userInput="{{product.name}}" stepKey="seeProductNameInTitle"/>
168+
</actionGroup>
169+
111170
<actionGroup name="generateConfigurationsByAttributeCode">
112171
<annotations>
113172
<description>Generates the Product Configurations for the provided Attribute Code on the Configurable Product creation/edit page.</description>
@@ -296,12 +355,21 @@
296355
<fillField userInput="{{firstOption.weight}}" selector="{{AdminProductFormConfigurationsSection.confProductWeightCell(firstOption.name)}}" stepKey="fillFieldWeightForFirstAttributeOption"/>
297356
<fillField userInput="{{secondOption.weight}}" selector="{{AdminProductFormConfigurationsSection.confProductWeightCell(secondOption.name)}}" stepKey="fillFieldWeightForSecondAttributeOption"/>
298357
</actionGroup>
299-
358+
<actionGroup name="changeConfigurableProductChildProductPrice">
359+
<annotations>
360+
<description>Change the price of a configurable child product in the grid under configurations.</description>
361+
</annotations>
362+
<arguments>
363+
<argument name="productAttributes" type="string"/>
364+
<argument name="productPrice" type="string"/>
365+
</arguments>
366+
<fillField userInput="{{productPrice}}" selector="{{AdminProductFormConfigurationsSection.confProductPriceCell(productAttributes)}}" stepKey="fillPriceForConfigurableProductAttributeOption"/>
367+
</actionGroup>
300368
<actionGroup name="changeProductConfigurationsInGridExceptSku" extends="changeProductConfigurationsInGrid">
301369
<annotations>
302370
<description>EXTENDS: changeProductConfigurationsInGrid. Removes 'fillFieldSkuForFirstAttributeOption' and 'fillFieldSkuForSecondAttributeOption'.</description>
303371
</annotations>
304-
372+
305373
<remove keyForRemoval="fillFieldSkuForFirstAttributeOption"/>
306374
<remove keyForRemoval="fillFieldSkuForSecondAttributeOption"/>
307375
</actionGroup>

app/code/Magento/Store/App/Action/Plugin/Context.php

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
use Magento\Framework\App\RequestInterface;
1212
use Magento\Framework\Exception\NoSuchEntityException;
1313
use Magento\Framework\Exception\NotFoundException;
14+
use Magento\Framework\Session\SessionManagerInterface;
1415
use Magento\Store\Api\Data\StoreInterface;
1516
use Magento\Store\Api\StoreCookieManagerInterface;
17+
use Magento\Store\Model\ScopeInterface;
18+
use Magento\Store\Model\StoreManager;
1619
use Magento\Store\Model\StoreManagerInterface;
1720

1821
/**
@@ -21,17 +24,17 @@
2124
class Context
2225
{
2326
/**
24-
* @var \Magento\Framework\Session\SessionManagerInterface
27+
* @var SessionManagerInterface
2528
*/
2629
protected $session;
2730

2831
/**
29-
* @var \Magento\Framework\App\Http\Context
32+
* @var HttpContext
3033
*/
3134
protected $httpContext;
3235

3336
/**
34-
* @var \Magento\Store\Model\StoreManagerInterface
37+
* @var StoreManagerInterface
3538
*/
3639
protected $storeManager;
3740

@@ -41,15 +44,15 @@ class Context
4144
protected $storeCookieManager;
4245

4346
/**
44-
* @param \Magento\Framework\Session\SessionManagerInterface $session
45-
* @param \Magento\Framework\App\Http\Context $httpContext
46-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
47+
* @param SessionManagerInterface $session
48+
* @param HttpContext $httpContext
49+
* @param StoreManagerInterface $storeManager
4750
* @param StoreCookieManagerInterface $storeCookieManager
4851
*/
4952
public function __construct(
50-
\Magento\Framework\Session\SessionManagerInterface $session,
51-
\Magento\Framework\App\Http\Context $httpContext,
52-
\Magento\Store\Model\StoreManagerInterface $storeManager,
53+
SessionManagerInterface $session,
54+
HttpContext $httpContext,
55+
StoreManagerInterface $storeManager,
5356
StoreCookieManagerInterface $storeCookieManager
5457
) {
5558
$this->session = $session;
@@ -78,41 +81,42 @@ public function beforeDispatch(
7881

7982
/** @var string|array|null $storeCode */
8083
$storeCode = $request->getParam(
81-
\Magento\Store\Model\StoreManagerInterface::PARAM_NAME,
84+
StoreManagerInterface::PARAM_NAME,
8285
$this->storeCookieManager->getStoreCodeFromCookie()
8386
);
8487
if (is_array($storeCode)) {
8588
if (!isset($storeCode['_data']['code'])) {
86-
$this->processInvalidStoreRequested();
89+
$this->processInvalidStoreRequested($request);
8790
}
8891
$storeCode = $storeCode['_data']['code'];
8992
}
9093
if ($storeCode === '') {
9194
//Empty code - is an invalid code and it was given explicitly
9295
//(the value would be null if the code wasn't found).
93-
$this->processInvalidStoreRequested();
96+
$this->processInvalidStoreRequested($request);
9497
}
9598
try {
9699
$currentStore = $this->storeManager->getStore($storeCode);
100+
$this->updateContext($request, $currentStore);
97101
} catch (NoSuchEntityException $exception) {
98-
$this->processInvalidStoreRequested($exception);
102+
$this->processInvalidStoreRequested($request, $exception);
99103
}
100-
101-
$this->updateContext($currentStore);
102104
}
103105

104106
/**
105107
* Take action in case of invalid store requested.
106108
*
107-
* @param \Throwable|null $previousException
109+
* @param RequestInterface $request
110+
* @param NoSuchEntityException|null $previousException
108111
* @return void
109112
* @throws NotFoundException
110113
*/
111114
private function processInvalidStoreRequested(
112-
\Throwable $previousException = null
115+
RequestInterface $request,
116+
NoSuchEntityException $previousException = null
113117
) {
114118
$store = $this->storeManager->getStore();
115-
$this->updateContext($store);
119+
$this->updateContext($request, $store);
116120

117121
throw new NotFoundException(
118122
$previousException
@@ -125,24 +129,34 @@ private function processInvalidStoreRequested(
125129
/**
126130
* Update context accordingly to the store found.
127131
*
132+
* @param RequestInterface $request
128133
* @param StoreInterface $store
129134
* @return void
130135
* @throws \Magento\Framework\Exception\LocalizedException
131136
*/
132-
private function updateContext(StoreInterface $store)
137+
private function updateContext(RequestInterface $request, StoreInterface $store)
133138
{
139+
switch (true) {
140+
case $store->isUseStoreInUrl():
141+
$defaultStore = $store;
142+
break;
143+
case ScopeInterface::SCOPE_STORE == $request->getServerValue(StoreManager::PARAM_RUN_TYPE):
144+
$defaultStoreCode = $request->getServerValue(StoreManager::PARAM_RUN_CODE);
145+
$defaultStore = $this->storeManager->getStore($defaultStoreCode);
146+
break;
147+
default:
148+
$defaultStoreCode = $this->storeManager->getDefaultStoreView()->getCode();
149+
$defaultStore = $this->storeManager->getStore($defaultStoreCode);
150+
break;
151+
}
134152
$this->httpContext->setValue(
135153
StoreManagerInterface::CONTEXT_STORE,
136154
$store->getCode(),
137-
$store->isUseStoreInUrl() ? $store->getCode() : $this->storeManager->getDefaultStoreView()->getCode()
155+
$defaultStore->getCode()
138156
);
139-
140-
/** @var StoreInterface $defaultStore */
141-
$defaultStore = $this->storeManager->getWebsite()->getDefaultStore();
142157
$this->httpContext->setValue(
143158
HttpContext::CONTEXT_CURRENCY,
144-
$this->session->getCurrencyCode()
145-
?: $store->getDefaultCurrencyCode(),
159+
$this->session->getCurrencyCode() ?: $store->getDefaultCurrencyCode(),
146160
$defaultStore->getDefaultCurrencyCode()
147161
);
148162
}

0 commit comments

Comments
 (0)