Skip to content

Commit 8463500

Browse files
committed
Merge remote-tracking branch 'github-magento/MAGETWO-98947' into EPAM-PR-51
2 parents c390f29 + 2672e99 commit 8463500

File tree

46 files changed

+1870
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1870
-141
lines changed

app/code/Magento/ConfigurableProduct/Setup/Patch/Data/InstallInitialConfigurableAttributes.php

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

77
namespace Magento\ConfigurableProduct\Setup\Patch\Data;
88

9+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
910
use Magento\Eav\Setup\EavSetup;
1011
use Magento\Eav\Setup\EavSetupFactory;
11-
use Magento\Framework\App\ResourceConnection;
1212
use Magento\Framework\Setup\ModuleDataSetupInterface;
1313
use Magento\Framework\Setup\Patch\DataPatchInterface;
1414
use Magento\Framework\Setup\Patch\PatchVersionInterface;
15-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1615

1716
/**
1817
* Class InstallInitialConfigurableAttributes
18+
*
1919
* @package Magento\ConfigurableProduct\Setup\Patch
2020
*/
2121
class InstallInitialConfigurableAttributes implements DataPatchInterface, PatchVersionInterface
@@ -24,6 +24,7 @@ class InstallInitialConfigurableAttributes implements DataPatchInterface, PatchV
2424
* @var ModuleDataSetupInterface
2525
*/
2626
private $moduleDataSetup;
27+
2728
/**
2829
* @var EavSetupFactory
2930
*/
@@ -43,7 +44,7 @@ public function __construct(
4344
}
4445

4546
/**
46-
* {@inheritdoc}
47+
* @inheritdoc
4748
*/
4849
public function apply()
4950
{
@@ -64,40 +65,43 @@ public function apply()
6465
'color'
6566
];
6667
foreach ($attributes as $attributeCode) {
67-
$relatedProductTypes = explode(
68-
',',
69-
$eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode, 'apply_to')
70-
);
71-
if (!in_array(Configurable::TYPE_CODE, $relatedProductTypes)) {
72-
$relatedProductTypes[] = Configurable::TYPE_CODE;
73-
$eavSetup->updateAttribute(
74-
\Magento\Catalog\Model\Product::ENTITY,
75-
$attributeCode,
76-
'apply_to',
77-
implode(',', $relatedProductTypes)
68+
$attribute = $eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode, 'apply_to');
69+
if ($attribute) {
70+
$relatedProductTypes = explode(
71+
',',
72+
$attribute
7873
);
74+
if (!in_array(Configurable::TYPE_CODE, $relatedProductTypes)) {
75+
$relatedProductTypes[] = Configurable::TYPE_CODE;
76+
$eavSetup->updateAttribute(
77+
\Magento\Catalog\Model\Product::ENTITY,
78+
$attributeCode,
79+
'apply_to',
80+
implode(',', $relatedProductTypes)
81+
);
82+
}
7983
}
8084
}
8185
}
8286

8387
/**
84-
* {@inheritdoc}
88+
* @inheritdoc
8589
*/
8690
public static function getDependencies()
8791
{
8892
return [];
8993
}
9094

9195
/**
92-
* {@inheritdoc}
96+
* @inheritdoc
9397
*/
9498
public static function getVersion()
9599
{
96100
return '2.0.0';
97101
}
98102

