Skip to content

Commit bc93cda

Browse files
authored
Merge branch '2.4-develop' into hacktoberfest_PR_4
2 parents 42d33a4 + 57a3231 commit bc93cda

File tree

31 files changed

+594
-119
lines changed

31 files changed

+594
-119
lines changed

app/code/Magento/Backend/Test/Mftf/ActionGroup/SecondaryGridActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</arguments>
2121

2222
<!-- search for the name -->
23+
<waitForElementClickable selector="{{AdminSecondaryGridSection.resetFilters}}" stepKey="waitForFiltersReset"/>
2324
<click stepKey="resetFilters" selector="{{AdminSecondaryGridSection.resetFilters}}"/>
2425
<fillField stepKey="fillIdentifier" selector="{{searchInput}}" userInput="{{name}}"/>
2526
<click stepKey="searchForName" selector="{{AdminSecondaryGridSection.searchButton}}"/>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Model\Category\Attribute\Backend;
18+
19+
class DefaultSortby extends Sortby
20+
{
21+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\Catalog\Setup\Patch\Data;
18+
19+
use Magento\Catalog\Setup\CategorySetup;
20+
use Magento\Catalog\Setup\CategorySetupFactory;
21+
use Magento\Framework\Setup\ModuleDataSetupInterface;
22+
use Magento\Framework\Setup\Patch\DataPatchInterface;
23+
use Magento\Framework\Setup\Patch\PatchInterface;
24+
25+
class UpdateDefaultSortyByBackendType implements DataPatchInterface
26+
{
27+
/**
28+
* @var ModuleDataSetupInterface
29+
*/
30+
private $moduleDataSetup;
31+
32+
/**
33+
* @var CategorySetupFactory
34+
*/
35+
private $categorySetupFactory;
36+
37+
/**
38+
* PatchInitial constructor.
39+
* @param ModuleDataSetupInterface $moduleDataSetup
40+
* @param CategorySetupFactory $categorySetupFactory
41+
*/
42+
public function __construct(
43+
ModuleDataSetupInterface $moduleDataSetup,
44+
CategorySetupFactory $categorySetupFactory
45+
) {
46+
$this->moduleDataSetup = $moduleDataSetup;
47+
$this->categorySetupFactory = $categorySetupFactory;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function apply(): UpdateDefaultSortyByBackendType
54+
{
55+
$mediaBackendModel = \Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby::class;
56+
/** @var CategorySetup $categorySetup */
57+
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
58+
$categorySetup->updateAttribute(
59+
'catalog_category',
60+
'default_sort_by',
61+
'backend_model',
62+
$mediaBackendModel
63+
);
64+
65+
return $this;
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public static function getDependencies()
72+
{
73+
return [];
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
public function getAliases()
80+
{
81+
return [];
82+
}
83+
}

app/code/Magento/Catalog/Test/Fixture/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Category implements RevertibleDataFixtureInterface
2727
'include_in_menu' => true,
2828
'available_sort_by' => [],
2929
'custom_attributes' => [
30-
'default_sort_by' => ['name']
30+
'default_sort_by' => 'position'
3131
],
3232
'extension_attributes' => [],
3333
'created_at' => null,

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontVerifyThatRecentlyOrderedWidgetShowOnlyFiveProductTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989

9090
<!--Place the order-->
9191
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage"/>
92+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectPaymentMethod"/>
9293
<actionGroup ref="PlaceOrderWithLoggedUserActionGroup" stepKey="placeOrder">
9394
<argument name="shippingMethod" value="Flat Rate"/>
9495
</actionGroup>

app/code/Magento/Catalog/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@
740740
<item name="Magento\Catalog\Model\Product\Attribute\Backend\Category" xsi:type="string">int[]</item>
741741
<item name="Magento\Catalog\Model\Product\Attribute\Backend\Stock" xsi:type="string">Magento\CatalogInventory\Api\Data\StockItemInterface[]</item>
742742
<item name="Magento\Catalog\Model\Category\Attribute\Backend\Sortby" xsi:type="string">string[]</item>
743+
<item name="Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" xsi:type="string">string</item>
743744
</argument>
744745
</arguments>
745746
</type>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/ClickPlaceOrderActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton"/>
1717
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder"/>
1818
<waitForPageLoad stepKey="waitForCheckout"/>
19-
<see selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="waitForLoadSuccessPage"/>
19+
<waitForText selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="waitForLoadSuccessPage"/>
2020
</actionGroup>
2121
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StoreFrontValidateDynamicChangeOfShippingRateForGuestUserTest.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@
5757
<actionGroup ref="OpenStoreFrontCheckoutShippingPageActionGroup" stepKey="goToShippingPage"/>
5858
<!-- Guest checkout -->
5959
<actionGroup ref="FillGuestCheckoutShippingAddressFormActionGroup" stepKey="goToShippingAndFillDetails">
60-
<argument name="customerAddress" value="US_CA_Address"/>
60+
<argument name="customerAddress" value="US_Address_CA"/>
6161
</actionGroup>
6262
<selectOption selector="{{CheckoutShippingSection.region}}" userInput="California" stepKey="fillStateField"/>
6363
<waitForPageLoad stepKey="waitForChangeAfterStateLoad"/>
64-
<actionGroup ref="CheckForFlatRateShippingMethodAvailabilityActionGroup" stepKey="verifyShippingMethod"/>
64+
<actionGroup ref="StorefrontCheckForFlatRateShippingMethodAvailabilityActionGroup" stepKey="verifyShippingMethod"/>
6565
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlLabel}}" stepKey="waitForDHLLabelVisible"/>
6666
<waitForElementNotVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlWorldWideExpress}}" stepKey="waitForDHLPriceNotVisibleAfterStateChange"/>
6767
<waitForElementNotVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShipping}}" stepKey="waitForFreeShippingNotVisible"/>
6868
<waitForElementNotVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShippingLabel}}" stepKey="waitForFreeShippingLabelNotVisible"/>
6969
<!-- Change country value -->
7070
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="Afghanistan" stepKey="fillCountryField"/>
7171
<waitForPageLoad stepKey="waitForChangeAfterCountryLoad"/>
72-
<actionGroup ref="CheckForFlatRateShippingMethodAvailabilityActionGroup" stepKey="verifyShippingMethodAfterCountryChange"/>
72+
<actionGroup ref="StorefrontCheckForFlatRateShippingMethodAvailabilityActionGroup" stepKey="verifyShippingMethodAfterCountryChange"/>
7373
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShipping}}" stepKey="waitForFreeShippingVisibleAfterCountryChange"/>
7474
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShippingLabel}}" stepKey="waitForFreeShippingLabelVisibleAfterCountryChange"/>
7575
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlLabel}}" stepKey="waitForDHLLabelVisibleAfterCountryChange"/>
@@ -79,10 +79,10 @@
7979
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="United Kingdom" stepKey="fillCountry"/>
8080
<fillField selector="{{CheckoutShippingSection.city}}" userInput="London" stepKey="fillCity"/>
8181
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="N14 5JP" stepKey="fillPostcode"/>
82-
<actionGroup ref="CheckForFlatRateShippingMethodAvailabilityActionGroup" stepKey="verifyShippingMethodAfterNewData"/>
82+
<actionGroup ref="StorefrontCheckForFlatRateShippingMethodAvailabilityActionGroup" stepKey="verifyShippingMethodAfterNewData"/>
8383
<waitForElementNotVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShipping}}" stepKey="waitForFreeShippingVisibleAfterNewFormData"/>
8484
<waitForElementNotVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShippingLabel}}" stepKey="waitForFreeShippingLabelVisibleAfterNewFormData"/>
85-
<actionGroup ref="VerifyDHLShippingMethodIsVisibilityActionGroup" stepKey="dhlShippingVisibility"/>
85+
<actionGroup ref="StorefrontVerifyDHLShippingMethodIsVisibilityActionGroup" stepKey="dhlShippingVisibility"/>
8686
<after>
8787
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
8888
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>

