Skip to content
Snippets Groups Projects
Commit ebba5f8a authored by Roman Ganin's avatar Roman Ganin Committed by GitHub
Browse files

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
parents 99db5bce 92b41543
No related merge requests found
Showing
with 260 additions and 11 deletions
...@@ -40,6 +40,11 @@ class Suffix extends \Magento\Framework\App\Config\Value ...@@ -40,6 +40,11 @@ class Suffix extends \Magento\Framework\App\Config\Value
*/ */
protected $resource; protected $resource;
/**
* @var \Magento\Framework\App\Config\ScopePool
*/
private $scopePool;
/** /**
* @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
...@@ -75,6 +80,22 @@ class Suffix extends \Magento\Framework\App\Config\Value ...@@ -75,6 +80,22 @@ class Suffix extends \Magento\Framework\App\Config\Value
$this->resource = $appResource; $this->resource = $appResource;
} }
/**
* Get instance of ScopePool
*
* @return \Magento\Framework\App\Config\ScopePool
* @deprecated
*/
private function getScopePool()
{
if ($this->scopePool === null) {
$this->scopePool = \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\App\Config\ScopePool::class
);
}
return $this->scopePool;
}
/** /**
* Check url rewrite suffix - whether we can support it * Check url rewrite suffix - whether we can support it
* *
...@@ -103,6 +124,24 @@ class Suffix extends \Magento\Framework\App\Config\Value ...@@ -103,6 +124,24 @@ class Suffix extends \Magento\Framework\App\Config\Value
return parent::afterSave(); return parent::afterSave();
} }
/**
* {@inheritdoc}
*/
public function afterDeleteCommit()
{
if ($this->isValueChanged()) {
$this->updateSuffixForUrlRewrites();
if ($this->isCategorySuffixChanged()) {
$this->cacheTypeList->invalidate([
\Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER,
\Magento\Framework\App\Cache\Type\Collection::TYPE_IDENTIFIER
]);
}
}
return parent::afterDeleteCommit();
}
/** /**
* Check is category suffix changed * Check is category suffix changed
* *
...@@ -135,7 +174,12 @@ class Suffix extends \Magento\Framework\App\Config\Value ...@@ -135,7 +174,12 @@ class Suffix extends \Magento\Framework\App\Config\Value
} }
$entities = $this->urlFinder->findAllByData($dataFilter); $entities = $this->urlFinder->findAllByData($dataFilter);
$oldSuffixPattern = '~' . preg_quote($this->getOldValue()) . '$~'; $oldSuffixPattern = '~' . preg_quote($this->getOldValue()) . '$~';
$suffix = $this->getValue(); if ($this->getValue() !== null) {
$suffix = $this->getValue();
} else {
$this->getScopePool()->clean();
$suffix = $this->_config->getValue($this->getPath());
}
foreach ($entities as $urlRewrite) { foreach ($entities as $urlRewrite) {
$bind = $urlRewrite->getIsAutogenerated() $bind = $urlRewrite->getIsAutogenerated()
? [UrlRewrite::REQUEST_PATH => preg_replace($oldSuffixPattern, $suffix, $urlRewrite->getRequestPath())] ? [UrlRewrite::REQUEST_PATH => preg_replace($oldSuffixPattern, $suffix, $urlRewrite->getRequestPath())]
......
...@@ -179,7 +179,7 @@ define( ...@@ -179,7 +179,7 @@ define(
newShippingAddress; newShippingAddress;
this.source.set('params.invalid', false); this.source.set('params.invalid', false);
this.source.trigger('shippingAddress.data.validate'); this.triggerShippingDataValidateEvent();
if (!this.source.get('params.invalid')) { if (!this.source.get('params.invalid')) {
addressData = this.source.get('shippingAddress'); addressData = this.source.get('shippingAddress');
...@@ -254,12 +254,7 @@ define( ...@@ -254,12 +254,7 @@ define(
if (this.isFormInline) { if (this.isFormInline) {
this.source.set('params.invalid', false); this.source.set('params.invalid', false);
this.source.trigger('shippingAddress.data.validate'); this.triggerShippingDataValidateEvent();
if (this.source.get('shippingAddress.custom_attributes')) {
this.source.trigger('shippingAddress.custom_attributes.data.validate');
}
if (emailValidationResult && if (emailValidationResult &&
this.source.get('params.invalid') || this.source.get('params.invalid') ||
!quote.shippingMethod().method_code || !quote.shippingMethod().method_code ||
...@@ -304,6 +299,18 @@ define( ...@@ -304,6 +299,18 @@ define(
} }
return true; return true;
},
/**
* Trigger Shipping data Validate Event.
*
* @return {void}
*/
triggerShippingDataValidateEvent: function () {
this.source.trigger('shippingAddress.data.validate');
if (this.source.get('shippingAddress.custom_attributes')) {
this.source.trigger('shippingAddress.custom_attributes.data.validate');
}
} }
}); });
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</arguments> </arguments>
</block> </block>
<referenceBlock name="product.info.addto"> <referenceBlock name="product.info.addto">
<block class="Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist" name="view.addto.wishlist" after="view.addto.requisition" <block class="Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist" name="view.addto.wishlist"
template="Magento_Wishlist::catalog/product/view/addto/wishlist.phtml" /> template="Magento_Wishlist::catalog/product/view/addto/wishlist.phtml" />
</referenceBlock> </referenceBlock>
</referenceContainer> </referenceContainer>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<update handle="catalog_product_view"/> <update handle="catalog_product_view"/>
<body> <body>
<referenceBlock name="product.info.addto"> <referenceBlock name="product.info.addto">
<block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist" after="view.addto.requisition" <block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist"
template="item/configure/addto/wishlist.phtml" /> template="item/configure/addto/wishlist.phtml" />
</referenceBlock> </referenceBlock>
</body> </body>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.bundle" as="addtocart" template="product/view/addtocart.phtml" /> <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart.bundle" as="addtocart" template="product/view/addtocart.phtml" />
<block class="Magento\Catalog\Block\Product\View" name="product.info.addto.bundle" as="addto" after="product.info.addtocart.bundle" <block class="Magento\Catalog\Block\Product\View" name="product.info.addto.bundle" as="addto" after="product.info.addtocart.bundle"
template="Magento_Catalog::product/view/addto.phtml" cacheable="false"> template="Magento_Catalog::product/view/addto.phtml" cacheable="false">
<block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist.bundle" after="view.addto.requisition" <block class="Magento\Wishlist\Block\Item\Configure" name="view.addto.wishlist.bundle"
template="item/configure/addto/wishlist.phtml" /> template="item/configure/addto/wishlist.phtml" />
<block class="Magento\Catalog\Block\Product\View\AddTo\Compare" name="view.addto.compare.bundle" after="view.addto.wishlist" <block class="Magento\Catalog\Block\Product\View\AddTo\Compare" name="view.addto.compare.bundle" after="view.addto.wishlist"
template="Magento_Catalog::product/view/addto/compare.phtml" /> template="Magento_Catalog::product/view/addto/compare.phtml" />
......
...@@ -6,13 +6,60 @@ ...@@ -6,13 +6,60 @@
namespace Magento\Checkout\Test\Block\Onepage; namespace Magento\Checkout\Test\Block\Onepage;
use Magento\Checkout\Test\Block\Onepage\Shipping\AddressModal;
use Magento\Mtf\Block\Form; use Magento\Mtf\Block\Form;
use Magento\Mtf\Client\Locator;
/** /**
* Checkout shipping address block. * Checkout shipping address block.
*/ */
class Shipping extends Form class Shipping extends Form
{ {
/**
* CSS Selector for "New Address" button
*
* @var string
*/
private $newAddressButton = '[data-bind*="isNewAddressAdded"]';
/**
* Wait element.
*
* @var string
*/
private $waitElement = '.loading-mask';
/**
* SCC Selector for Address Modal block.
*
* @var string
*/
private $addressModalBlock = '//*[@id="opc-new-shipping-address"]/../..';
/**
* Click on "New Address" button.
*
* @return void
*/
public function clickOnNewAddressButton()
{
$this->waitForElementNotVisible($this->waitElement);
$this->_rootElement->find($this->newAddressButton)->click();
}
/**
* Get Address Modal Block.
*
* @return AddressModal
*/
public function getAddressModalBlock()
{
return $this->blockFactory->create(
AddressModal::class,
['element' => $this->browser->find($this->addressModalBlock, Locator::SELECTOR_XPATH)]
);
}
/** /**
* Returns form's required elements * Returns form's required elements
* *
......
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Test\Block\Onepage\Shipping;
use Magento\Mtf\Block\Form;
/**
* Checkout shipping address modal block.
*/
class AddressModal extends Form
{
/**
* CSS Selector for Save button.
*
* @var string
*/
private $saveButton = '.action-save-address';
/**
* Selector for field's error message.
*
* @var string
*/
private $errorMessage = '.field-error';
/**
* Selector for error fields.
*
* @var string
*/
private $errorField = '._error';
/**
* Selector for field label that have error message.
*
* @var string
*/
private $fieldLabel = '.label';
/**
* Click on 'Save Address' button.
*
* @return void
*/
public function save()
{
$this->_rootElement->find($this->saveButton)->click();
}
/**
* Get Error messages for attributes.
*
* @return array
*/
public function getErrorMessages()
{
$result = [];
foreach ($this->_rootElement->getElements($this->errorField) as $item) {
$result[$item->find($this->fieldLabel)->getText()] = $item->find($this->errorMessage)->getText();
}
return $result;
}
}
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<mapping strict="0">
<fields>
<firstname />
<lastname />
<company />
<street>
<selector>input[name="street[0]"]</selector>
</street>
<city />
<region_id>
<input>select</input>
</region_id>
<country_id>
<input>select</input>
</country_id>
<telephone />
<postcode />
</fields>
</mapping>
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Test\TestStep;
use Magento\Checkout\Test\Page\CheckoutOnepage;
use Magento\Customer\Test\Fixture\Address;
use Magento\Mtf\TestStep\TestStepInterface;
/**
* Create customer custom attribute step.
*/
class AddNewShippingAddressStep implements TestStepInterface
{
/**
* Checkout One page.
*
* @var CheckoutOnepage
*/
private $checkoutOnepage;
/**
* Shipping Address fixture.
*
* @var Address
*/
private $address;
/**
* @constructor
* @param CheckoutOnepage $checkoutOnepage
* @param Address|null $address [optional]
*/
public function __construct(CheckoutOnepage $checkoutOnepage, Address $address = null)
{
$this->checkoutOnepage = $checkoutOnepage;
$this->address = $address;
}
/**
* Create customer account.
*
* @return void
*/
public function run()
{
$shippingBlock = $this->checkoutOnepage->getShippingBlock();
$shippingBlock->clickOnNewAddressButton();
if ($this->address) {
$shippingBlock->getAddressModalBlock()->fill($this->address);
}
$shippingBlock->getAddressModalBlock()->save();
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment