Skip to content

Commit 02973bd

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-l3/magento2ce into ACP2E-763
2 parents e9b1ed7 + ac0c588 commit 02973bd

File tree

27 files changed

+639
-150
lines changed

27 files changed

+639
-150
lines changed

app/code/Magento/Catalog/Model/Product/Price/BasePriceStorage.php

Lines changed: 84 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,27 @@
66

77
namespace Magento\Catalog\Model\Product\Price;
88

9+
use Magento\Catalog\Api\BasePriceStorageInterface;
10+
use Magento\Catalog\Api\Data\BasePriceInterface;
11+
use Magento\Catalog\Api\Data\BasePriceInterfaceFactory;
12+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
13+
use Magento\Catalog\Api\ProductRepositoryInterface;
14+
use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor;
15+
use Magento\Catalog\Model\Product\Price\Validation\Result;
16+
use Magento\Catalog\Model\ProductIdLocatorInterface;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Exception\NoSuchEntityException;
19+
use Magento\Store\Api\StoreRepositoryInterface;
20+
use Magento\Store\Model\Store;
21+
922
/**
1023
* Base prices storage.
24+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1125
*/
12-
class BasePriceStorage implements \Magento\Catalog\Api\BasePriceStorageInterface
26+
class BasePriceStorage implements BasePriceStorageInterface
1327
{
1428
/**
15-
* Attribute code.
29+
* Price attribute code.
1630
*
1731
* @var string
1832
*/
@@ -24,27 +38,27 @@ class BasePriceStorage implements \Magento\Catalog\Api\BasePriceStorageInterface
2438
private $pricePersistence;
2539

2640
/**
27-
* @var \Magento\Catalog\Api\Data\BasePriceInterfaceFactory
41+
* @var BasePriceInterfaceFactory
2842
*/
2943
private $basePriceInterfaceFactory;
3044

3145
/**
32-
* @var \Magento\Catalog\Model\ProductIdLocatorInterface
46+
* @var ProductIdLocatorInterface
3347
*/
3448
private $productIdLocator;
3549

3650
/**
37-
* @var \Magento\Store\Api\StoreRepositoryInterface
51+
* @var StoreRepositoryInterface
3852
*/
3953
private $storeRepository;
4054

4155
/**
42-
* @var \Magento\Catalog\Api\ProductRepositoryInterface
56+
* @var ProductRepositoryInterface
4357
*/
4458
private $productRepository;
4559

4660
/**
47-
* @var \Magento\Catalog\Model\Product\Price\Validation\Result
61+
* @var Result
4862
*/
4963
private $validationResult;
5064

@@ -54,43 +68,50 @@ class BasePriceStorage implements \Magento\Catalog\Api\BasePriceStorageInterface
5468
private $pricePersistenceFactory;
5569

5670
/**
57-
* @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor
71+
* @var InvalidSkuProcessor
5872
*/
5973
private $invalidSkuProcessor;
6074

6175
/**
62-
* Price type allowed.
76+
* @var ProductAttributeRepositoryInterface
77+
*/
78+
private $productAttributeRepository;
79+
80+
/**
81+
* Is price type allowed
6382
*
6483
* @var int
6584
*/
6685
private $priceTypeAllowed = 1;
6786

6887
/**
69-
* Allowed product types.
88+
* Array of allowed product types.
7089
*
7190
* @var array
7291
*/
7392
private $allowedProductTypes = [];
7493

7594
/**
7695
* @param PricePersistenceFactory $pricePersistenceFactory
77-
* @param \Magento\Catalog\Api\Data\BasePriceInterfaceFactory $basePriceInterfaceFactory
78-
* @param \Magento\Catalog\Model\ProductIdLocatorInterface $productIdLocator
79-
* @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository
80-
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
81-
* @param \Magento\Catalog\Model\Product\Price\Validation\Result $validationResult
82-
* @param \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor $invalidSkuProcessor
96+
* @param BasePriceInterfaceFactory $basePriceInterfaceFactory
97+
* @param ProductIdLocatorInterface $productIdLocator
98+
* @param StoreRepositoryInterface $storeRepository
99+
* @param ProductRepositoryInterface $productRepository
100+
* @param Result $validationResult
101+
* @param InvalidSkuProcessor $invalidSkuProcessor
83102
* @param array $allowedProductTypes [optional]
103+
* @param ProductAttributeRepositoryInterface|null $productAttributeRepository
84104
*/
85105
public function __construct(
86106
PricePersistenceFactory $pricePersistenceFactory,
87-
\Magento\Catalog\Api\Data\BasePriceInterfaceFactory $basePriceInterfaceFactory,
88-
\Magento\Catalog\Model\ProductIdLocatorInterface $productIdLocator,
89-
\Magento\Store\Api\StoreRepositoryInterface $storeRepository,
90-
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
91-
\Magento\Catalog\Model\Product\Price\Validation\Result $validationResult,
92-
\Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor $invalidSkuProcessor,
93-
array $allowedProductTypes = []
107+
BasePriceInterfaceFactory $basePriceInterfaceFactory,
108+
ProductIdLocatorInterface $productIdLocator,
109+
StoreRepositoryInterface $storeRepository,
110+
ProductRepositoryInterface $productRepository,
111+
Result $validationResult,
112+
InvalidSkuProcessor $invalidSkuProcessor,
113+
array $allowedProductTypes = [],
114+
ProductAttributeRepositoryInterface $productAttributeRepository = null
94115
) {
95116
$this->pricePersistenceFactory = $pricePersistenceFactory;
96117
$this->basePriceInterfaceFactory = $basePriceInterfaceFactory;
@@ -100,10 +121,12 @@ public function __construct(
100121
$this->validationResult = $validationResult;
101122
$this->allowedProductTypes = $allowedProductTypes;
102123
$this->invalidSkuProcessor = $invalidSkuProcessor;
124+
$this->productAttributeRepository = $productAttributeRepository ?: ObjectManager::getInstance()
125+
->get(ProductAttributeRepositoryInterface::class);
103126
}
104127

105128
/**
106-
* {@inheritdoc}
129+
* @inheritdoc
107130
*/
108131
public function get(array $skus)
109132
{
@@ -128,7 +151,7 @@ public function get(array $skus)
128151
}
129152

130153
/**
131-
* {@inheritdoc}
154+
* @inheritdoc
132155
*/
133156
public function update(array $prices)
134157
{
@@ -146,6 +169,12 @@ public function update(array $prices)
146169
}
147170
}
148171

172+
$priceAttribute = $this->productAttributeRepository->get($this->attributeCode);
173+
174+
if ($priceAttribute !== null && $priceAttribute->isScopeWebsite()) {
175+
$formattedPrices = $this->applyWebsitePrices($formattedPrices);
176+
}
177+
149178
$this->getPricePersistence()->update($formattedPrices);
150179

151180
return $this->validationResult->getFailedItems();
@@ -168,7 +197,7 @@ private function getPricePersistence()
168197
/**
169198
* Retrieve valid prices that do not contain any errors.
170199
*
171-
* @param \Magento\Catalog\Api\Data\BasePriceInterface[] $prices
200+
* @param BasePriceInterface[] $prices
172201
* @return array
173202
*/
174203
private function retrieveValidPrices(array $prices)
@@ -207,7 +236,7 @@ private function retrieveValidPrices(array $prices)
207236
}
208237
try {
209238
$this->storeRepository->getById($price->getStoreId());
210-
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
239+
} catch (NoSuchEntityException $e) {
211240
$this->validationResult->addFailedItem(
212241
$id,
213242
__(
@@ -225,4 +254,32 @@ private function retrieveValidPrices(array $prices)
225254

226255
return $prices;
227256
}
257+
258+
/**
259+
* If Catalog Price Mode is Website, price needs to be applied to all Store Views in this website.
260+
*
261+
* @param array $formattedPrices
262+
* @return array
263+
* @throws NoSuchEntityException
264+
*/
265+
private function applyWebsitePrices($formattedPrices): array
266+
{
267+
foreach ($formattedPrices as $price) {
268+
if ($price['store_id'] == Store::DEFAULT_STORE_ID) {
269+
continue;
270+
}
271+
272+
$storeIds = $this->storeRepository->getById($price['store_id'])->getWebsite()->getStoreIds();
273+
274+
// Unset origin store view to get rid of duplicate
275+
unset($storeIds[$price['store_id']]);
276+
277+
foreach ($storeIds as $storeId) {
278+
$price['store_id'] = (int)$storeId;
279+
$formattedPrices[] = $price;
280+
}
281+
}
282+
283+
return $formattedPrices;
284+
}
228285
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="StorefrontGuestSignInActionGroup">
12+
<annotations>
13+
<description>Enter email id and password, click on sign in button.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="email" type="string" defaultValue=""/>
17+
<argument name="password" type="string" defaultValue=""/>
18+
</arguments>
19+
<fillField selector="{{StorefrontCustomerSignInPopupFormSection.email}}" userInput="{{email}}" stepKey="fillEmailId"/>
20+
<fillField selector="{{StorefrontCustomerSignInPopupFormSection.password}}" userInput="{{password}}" stepKey="fillPassword"/>
21+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.createAnAccount}}" stepKey="seeCreateAnAccount"/>
22+
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.forgotYourPassword}}" stepKey="seeForgotYourPassword"/>
23+
<click selector="{{StorefrontCustomerSignInPopupFormSection.signIn}}" stepKey="clickOnSignIn"/>
24+
</actionGroup>
25+
</actionGroups>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="CheckoutShippingGuestInfoSection">
1212
<element name="email" type="input" selector="#customer-email"/>
1313
<element name="firstName" type="input" selector="input[name=firstname]"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontShoppingCartGuestCheckoutDisabledTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Modal window for Sign In is shown if Guest checkout is disabled. "/>
15+
<title value="Modal window for Sign In is shown if Guest checkout is disabled."/>
16+
<description value="Modal window for Sign In is shown if Guest checkout is disabled. Flow from Shopping Cart"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-27419"/>
19+
<group value="module-checkout"/>
20+
</annotations>
21+
<before>
22+
<!-- create category and simple product -->
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<!--Goto Admin Configuration page and Allow Guest Checkout is No-->
28+
<createData entity="DisableAllowGuestCheckout" stepKey="storeConfigurationAllowGuestCheckoutNo">
29+
</createData>
30+
<!-- create customer and clean the cache and index-->
31+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
32+
</before>
33+
<!-- Goto storefront and add product to cart-->
34+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="onCategoryPage"/>
35+
<waitForPageLoad stepKey="waitForPageLoad6"/>
36+
<actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverProduct"/>
37+
<actionGroup ref="StorefrontClickAddToCartButtonActionGroup" stepKey="addToCart"/>
38+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/>
39+
<see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/>
40+
<see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/>
41+
<!-- Checkout form mini cart-->
42+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="guestGoToCheckoutFromMiniCart"/>
43+
<!-- click on Place Order and Guest sing in -->
44+
<actionGroup ref="StorefrontGuestSignInActionGroup" stepKey="singInForPlaceOrder">
45+
<argument name="email" value="$$createCustomer.email$$"/>
46+
<argument name="password" value="$$createCustomer.password$$"/>
47+
</actionGroup>
48+
<after>
49+
<!--Goto Admin Configuration page and Allow Guest Checkout is Yes-->
50+
<createData entity="EnableAllowGuestCheckout" stepKey="storeConfigurationAllowGuestCheckoutYes">
51+
</createData>
52+
<!-- Delete created category, product and customer-->
53+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
54+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
55+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
56+
</after>
57+
</test>
58+
</tests>

