Skip to content

Commit 2a55516

Browse files
Merge pull request #8656 from magento-gl/spartans_pr_04122023
[Spartans] Bugfix Delivery
2 parents d88a9d2 + d75bbfc commit 2a55516

File tree

18 files changed

+307
-30
lines changed

18 files changed

+307
-30
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ public function save(ProductInterface $product, $saveOptions = false)
526526
$assignToCategories = false;
527527
$tierPrices = $product->getData('tier_price');
528528
$productDataToChange = $product->getData();
529-
530529
try {
531530
$existingProduct = $product->getId() ?
532531
$this->getById($product->getId()) :
@@ -597,14 +596,16 @@ public function save(ProductInterface $product, $saveOptions = false)
597596
&& $product->getStoreId() !== Store::DEFAULT_STORE_ID
598597
&& (count($stores) > 1 || count($websites) === 1)
599598
) {
599+
$imageRoles = ['image', 'small_image', 'thumbnail'];
600600
foreach ($productAttributes as $attribute) {
601601
$attributeCode = $attribute->getAttributeCode();
602602
$value = $product->getData($attributeCode);
603-
if ($existingProduct->getData($attributeCode) === $value
603+
if (!in_array($attributeCode, $imageRoles)
604+
&& $existingProduct->getData($attributeCode) === $value
605+
&& $existingProduct->getOrigData($attributeCode) === $value
604606
&& $attribute->getScope() !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
605607
&& !is_array($value)
606608
&& !$attribute->isStatic()
607-
&& !array_key_exists($attributeCode, $productDataToChange)
608609
&& $value !== null
609610
&& !$this->scopeOverriddenValue->containsValue(
610611
ProductInterface::class,
@@ -618,6 +619,21 @@ public function save(ProductInterface $product, $saveOptions = false)
618619
$attributeCode === ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY ? false : null
619620
);
620621
$hasDataChanged = true;
622+
} elseif (in_array($attributeCode, $imageRoles)
623+
&& $existingProduct->getData($attributeCode) === $value
624+
&& !array_key_exists($attributeCode, $productDataToChange)
625+
&& $attribute->getScope() !== EavAttributeInterface::SCOPE_GLOBAL_TEXT
626+
&& $value !== null
627+
&& !$this->scopeOverriddenValue->containsValue(
628+
ProductInterface::class,
629+
$product,
630+
$attributeCode,
631+
$product->getStoreId()
632+
)
633+
634+
) {
635+
$product->setData($attributeCode, null);
636+
$hasDataChanged = true;
621637
}
622638
}
623639
if ($hasDataChanged) {

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ public function getQuery(array $dimensions, string $productType, array $entityId
230230
$select->where('cgw.website_id IS NULL');
231231

232232
if ($entityIds !== null) {
233-
$select->where(sprintf('e.entity_id BETWEEN %s AND %s', min($entityIds), max($entityIds)));
234233
$select->where('e.entity_id IN(?)', $entityIds, \Zend_Db::INT_TYPE);
235234
}
236235

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="CheckoutSelectCreditCardPaymentActionGroup">
12+
<annotations>
13+
<description>Selects the 'Credit card' Payment Method on the Storefront Checkout page.</description>
14+
</annotations>
15+
16+
<waitForPageLoad stepKey="waitForLoadingMask"/>
17+
<waitForPageLoad stepKey="waitForPageLoad"/>
18+
<click selector="{{StorefrontCheckoutPaymentMethodSection.checkCreditCard}}" stepKey="selectCreditCardPaymentMethod"/>
19+
<waitForPageLoad stepKey="waitForLoadingMaskAfterPaymentMethodSelection"/>
20+
</actionGroup>
21+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCheckoutPaymentMethodSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<section name="StorefrontCheckoutPaymentMethodSection">
1212
<element name="billingAddress" type="text" selector=".checkout-billing-address"/>
1313
<element name="checkPaymentMethodByName" type="radio" selector="//div[@id='checkout-payment-method-load']//div[@class='payment-method']//label//span[contains(., '{{methodName}}')]/../..//input" parameterized="true"/>
14+
<element name="checkCreditCard" type="radio" selector="//div[@id='checkout-payment-method-load']//div[@class='payment-method payment-method-braintree']//label//span[contains(., 'Credit Card')]/../..//input"/>
1415
<element name="billingAddressSameAsShipping" type="checkbox" selector=".payment-method._active [name='billing-address-same-as-shipping']"/>
1516
<element name="billingAddressSameAsShippingShared" type="checkbox" selector="#billing-address-same-as-shipping-shared"/>
1617
<element name="paymentOnAccount" type="radio" selector="#companycredit" deprecated="Use StorefrontCheckoutPaymentSection.paymentOnAccount B2B repository"/>

app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,20 @@
511511
<data key="postcode">5555</data>
512512
<data key="telephone">555-55-555-55</data>
513513
</entity>
514+
<entity name="US_Address_CA_CC" type="address">
515+
<data key="firstname">CCREJECT-BANK_ERROR</data>
516+
<data key="lastname">Doe</data>
517+
<array key="street">
518+
<item>119 Belmont St</item>
519+
</array>
520+
<data key="city">Ontario</data>
521+
<data key="state">California</data>
522+
<data key="country_id">US</data>
523+
<data key="country">United States</data>
524+
<data key="postcode">91761</data>
525+
<data key="telephone">7865438767</data>
526+
<data key="default_billing">Yes</data>
527+
<data key="default_shipping">Yes</data>
528+
<requiredEntity type="region">RegionCA</requiredEntity>
529+
</entity>
514530
</entities>

app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,18 @@
489489
<data key="group">General</data>
490490
<requiredEntity type="address">Canada_Address</requiredEntity>
491491
</entity>
492+
<entity name="Custom_US_Customer" type="customer">
493+
<data key="group_id">1</data>
494+
<data key="default_billing">true</data>
495+
<data key="default_shipping">true</data>
496+
<data key="email" unique="prefix">John.Doe@example.com</data>
497+
<data key="firstname">John</data>
498+
<data key="lastname">Doe</data>
499+
<data key="fullname">John Doe</data>
500+
<data key="password">pwdTest123!</data>
501+
<data key="store_id">0</data>
502+
<data key="website_id">0</data>
503+
<data key="group">General</data>
504+
<requiredEntity type="address">US_Address_CA_CC</requiredEntity>
505+
</entity>
492506
</entities>

app/code/Magento/Directory/Model/Currency.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,11 @@ private function formatCurrency(string $price, array $options): string
428428

429429
$this->numberFormatter = $this->getNumberFormatter($options);
430430

431+
$this->numberFormatter->setAttribute(
432+
\NumberFormatter::ROUNDING_MODE,
433+
\NumberFormatter::ROUND_HALFUP
434+
);
435+
431436
$formattedCurrency = $this->numberFormatter->formatCurrency(
432437
$price,
433438
$this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)

app/code/Magento/Quote/Model/QuoteValidator.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Quote\Model\Quote as QuoteEntity;
1515
use Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage as OrderAmountValidationMessage;
1616
use Magento\Quote\Model\ValidationRules\QuoteValidationRuleInterface;
17+
use Magento\Framework\Webapi\Rest\Response as RestResponse;
1718

1819
/**
1920
* Class to validate the quote
@@ -43,24 +44,32 @@ class QuoteValidator
4344
*/
4445
private $quoteValidationRule;
4546

47+
/**
48+
* @var RestResponse
49+
*/
50+
private $_response;
51+
4652
/**
4753
* QuoteValidator constructor.
4854
*
4955
* @param AllowedCountries|null $allowedCountryReader
5056
* @param OrderAmountValidationMessage|null $minimumAmountMessage
5157
* @param QuoteValidationRuleInterface|null $quoteValidationRule
58+
* @param RestResponse|null $response
5259
*/
5360
public function __construct(
5461
AllowedCountries $allowedCountryReader = null,
5562
OrderAmountValidationMessage $minimumAmountMessage = null,
56-
QuoteValidationRuleInterface $quoteValidationRule = null
63+
QuoteValidationRuleInterface $quoteValidationRule = null,
64+
RestResponse $response = null
5765
) {
5866
$this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance()
5967
->get(AllowedCountries::class);
6068
$this->minimumAmountMessage = $minimumAmountMessage ?: ObjectManager::getInstance()
6169
->get(OrderAmountValidationMessage::class);
6270
$this->quoteValidationRule = $quoteValidationRule ?: ObjectManager::getInstance()
6371
->get(QuoteValidationRuleInterface::class);
72+
$this->_response = $response ?: ObjectManager::getInstance()->get(RestResponse::class);
6473
}
6574

6675
/**
@@ -106,6 +115,7 @@ public function validateBeforeSubmit(QuoteEntity $quote)
106115
$defaultMessage .= ' %1';
107116
}
108117
if ($defaultMessage) {
118+
$this->_response->setHeader('errorRedirectAction', '#shipping');
109119
throw new ValidatorException(__($defaultMessage, implode(' ', $messages)));
110120
}
111121
}

app/code/Magento/QuoteGraphQl/Model/Resolver/CartPrices.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ private function getAppliedTaxes(Total $total, string $currency): array
9898
$rates = [];
9999

100100
foreach ($appliedTaxes as $appliedTax) {
101+
$totalPercentage = $appliedTax['percent'];
101102
foreach ($appliedTax['rates'] as $appliedTaxRate) {
102103
$rateTitle = $appliedTaxRate['title'];
103104
if (!array_key_exists($rateTitle, $rates)) {
104105
$rates[$rateTitle] = 0.0;
105106
}
106-
$rates[$rateTitle] += $appliedTax['amount'];
107+
$percentage = $appliedTaxRate['percent'];
108+
$taxValue = ($percentage / $totalPercentage) * $appliedTax['amount'];
109+
$rates[$rateTitle] += round((float) $taxValue, 2);
107110
}
108111
}
109112

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminBraintreeEnableActionGroup">
12+
<annotations>
13+
<description>Goes to the 'Configuration' page for 'Payment Methods'. Fills in the provided Sample Braintree credentials and other details. Clicks on Save.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="credentials" defaultValue="SampleBraintreeConfig"/>
17+
<argument name="countryCode" type="string" defaultValue="us"/>
18+
</arguments>
19+
<amOnPage url="{{AdminConfigBraintreePage.url}}" stepKey="navigateToPaymentConfigurationPage"/>
20+
<waitForPageLoad stepKey="waitForPageLoad1"/>
21+
<click selector="{{BraintreeConfigSection.configureBtn(countryCode)}}" stepKey="clickBraintreeConfigureBtn"/>
22+
<selectOption selector ="{{BraintreeConfigSection.environment(countryCode)}}" userInput="Sandbox" stepKey="inputTypeOfEnvironment"/>
23+
<selectOption selector ="{{BraintreeConfigSection.paymentAction(countryCode)}}" userInput="Authorize" stepKey="inputPaymentAction"/>
24+
<fillField selector ="{{BraintreeConfigSection.merchantID(countryCode)}}" userInput="{{credentials.braintree_merchant_id}}" stepKey="inputMerchantId"/>
25+
<fillField selector ="{{BraintreeConfigSection.publicKey(countryCode)}}" userInput="{{credentials.braintree_public_key}}" stepKey="inputPublicKey"/>
26+
<fillField selector ="{{BraintreeConfigSection.privateKey(countryCode)}}" userInput="{{credentials.braintree_private_key}}" stepKey="inputPrivateKey"/>
27+
<selectOption selector ="{{BraintreeConfigSection.enableCard(countryCode)}}" userInput="Yes" stepKey="enableCardPayment"/>
28+
<click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig"/>
29+
<waitForPageLoad stepKey="waitForPageLoad2"/>
30+
</actionGroup>
31+
</actionGroups>

0 commit comments

Comments
 (0)