99103
/**
100-
* {@inheritdoc}
104+
* @inheritdoc
101105
*/
102106
public function getAliases()
103107
{

app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1111
<actionGroup name="CustomerLogoutStorefrontByMenuItemsActionGroup">
12-
<conditionalClick selector="{{StorefrontPanelHeaderSection.customerWelcome}}"
13-
dependentSelector="{{StorefrontPanelHeaderSection.customerWelcomeMenu}}"
12+
<conditionalClick selector="{{StorefrontPanelHeaderSection.customerWelcomeMenu}}"
13+
dependentSelector="{{StorefrontPanelHeaderSection.customerLogoutLink}}"
1414
visible="false"
1515
stepKey="clickHeaderCustomerMenuButton" />
1616
<click selector="{{StorefrontPanelHeaderSection.customerLogoutLink}}" stepKey="clickSignOutButton" />

app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<element name="welcomeMessage" type="text" selector="header>.panel .greet.welcome" />
1616
<element name="createAnAccountLink" type="select" selector="//div[@class='panel wrapper']//li/a[contains(.,'Create an Account')]" timeout="30"/>
1717
<element name="notYouLink" type="button" selector=".greet.welcome span a"/>
18-
<element name="customerWelcome" type="text" selector=".panel.header .customer-welcome"/>
19-
<element name="customerWelcomeMenu" type="text" selector=".panel.header .customer-welcome .customer-menu"/>
18+
<element name="customerWelcome" type="text" selector=".panel.header .greet.welcome"/>
19+
<element name="customerWelcomeMenu" type="text" selector=".panel.header .customer-welcome .customer-name"/>
2020
<element name="customerLoginLink" type="button" selector=".panel.header .header.links .authorization-link a" timeout="30"/>
2121
<element name="customerLogoutLink" type="text" selector=".panel.header .customer-welcome .customer-menu .authorization-link a" timeout="30"/>
2222
</section>

app/code/Magento/Customer/view/frontend/templates/account/customer.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
data-toggle="dropdown"
1717
data-trigger-keypress-button="true"
1818
data-bind="scope: 'customer'">
19-
<span data-bind="text: customer().fullname"></span>
2019
<button type="button"
2120
class="action switch"
2221
tabindex="-1"

app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Store\Model\ScopeInterface;
1010

1111
/**
12+
* Saves data from order to purchased links.
13+
*
1214
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1315
*/
1416
class SaveDownloadableOrderItemObserver implements ObserverInterface
@@ -92,9 +94,15 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9294
if ($purchasedLink->getId()) {
9395
return $this;
9496
}
97+
$storeId = $orderItem->getOrder()->getStoreId();
98+
$orderStatusToEnableItem = $this->_scopeConfig->getValue(
99+
\Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS,
100+
ScopeInterface::SCOPE_STORE,
101+
$storeId
102+
);
95103
if (!$product) {
96104
$product = $this->_createProductModel()->setStoreId(
97-
$orderItem->getOrder()->getStoreId()
105+
$storeId
98106
)->load(
99107
$orderItem->getProductId()
100108
);
@@ -150,6 +158,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
150158
)->setNumberOfDownloadsBought(
151159
$numberOfDownloads
152160
)->setStatus(
161+
\Magento\Sales\Model\Order\Item::STATUS_PENDING == $orderStatusToEnableItem ?
162+
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE :
153163
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING
154164
)->setCreatedAt(
155165
$orderItem->getCreatedAt()
@@ -165,6 +175,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
165175
}
166176

167177
/**
178+
* Create purchased model.
179+
*
168180
* @return \Magento\Downloadable\Model\Link\Purchased
169181
*/
170182
protected function _createPurchasedModel()
@@ -173,6 +185,8 @@ protected function _createPurchasedModel()
173185
}
174186

175187
/**
188+
* Create product model.
189+
*
176190
* @return \Magento\Catalog\Model\Product
177191
*/
178192
protected function _createProductModel()
@@ -181,6 +195,8 @@ protected function _createProductModel()
181195
}
182196

183197
/**
198+
* Create purchased item model.
199+
*
184200
* @return \Magento\Downloadable\Model\Link\Purchased\Item
185201
*/
186202
protected function _createPurchasedItemModel()
@@ -189,6 +205,8 @@ protected function _createPurchasedItemModel()
189205
}
190206

191207
/**
208+
* Create items collection.
209+
*
192210
* @return \Magento\Downloadable\Model\ResourceModel\Link\Purchased\Item\Collection
193211
*/
194212
protected function _createItemsCollection()