app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
<element name="ShippingTaxClass" type="select" selector="#tax_classes_shipping_tax_class"/>
1515
<element name="EnableTaxClassForShipping" type="checkbox" selector="#tax_classes_shipping_tax_class_inherit"/>
1616
</section>
17-
</sections>
17+
</sections>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSignInFormSection/StorefrontCustomerSignInPopupFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<element name="email" type="input" selector="#customer-email"/>
1313
<element name="password" type="input" selector="#pass"/>
1414
<element name="signIn" type="button" selector="#send2" timeout="30"/>
15+
<element name="forgotYourPassword" type="button" selector="//a[@class='action']//span[contains(text(),'Forgot Your Password?')]" timeout="30"/>
1516
<element name="createAnAccount" type="button" selector="//div[contains(@class,'actions-toolbar')]//a[contains(.,'Create an Account')]" timeout="30"/>
1617
</section>
1718
</sections>

app/code/Magento/NewRelicReporting/Console/Command/DeployMarker.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DeployMarker extends Command
2929
*
3030
* @param DeploymentsFactory $deploymentsFactory
3131
* @param ServiceShellUser $serviceShellUser
32-
* @param null $name
32+
* @param ?string $name
3333
*/
3434
public function __construct(
3535
DeploymentsFactory $deploymentsFactory,
@@ -42,7 +42,7 @@ public function __construct(
4242
}
4343

4444
/**
45-
* {@inheritdoc}
45+
* @inheritdoc
4646
*/
4747
protected function configure()
4848
{
@@ -62,20 +62,27 @@ protected function configure()
6262
'user',
6363
InputArgument::OPTIONAL,
6464
'Deployment User'
65+
)->addArgument(
66+
'revision',
67+
InputArgument::OPTIONAL,
68+
'Revision'
6569
);
6670
parent::configure();
6771
}
6872

6973
/**
70-
* {@inheritdoc}
74+
* @inheritdoc
7175
*/
7276
protected function execute(InputInterface $input, OutputInterface $output)
7377
{
7478
$this->deploymentsFactory->create()->setDeployment(
7579
$input->getArgument('message'),
7680
$input->getArgument('change_log'),
77-
$this->serviceShellUser->get($input->getArgument('user'))
81+
$this->serviceShellUser->get($input->getArgument('user')),
82+
$input->getArgument('revision')
7883
);
7984
$output->writeln('<info>NewRelic deployment information sent</info>');
85+
86+
return 0;
8087
}
8188
}

0 commit comments

Comments
 (0)