app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/GuestValidation.php

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@
66

77
namespace Magento\CheckoutAgreements\Model\Checkout\Plugin;
88

9+
use Magento\Checkout\Api\AgreementsValidatorInterface;
10+
use Magento\Checkout\Api\GuestPaymentInformationManagementInterface;
11+
use Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface;
912
use Magento\CheckoutAgreements\Model\AgreementsProvider;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\Exception\CouldNotSaveException;
15+
use Magento\Framework\Exception\NoSuchEntityException;
16+
use Magento\Quote\Api\Data\AddressInterface;
17+
use Magento\Quote\Api\Data\PaymentInterface;
18+
use Magento\Quote\Api\GuestCartRepositoryInterface;
19+
use Magento\Store\Model\App\Emulation;
1020
use Magento\Store\Model\ScopeInterface;
1121
use Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter;
1222

@@ -40,62 +50,85 @@ class GuestValidation
4050
private $activeStoreAgreementsFilter;
4151

4252
/**
43-
* @param \Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator
44-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration
45-
* @param \Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface $checkoutAgreementsList
53+
* @var GuestCartRepositoryInterface
54+
*/
55+
private GuestCartRepositoryInterface $quoteRepository;
56+
57+
/**
58+
* @var Emulation
59+
*/
60+
private Emulation $storeEmulation;
61+
62+
/**
63+
* @param AgreementsValidatorInterface $agreementsValidator
64+
* @param ScopeConfigInterface $scopeConfiguration
65+
* @param CheckoutAgreementsListInterface $checkoutAgreementsList
4666
* @param ActiveStoreAgreementsFilter $activeStoreAgreementsFilter
67+
* @param GuestCartRepositoryInterface $quoteRepository
68+
* @param Emulation $storeEmulation
4769
*/
4870
public function __construct(
4971
\Magento\Checkout\Api\AgreementsValidatorInterface $agreementsValidator,
5072
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration,
5173
\Magento\CheckoutAgreements\Api\CheckoutAgreementsListInterface $checkoutAgreementsList,
52-
\Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter $activeStoreAgreementsFilter
74+
\Magento\CheckoutAgreements\Model\Api\SearchCriteria\ActiveStoreAgreementsFilter $activeStoreAgreementsFilter,
75+
GuestCartRepositoryInterface $quoteRepository,
76+
Emulation $storeEmulation
5377
) {
5478
$this->agreementsValidator = $agreementsValidator;
5579
$this->scopeConfiguration = $scopeConfiguration;
5680
$this->checkoutAgreementsList = $checkoutAgreementsList;
5781
$this->activeStoreAgreementsFilter = $activeStoreAgreementsFilter;
82+
$this->quoteRepository = $quoteRepository;
83+
$this->storeEmulation = $storeEmulation;
5884
}
5985