app/code/Magento/Quote/Model/Quote/Item/Compare.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function getOptionValues($value)
5050
if (is_string($value) && $this->jsonValidator->isValid($value)) {
5151
$value = $this->serializer->unserialize($value);
5252
if (is_array($value)) {
53-
unset($value['qty'], $value['uenc']);
53+
unset($value['qty'], $value['uenc'], $value['related_product'], $value['item']);
5454
$value = array_filter($value, function ($optionValue) {
5555
return !empty($optionValue);
5656
});
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\QuoteGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
14+
use Magento\Quote\Model\Quote;
15+
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser;
16+
17+
/**
18+
* @inheritdoc
19+
*/
20+
class CartEmail implements ResolverInterface
21+
{
22+
/**
23+
* @var GetCartForUser
24+
*/
25+
private $getCartForUser;
26+
27+
/**
28+
* @param GetCartForUser $getCartForUser
29+
*/
30+
public function __construct(
31+
GetCartForUser $getCartForUser
32+
) {
33+
$this->getCartForUser = $getCartForUser;
34+
}
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
40+
{
41+
if (!isset($value['model'])) {
42+
throw new LocalizedException(__('"model" value should be specified'));
43+
}
44+
/** @var Quote $cart */
45+
$cart = $value['model'];
46+
47+
return $cart->getCustomerEmail();
48+
}
49+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\QuoteGraphQl\Model\Resolver;
9+
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\GraphQl\Config\Element\Field;
12+
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
14+
use Magento\Quote\Model\Quote;
15+
use Magento\Quote\Model\Quote\Address\Total;
16+
use Magento\Quote\Model\Quote\TotalsCollector;
17+
18+
/**
19+
* @inheritdoc
20+
*/
21+
class CartPrices implements ResolverInterface
22+
{
23+
/**
24+
* @var TotalsCollector
25+
*/
26+
private $totalsCollector;
27+
28+
/**
29+
* @param TotalsCollector $totalsCollector
30+
*/
31+
public function __construct(
32+
TotalsCollector $totalsCollector
33+
) {
34+
$this->totalsCollector = $totalsCollector;
35+
}
36+
37+
/**
38+
* @inheritdoc
39+
*/
40+
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
41+
{
42+
if (!isset($value['model'])) {
43+
throw new LocalizedException(__('"model" value should be specified'));
44+
}
45+
46+
/** @var Quote $quote */
47+
$quote = $value['model'];
48+
$cartTotals = $this->totalsCollector->collectQuoteTotals($quote);
49+
$currency = $quote->getQuoteCurrencyCode();
50+
51+
return [
52+
'grand_total' => ['value' => $cartTotals->getGrandTotal(), 'currency' => $currency],
53+
'subtotal_including_tax' => ['value' => $cartTotals->getSubtotalInclTax(), 'currency' => $currency],
54+
'subtotal_excluding_tax' => ['value' => $cartTotals->getSubtotal(), 'currency' => $currency],
55+
'subtotal_with_discount_excluding_tax' => [
56+
'value' => $cartTotals->getSubtotalWithDiscount(), 'currency' => $currency
57+
],
58+
'applied_taxes' => $this->getAppliedTaxes($cartTotals, $currency),
59+
'model' => $quote
60+
];
61+
}
62+
63+
/**
64+
* Returns taxes applied to the current quote
65+
*
66+
* @param Total $total
67+
* @param string $currency
68+
* @return array
69+
*/
70+
private function getAppliedTaxes(Total $total, string $currency): array
71+
{
72+
$appliedTaxesData = [];
73+
$appliedTaxes = $total->getAppliedTaxes();
74+
75+
if (count($appliedTaxes) === 0) {
76+
return $appliedTaxesData;
77+
}
78+
79+
foreach ($appliedTaxes as $appliedTax) {
80+
$appliedTaxesData[] = [
81+
'label' => $appliedTax['id'],
82+
'amount' => ['value' => $appliedTax['amount'], 'currency' => $currency]
83+
];
84+
}
85+
return $appliedTaxesData;
86+
}
87+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
6565

6666
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId());
6767

68+
if ($context->getUserId() === 0) {
69+
if (!$cart->getCustomerEmail()) {
70+
throw new GraphQlInputException(__("Guest email for cart is missing. Please enter"));
71+
}
72+
$cart->setCheckoutMethod(CartManagementInterface::METHOD_GUEST);
73+
}
74+
6875
try {
6976
$orderId = $this->cartManagement->placeOrder($cart->getId());
7077
$order = $this->orderRepository->get($orderId);

0 commit comments

Comments
 (0)