Skip to content

Commit 21ce3d7

Browse files
authored
Merge pull request #6368 from magento-l3/PR17november
L3 Bugfix delivery
2 parents e0561ce + 7b4ea1a commit 21ce3d7

File tree

14 files changed

+417
-44
lines changed

14 files changed

+417
-44
lines changed

app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleItemsTest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
</actionGroup>
6060
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
6161
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
62+
<!-- Check that Bundle Options initialized with default quantity -->
63+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/>
64+
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity">
65+
<expectedResult type="string">1</expectedResult>
66+
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult>
67+
</assertEquals>
68+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/>
69+
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity">
70+
<expectedResult type="string">1</expectedResult>
71+
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult>
72+
</assertEquals>
73+
6274
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
6375
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>
6476

@@ -108,6 +120,17 @@
108120
</actionGroup>
109121
<checkOption selector="{{AdminProductFormBundleSection.firstProductOption}}" stepKey="selectNewFirstGridRow2"/>
110122
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddNewSelectedBundleProducts"/>
123+
<!-- Check that existing Bundle Options do not loose user input quantity values -->
124+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantityAfterUserInput"/>
125+
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantityAfterUserInput">
126+
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
127+
<actualResult type="string">$grabbedFirstBundleOptionQuantityAfterUserInput</actualResult>
128+
</assertEquals>
129+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantityAfterUserInput"/>
130+
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantityAfterUserInput">
131+
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
132+
<actualResult type="string">$grabbedSecondBundleOptionQuantityAfterUserInput</actualResult>
133+
</assertEquals>
111134
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '2')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty1"/>
112135
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '3')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty2"/>
113136

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-option-qty.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ define([
1717
}
1818
},
1919

20+
/**
21+
* @inheritdoc
22+
*/
23+
setInitialValue: function () {
24+
this.initialValue = this.getInitialValue();
25+
26+
if (this.initialValue === undefined || this.initialValue === '') {
27+
this.initialValue = 1;
28+
}
29+
30+
if (this.value.peek() !== this.initialValue) {
31+
this.value(this.initialValue);
32+
}
33+
34+
this.on('value', this.onUpdate.bind(this));
35+
this.isUseDefault(this.disabled());
36+
37+
return this;
38+
},
39+
2040
/**
2141
* @inheritdoc
2242
*/
@@ -33,6 +53,5 @@ define([
3353

3454
return !this.visible() ? false : notEqual;
3555
}
36-
3756
});
3857
});

