Skip to content

Commit ebba5f8

Browse files
authored
Merge pull request #521 from magento-troll/troll_bugfix
[Troll] bugfixes MAGETWO-59482 Wishlist dependency on B2B requisition list block MAGETWO-59227 Customer Address/Customer attribute isn't validated if required MAGETWO-54296 Сategory suffix does not change after the second configuration changes
2 parents 99db5bc + 92b4154 commit ebba5f8

File tree

9 files changed

+260
-11
lines changed

9 files changed

+260
-11
lines changed

app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class Suffix extends \Magento\Framework\App\Config\Value
4040
*/
4141
protected $resource;
4242

43+
/**
44+
* @var \Magento\Framework\App\Config\ScopePool
45+
*/
46+
private $scopePool;
47+
4348
/**
4449
* @param \Magento\Framework\Model\Context $context
4550
* @param \Magento\Framework\Registry $registry
@@ -75,6 +80,22 @@ public function __construct(
7580
$this->resource = $appResource;
7681
}
7782

83+
/**
84+
* Get instance of ScopePool
85+
*
86+
* @return \Magento\Framework\App\Config\ScopePool
87+
* @deprecated
88+
*/
89+
private function getScopePool()
90+
{
91+
if ($this->scopePool === null) {
92+
$this->scopePool = \Magento\Framework\App\ObjectManager::getInstance()->get(
93+
\Magento\Framework\App\Config\ScopePool::class
94+
);
95+
}
96+
return $this->scopePool;
97+
}
98+
7899
/**
79100
* Check url rewrite suffix - whether we can support it
80101
*
@@ -103,6 +124,24 @@ public function afterSave()
103124
return parent::afterSave();
104125
}
105126

127+
/**
128+
* {@inheritdoc}
129+
*/
130+
public function afterDeleteCommit()
131+
{
132+
if ($this->isValueChanged()) {
133+
$this->updateSuffixForUrlRewrites();
134+
if ($this->isCategorySuffixChanged()) {
135+
$this->cacheTypeList->invalidate([
136+
\Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER,
137+
\Magento\Framework\App\Cache\Type\Collection::TYPE_IDENTIFIER
138+
]);
139+
}
140+
}
141+
142+
return parent::afterDeleteCommit();
143+
}
144+
106145
/**
107146
* Check is category suffix changed
108147
*
@@ -135,7 +174,12 @@ protected function updateSuffixForUrlRewrites()
135174
}
136175
$entities = $this->urlFinder->findAllByData($dataFilter);
137176
$oldSuffixPattern = '~' . preg_quote($this->getOldValue()) . '$~';
138-
$suffix = $this->getValue();
177+
if ($this->getValue() !== null) {
178+
$suffix = $this->getValue();
179+
} else {
180+
$this->getScopePool()->clean();
181+
$suffix = $this->_config->getValue($this->getPath());
182+
}
139183
foreach ($entities as $urlRewrite) {
140184
$bind = $urlRewrite->getIsAutogenerated()
141185
? [UrlRewrite::REQUEST_PATH => preg_replace($oldSuffixPattern, $suffix, $urlRewrite->getRequestPath())]

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ define(
179179
newShippingAddress;
180180

181181
this.source.set('params.invalid', false);
182-
this.source.trigger('shippingAddress.data.validate');
182+
this.triggerShippingDataValidateEvent();
183183

184184
if (!this.source.get('params.invalid')) {
185185
addressData = this.source.get('shippingAddress');
@@ -254,12 +254,7 @@ define(
254254

255255
if (this.isFormInline) {
256256
this.source.set('params.invalid', false);
257-
this.source.trigger('shippingAddress.data.validate');
258-
259-
if (this.source.get('shippingAddress.custom_attributes')) {
260-
this.source.trigger('shippingAddress.custom_attributes.data.validate');
261-
}
262-
257+
this.triggerShippingDataValidateEvent();
263258
if (emailValidationResult &&
264259
this.source.get('params.invalid') ||
265260
!quote.shippingMethod().method_code ||
@@ -304,6 +299,18 @@ define(
304299
}
305300

306301
return true;
302+
},
303+
304+
/**
305+
* Trigger Shipping data Validate Event.
306+
*
307+
* @return {void}
308+
*/
309+
triggerShippingDataValidateEvent: function () {
310+
this.source.trigger('shippingAddress.data.validate');
311+
if (this.source.get('shippingAddress.custom_attributes')) {
312+
this.source.trigger('shippingAddress.custom_attributes.data.validate');
313+
}
307314
}
308315
});
309316
}

app/code/Magento/Wishlist/view/frontend/layout/catalog_product_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</arguments>
1717
</block>
1818
<referenceBlock name="product.info.addto">
19-
<block class="Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist" name="view.addto.wishlist" after="view.addto.requisition"
19+
<block class="Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist" name="view.addto.wishlist"
2020
template="Magento_Wishlist::catalog/product/view/addto/wishlist.phtml" />
2121
</referenceBlock>
2222
</referenceContainer>

app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<update handle="catalog_product_view"/>
1010
<body>
1111
<referenceBlock name="product.info.addto">
12-
<block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist" after="view.addto.requisition"
12+
<block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist"
1313
template="item/configure/addto/wishlist.phtml" />
1414
</referenceBlock>
1515
</body>