6086
/**
6187
* Validates agreements before save payment information and order placing.
6288
*
63-
* @param \Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject
89+
* @param GuestPaymentInformationManagementInterface $subject
6490
* @param string $cartId
6591
* @param string $email
66-
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
67-
* @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress
68-
* @throws \Magento\Framework\Exception\CouldNotSaveException
92+
* @param PaymentInterface $paymentMethod
93+
* @param AddressInterface|null $billingAddress
6994
* @return void
7095
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
96+
* @throws CouldNotSaveException|NoSuchEntityException
7197
*/
7298
public function beforeSavePaymentInformationAndPlaceOrder(
73-
\Magento\Checkout\Api\GuestPaymentInformationManagementInterface $subject,
99+
GuestPaymentInformationManagementInterface $subject,
74100
$cartId,
75101
$email,
76-
\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
77-
\Magento\Quote\Api\Data\AddressInterface $billingAddress = null
102+
PaymentInterface $paymentMethod,
103+
AddressInterface $billingAddress = null
78104
) {
79105
if ($this->isAgreementEnabled()) {
80-
$this->validateAgreements($paymentMethod);
106+
$quote = $this->quoteRepository->get($cartId);
107+
$storeId = $quote->getStoreId();
108+
$this->validateAgreements($paymentMethod, $storeId);
81109
}
82110
}
83111

84112
/**
85113
* Validates agreements.
86114
*
87-
* @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod
88-
* @throws \Magento\Framework\Exception\CouldNotSaveException
115+
* @param PaymentInterface $paymentMethod
116+
* @param int $storeId
89117
* @return void
118+
* @throws CouldNotSaveException
90119
*/
91-
private function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod)
120+
private function validateAgreements(PaymentInterface $paymentMethod, int $storeId)
92121
{
93122
$agreements = $paymentMethod->getExtensionAttributes() === null
94123
? []
95124
: $paymentMethod->getExtensionAttributes()->getAgreementIds();
96125

97-
if (!$this->agreementsValidator->isValid($agreements)) {
98-
throw new \Magento\Framework\Exception\CouldNotSaveException(
126+
$this->storeEmulation->startEnvironmentEmulation($storeId);
127+
$isValid = $this->agreementsValidator->isValid($agreements);
128+
$this->storeEmulation->stopEnvironmentEmulation();
129+
130+
if (!$isValid) {
131+
throw new CouldNotSaveException(
99132
__(
100133
"The order wasn't placed. "
101134
. "First, agree to the terms and conditions, then try placing your order again."

0 commit comments

Comments
 (0)