app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ define([
2727
// clone address form data to new object
2828
var addressData = $.extend(true, {}, formData),
2929
region,
30-
regionName = addressData.region;
30+
regionName = addressData.region,
31+
customAttributes;
3132

3233
if (mageUtils.isObject(addressData.street)) {
3334
addressData.street = this.objectToArray(addressData.street);
@@ -64,10 +65,20 @@ define([
6465
addressData['custom_attributes'] = _.map(
6566
addressData['custom_attributes'],
6667
function (value, key) {
67-
return {
68+
customAttributes = {
6869
'attribute_code': key,
6970
'value': value
7071
};
72+
73+
if (typeof value === 'boolean') {
74+
customAttributes = {
75+
'attribute_code': key,
76+
'value': value,
77+
'label': value === true ? 'Yes' : 'No'
78+
};
79+
}
80+
81+
return customAttributes;
7182
}
7283
);
7384
}

app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,4 @@ define([
8080
quote.shippingAddress.subscribe(estimateTotalsAndUpdateRates);
8181
quote.shippingMethod.subscribe(estimateTotalsShipping);
8282
quote.billingAddress.subscribe(estimateTotalsBilling);
83-
customerData.get('cart').subscribe(estimateTotalsShipping);
8483
});

app/code/Magento/Customer/Model/Address/CustomAttributesProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private function getAttributeLabels(array $customAttribute, string $customAttrib
7171
{
7272
$attributeOptionLabels = [];
7373

74-
if (!empty($customAttribute['value'])) {
74+
if (isset($customAttribute['value']) && $customAttribute['value'] != null) {
7575
$customAttributeValues = explode(',', $customAttribute['value']);
7676
$attributeOptions = $this->attributeOptionManager->getItems(
7777
\Magento\Customer\Model\Indexer\Address\AttributeProvider::ENTITY,

app/code/Magento/Customer/Observer/AfterAddressSaveObserver.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public function execute(Observer $observer)
141141
if ($customerAddress->getVatId() == ''
142142
|| !$this->_customerVat->isCountryInEU($customerAddress->getCountry())
143143
) {
144-
$defaultGroupId = $this->_groupManagement->getDefaultGroup($customer->getStore())->getId();
144+
$defaultGroupId = $customer->getGroupId() ? $customer->getGroupId() :
145+
$this->_groupManagement->getDefaultGroup($customer->getStore())->getId();
145146
if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $defaultGroupId) {
146147
$customer->setGroupId($defaultGroupId);
147148
$customer->save();
@@ -216,8 +217,8 @@ protected function _canProcessAddress($address)
216217
protected function _isDefaultBilling($address)
217218
{
218219
return $address->getId() && $address->getId() == $address->getCustomer()->getDefaultBilling()
219-
|| $address->getIsPrimaryBilling()
220-
|| $address->getIsDefaultBilling();
220+
|| $address->getIsPrimaryBilling()
221+
|| $address->getIsDefaultBilling();
221222
}
222223

223224
/**
@@ -229,8 +230,8 @@ protected function _isDefaultBilling($address)
229230
protected function _isDefaultShipping($address)
230231
{
231232
return $address->getId() && $address->getId() == $address->getCustomer()->getDefaultShipping()
232-
|| $address->getIsPrimaryShipping()
233-
|| $address->getIsDefaultShipping();
233+
|| $address->getIsPrimaryShipping()
234+
|| $address->getIsDefaultShipping();
234235
}
235236

236237
/**

app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public function testAfterAddressSaveDefaultGroup(
341341
$customer->expects($this->once())
342342
->method('getDisableAutoGroupChange')
343343
->willReturn(false);
344-
$customer->expects($this->once())
344+
$customer->expects($this->exactly(2))
345345
->method('getGroupId')
346346
->willReturn(null);
347347
$customer->expects($this->once())

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@
66

77
namespace Magento\Sales\Block\Adminhtml\Order\Create\Form;
88

9+
use Magento\Backend\Block\Template\Context;
10+
use Magento\Backend\Model\Session\Quote;
11+
use Magento\Customer\Api\CustomerRepositoryInterface;
12+
use Magento\Customer\Api\Data\CustomerInterface;
913
use Magento\Customer\Api\GroupManagementInterface;
14+
use Magento\Customer\Model\Metadata\Form;
1015
use Magento\Framework\Api\ExtensibleDataObjectConverter;
1116
use Magento\Framework\App\ObjectManager;
1217
use Magento\Framework\Data\Form\Element\AbstractElement;
18+
use Magento\Framework\Data\FormFactory;
19+
use Magento\Customer\Model\Metadata\FormFactory as MetadataFormFactory;
20+
use Magento\Framework\Exception\LocalizedException;
21+
use Magento\Framework\Exception\NoSuchEntityException;
22+
use Magento\Framework\Phrase;
1323
use Magento\Framework\Pricing\PriceCurrencyInterface;
24+
use Magento\Framework\Reflection\DataObjectProcessor;
25+
use Magento\Sales\Model\AdminOrder\Create;
26+
use Magento\Store\Model\ScopeInterface;
1427

1528
/**
1629
* Create order account form
@@ -25,46 +38,48 @@ class Account extends AbstractForm
2538
/**
2639
* Metadata form factory
2740
*
28-
* @var \Magento\Customer\Model\Metadata\FormFactory
41+
* @var MetadataFormFactory
2942
*/
3043
protected $_metadataFormFactory;
3144

3245
/**
3346
* Customer repository
3447
*
35-
* @var \Magento\Customer\Api\CustomerRepositoryInterface
48+
* @var CustomerRepositoryInterface
3649
*/
3750
protected $customerRepository;
3851

3952
/**
40-
* @var \Magento\Framework\Api\ExtensibleDataObjectConverter
53+
* @var ExtensibleDataObjectConverter
4154
*/
4255
protected $_extensibleDataObjectConverter;
56+
4357
private const XML_PATH_EMAIL_REQUIRED_CREATE_ORDER = 'customer/create_account/email_required_create_order';
58+
4459
/**
45-
* @param \Magento\Backend\Block\Template\Context $context
46-
* @param \Magento\Backend\Model\Session\Quote $sessionQuote
47-
* @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
60+
* @param Context $context
61+
* @param Quote $sessionQuote
62+
* @param Create $orderCreate
4863
* @param PriceCurrencyInterface $priceCurrency
49-
* @param \Magento\Framework\Data\FormFactory $formFactory
50-
* @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor
51-
* @param \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory
52-
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
64+
* @param FormFactory $formFactory
65+
* @param DataObjectProcessor $dataObjectProcessor
66+
* @param MetadataFormFactory $metadataFormFactory
67+
* @param CustomerRepositoryInterface $customerRepository
5368
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
5469
* @param array $data
5570
* @param GroupManagementInterface|null $groupManagement
5671
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5772
*/
5873
public function __construct(
59-
\Magento\Backend\Block\Template\Context $context,
60-
\Magento\Backend\Model\Session\Quote $sessionQuote,
61-
\Magento\Sales\Model\AdminOrder\Create $orderCreate,
74+
Context $context,
75+
Quote $sessionQuote,
76+
Create $orderCreate,
6277
PriceCurrencyInterface $priceCurrency,
63-
\Magento\Framework\Data\FormFactory $formFactory,
64-
\Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor,
65-
\Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory,
66-
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
67-
\Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
78+
FormFactory $formFactory,
79+
DataObjectProcessor $dataObjectProcessor,
80+
MetadataFormFactory $metadataFormFactory,
81+
CustomerRepositoryInterface $customerRepository,
82+
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
6883
array $data = [],
6984
?GroupManagementInterface $groupManagement = null
7085
) {
@@ -103,7 +118,7 @@ public function getHeaderCssClass()
103118
/**
104119
* Return header text
105120
*
106-
* @return \Magento\Framework\Phrase
121+
* @return Phrase
107122
*/
108123
public function getHeaderText()
109124
{
@@ -114,10 +129,12 @@ public function getHeaderText()
114129
* Prepare Form and add elements to form
115130
*
116131
* @return $this
132+
* @throws LocalizedException
133+
* @throws NoSuchEntityException
117134
*/
118135
protected function _prepareForm()
119136
{
120-
/** @var \Magento\Customer\Model\Metadata\Form $customerForm */
137+
/** @var Form $customerForm */
121138
$customerForm = $this->_metadataFormFactory->create('customer', 'adminhtml_checkout');
122139

123140
// prepare customer attributes to show
@@ -170,6 +187,8 @@ protected function _addAdditionalFormElementData(AbstractElement $element)
170187
* Return Form Elements values
171188
*
172189
* @return array
190+
* @throws LocalizedException
191+
* @throws NoSuchEntityException
173192
*/
174193
public function getFormValues()
175194
{
@@ -183,7 +202,7 @@ public function getFormValues()
183202
? $this->_extensibleDataObjectConverter->toFlatArray(
184203
$customer,
185204
[],
186-
\Magento\Customer\Api\Data\CustomerInterface::class
205+
CustomerInterface::class
187206
)
188207
: [];
189208
foreach ($this->getQuote()->getData() as $key => $value) {
@@ -193,7 +212,7 @@ public function getFormValues()
193212
}
194213

195214
if (array_key_exists('group_id', $data) && empty($data['group_id'])) {
196-
$data['group_id'] = $this->groupManagement->getDefaultGroup($this->getQuote()->getStoreId())->getId();
215+
$data['group_id'] = $this->getSelectedGroupId();
197216
}
198217

199218
if ($this->getQuote()->getCustomerEmail()) {
@@ -208,6 +227,8 @@ public function getFormValues()
208227
*
209228
* @param array $attributes
210229
* @return array
230+
* @throws LocalizedException
231+
* @throws NoSuchEntityException
211232
*/
212233
private function extractValuesFromAttributes(array $attributes): array
213234
{
@@ -231,7 +252,24 @@ private function isEmailRequiredToCreateOrder()
231252
{
232253
return $this->_scopeConfig->getValue(
233254
self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER,
234-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
255+
ScopeInterface::SCOPE_STORE
235256
);
236257
}
258+
259+
/**
260+
* Retrieve selected group id
261+
*
262+
* @return string
263+
* @throws LocalizedException
264+
* @throws NoSuchEntityException
265+
*/
266+
private function getSelectedGroupId(): string
267+
{
268+
$selectedGroupId = $this->groupManagement->getDefaultGroup($this->getQuote()->getStoreId())->getId();
269+
$orderDetails = $this->getRequest()->getParam('order');
270+
if (!empty($orderDetails) && !empty($orderDetails['account']['group_id'])) {
271+
$selectedGroupId = $orderDetails['account']['group_id'];
272+
}
273+
return $selectedGroupId;
274+
}
237275
}

app/code/Magento/SalesRule/Model/Rule/Condition/Address.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function loadAttributeOptions()
6262
{
6363
$attributes = [
6464
'base_subtotal_with_discount' => __('Subtotal (Excl. Tax)'),
65+
'base_subtotal_total_incl_tax' => __('Subtotal (Incl. Tax)'),
6566
'base_subtotal' => __('Subtotal'),
6667
'total_qty' => __('Total Items Quantity'),
6768
'weight' => __('Total Weight'),
@@ -99,6 +100,7 @@ public function getInputType()
99100
{
100101
switch ($this->getAttribute()) {
101102
case 'base_subtotal':
103+
case 'base_subtotal_total_incl_tax':
102104
case 'weight':
103105
case 'total_qty':
104106
return 'numeric';

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleAddressConditionsData.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
1111
<entity name="SalesRuleAddressConditions" type="SalesRuleConditionAttribute">
1212
<data key="subtotal">Magento\SalesRule\Model\Rule\Condition\Address|base_subtotal</data>
13+
<data key="base_subtotal_total_incl_tax">Magento\SalesRule\Model\Rule\Condition\Address|base_subtotal_total_incl_tax</data>
1314
<data key="totalItemsQty">Magento\SalesRule\Model\Rule\Condition\Address|total_qty</data>
1415
<data key="totalWeight">Magento\SalesRule\Model\Rule\Condition\Address|weight</data>
1516
<data key="shippingMethod">Magento\SalesRule\Model\Rule\Condition\Address|shipping_method</data>

0 commit comments

Comments
 (0)