app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure_type_bundle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.bundle" as="addtocart" template="product/view/addtocart.phtml" />
2121
<block class="Magento\Catalog\Block\Product\View" name="product.info.addto.bundle" as="addto" after="product.info.addtocart.bundle"
2222
template="Magento_Catalog::product/view/addto.phtml" cacheable="false">
23-
<block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist.bundle" after="view.addto.requisition"
23+
<block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist.bundle"
2424
template="item/configure/addto/wishlist.phtml" />
2525
<block class="Magento\Catalog\Block\Product\View\AddTo\Compare" name="view.addto.compare.bundle" after="view.addto.wishlist"
2626
template="Magento_Catalog::product/view/addto/compare.phtml" />

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,60 @@
66

77
namespace Magento\Checkout\Test\Block\Onepage;
88

9+
use Magento\Checkout\Test\Block\Onepage\Shipping\AddressModal;
910
use Magento\Mtf\Block\Form;
11+
use Magento\Mtf\Client\Locator;
1012

1113
/**
1214
* Checkout shipping address block.
1315
*/
1416
class Shipping extends Form
1517
{
18+
/**
19+
* CSS Selector for "New Address" button
20+
*
21+
* @var string
22+
*/
23+
private $newAddressButton = '[data-bind*="isNewAddressAdded"]';
24+
25+
/**
26+
* Wait element.
27+
*
28+
* @var string
29+
*/
30+
private $waitElement = '.loading-mask';
31+
32+
/**
33+
* SCC Selector for Address Modal block.
34+
*
35+
* @var string
36+
*/
37+
private $addressModalBlock = '//*[@id="opc-new-shipping-address"]/../..';
38+
39+
/**
40+
* Click on "New Address" button.
41+
*
42+
* @return void
43+
*/
44+
public function clickOnNewAddressButton()
45+
{
46+
$this->waitForElementNotVisible($this->waitElement);
47+
$this->_rootElement->find($this->newAddressButton)->click();
48+
}
49+
50+
/**
51+
* Get Address Modal Block.
52+
*
53+
* @return AddressModal
54+
*/
55+
public function getAddressModalBlock()
56+
{
57+
return $this->blockFactory->create(
58+
AddressModal::class,
59+
['element' => $this->browser->find($this->addressModalBlock, Locator::SELECTOR_XPATH)]
60+
);
61+
}
62+
1663
/**
1764
* Returns form's required elements
1865
*
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\Block\Onepage\Shipping;
8+
9+
use Magento\Mtf\Block\Form;
10+
11+
/**
12+
* Checkout shipping address modal block.
13+
*/
14+
class AddressModal extends Form
15+
{
16+
/**
17+
* CSS Selector for Save button.
18+
*
19+
* @var string
20+
*/
21+
private $saveButton = '.action-save-address';
22+
23+
/**
24+
* Selector for field's error message.
25+
*
26+
* @var string
27+
*/
28+
private $errorMessage = '.field-error';
29+
30+
/**
31+
* Selector for error fields.
32+
*
33+
* @var string
34+
*/
35+
private $errorField = '._error';
36+
37+
/**
38+
* Selector for field label that have error message.
39+
*
40+
* @var string
41+
*/
42+
private $fieldLabel = '.label';
43+
44+
/**
45+
* Click on 'Save Address' button.
46+
*
47+
* @return void
48+
*/
49+
public function save()
50+
{
51+
$this->_rootElement->find($this->saveButton)->click();
52+
}
53+
54+
/**
55+
* Get Error messages for attributes.
56+
*
57+
* @return array
58+
*/
59+
public function getErrorMessages()
60+
{
61+
$result = [];
62+
foreach ($this->_rootElement->getElements($this->errorField) as $item) {
63+
$result[$item->find($this->fieldLabel)->getText()] = $item->find($this->errorMessage)->getText();
64+
}
65+
66+
return $result;
67+
}
68+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="0">
9+
<fields>
10+
<firstname />
11+
<lastname />
12+
<company />
13+
<street>
14+
<selector>input[name="street[0]"]</selector>
15+
</street>
16+
<city />
17+
<region_id>
18+
<input>select</input>
19+
</region_id>
20+
<country_id>
21+
<input>select</input>
22+
</country_id>
23+
<telephone />
24+
<postcode />
25+
</fields>
26+
</mapping>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\TestStep;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Customer\Test\Fixture\Address;
11+
use Magento\Mtf\TestStep\TestStepInterface;
12+
13+
/**
14+
* Create customer custom attribute step.
15+
*/
16+
class AddNewShippingAddressStep implements TestStepInterface
17+
{
18+
/**
19+
* Checkout One page.
20+
*
21+
* @var CheckoutOnepage
22+
*/
23+
private $checkoutOnepage;
24+
25+
/**
26+
* Shipping Address fixture.
27+
*
28+
* @var Address
29+
*/
30+
private $address;
31+
32+
/**
33+
* @constructor
34+
* @param CheckoutOnepage $checkoutOnepage
35+
* @param Address|null $address [optional]
36+
*/
37+
public function __construct(CheckoutOnepage $checkoutOnepage, Address $address = null)
38+
{
39+
$this->checkoutOnepage = $checkoutOnepage;
40+
$this->address = $address;
41+
}
42+
43+
/**
44+
* Create customer account.
45+
*
46+
* @return void
47+
*/
48+
public function run()
49+
{
50+
$shippingBlock = $this->checkoutOnepage->getShippingBlock();
51+
$shippingBlock->clickOnNewAddressButton();
52+
if ($this->address) {
53+
$shippingBlock->getAddressModalBlock()->fill($this->address);
54+
}
55+
$shippingBlock->getAddressModalBlock()->save();
56+
}
57+
}

0 commit comments

Comments
 (0)