Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit eb27ac2

Browse files
authored
Merge pull request #3363 from magento-tsg-csl3/2.3-develop-pr10
[TSG-CSL3] 2.3-develop (pr10)
2 parents 5916c5a + 39317f7 commit eb27ac2

File tree

12 files changed

+433
-51
lines changed

12 files changed

+433
-51
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="StorefrontMiniCartSection">
12+
<element name="quantity" type="button" selector="span.counter-number"/>
13+
<element name="show" type="button" selector="a.showcart"/>
14+
<element name="goToCheckout" type="button" selector="#top-cart-btn-checkout" timeout="30"/>
15+
</section>
16+
</sections>

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,16 @@ protected function _saveProducts()
16401640
}
16411641
$rowScope = $this->getRowScope($rowData);
16421642

1643-
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
1643+
$urlKey = $this->getUrlKey($rowData);
1644+
if (!empty($rowData[self::URL_KEY])) {
1645+
// If url_key column and its value were in the CSV file
1646+
$rowData[self::URL_KEY] = $urlKey;
1647+
} else if ($this->isNeedToChangeUrlKey($rowData)) {
1648+
// If url_key column was empty or even not declared in the CSV file but by the rules it is need to
1649+
// be setteed. In case when url_key is generating from name column we have to ensure that the bunch
1650+
// of products will pass for the event with url_key column.
1651+
$bunch[$rowNum][self::URL_KEY] = $rowData[self::URL_KEY] = $urlKey;
1652+
}
16441653

16451654
$rowSku = $rowData[self::COL_SKU];
16461655

@@ -2889,6 +2898,26 @@ protected function getResource()
28892898
return $this->_resource;
28902899
}
28912900

2901+
/**
2902+
* Whether a url key is needed to be change.
2903+
*
2904+
* @param array $rowData
2905+
* @return bool
2906+
*/
2907+
private function isNeedToChangeUrlKey(array $rowData): bool
2908+
{
2909+
$urlKey = $this->getUrlKey($rowData);
2910+
$productExists = $this->isSkuExist($rowData[self::COL_SKU]);
2911+
$markedToEraseUrlKey = isset($rowData[self::URL_KEY]);
2912+
// The product isn't new and the url key index wasn't marked for change.
2913+
if (!$urlKey && $productExists && !$markedToEraseUrlKey) {
2914+
// Seems there is no need to change the url key
2915+
return false;
2916+
}
2917+
2918+
return true;
2919+
}
2920+
28922921
/**
28932922
* Get product entity link field
28942923
*

app/code/Magento/Checkout/Controller/Cart/Delete.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Checkout\Controller\Cart;
87

98
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
109

10+
/**
11+
* Action Delete.
12+
*
13+
* Deletes item from cart.
14+
*/
1115
class Delete extends \Magento\Checkout\Controller\Cart implements HttpPostActionInterface
1216
{
1317
/**
@@ -24,7 +28,12 @@ public function execute()
2428
$id = (int)$this->getRequest()->getParam('id');
2529
if ($id) {
2630
try {
27-
$this->cart->removeItem($id)->save();
31+
$this->cart->removeItem($id);
32+
// We should set Totals to be recollected once more because of Cart model as usually is loading
33+
// before action executing and in case when triggerRecollect setted as true recollecting will
34+
// executed and the flag will be true already.
35+
$this->cart->getQuote()->setTotalsCollectedFlag(false);
36+
$this->cart->save();
2837
} catch (\Exception $e) {
2938
$this->messageManager->addErrorMessage(__('We can\'t remove the item.'));
3039
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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\Quote\Model\Product\Plugin;
9+
10+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
11+
use Magento\Catalog\Model\Product\Action as ProductAction;
12+
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
13+
14+
/**
15+
* Remove quote items after mass disabling products
16+
*/
17+
class MarkQuotesRecollectMassDisabled
18+
{
19+
/** @var QuoteResource$quoteResource */
20+
private $quoteResource;
21+
22+
/**
23+
* @param QuoteResource $quoteResource
24+
*/
25+
public function __construct(
26+
QuoteResource $quoteResource
27+
) {
28+
$this->quoteResource = $quoteResource;
29+
}
30+
31+
/**
32+
* Clean quote items after mass disabling product
33+
*
34+
* @param \Magento\Catalog\Model\Product\Action $subject
35+
* @param \Magento\Catalog\Model\Product\Action $result
36+
* @param int[] $productIds
37+
* @param int[] $attrData
38+
* @param int $storeId
39+
* @return \Magento\Catalog\Model\Product\Action
40+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
41+
*/
42+
public function afterUpdateAttributes(
43+
ProductAction $subject,
44+
ProductAction $result,
45+
$productIds,
46+
$attrData,
47+
$storeId
48+
): ProductAction {
49+
if (isset($attrData['status']) && $attrData['status'] === Status::STATUS_DISABLED) {
50+
$this->quoteResource->markQuotesRecollect($productIds);
51+
}
52+
53+
return $result;
54+
}
55+
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public function __construct(
103103
}
104104

105105
/**
106+
* Collect quote totals.
107+
*
106108
* @param \Magento\Quote\Model\Quote $quote
107109
* @return Address\Total
108110
*/
@@ -115,6 +117,8 @@ public function collectQuoteTotals(\Magento\Quote\Model\Quote $quote)
115117
}
116118

117119
/**
120+
* Collect quote.
121+
*
118122
* @param \Magento\Quote\Model\Quote $quote
119123
* @return \Magento\Quote\Model\Quote\Address\Total
120124
*/
@@ -172,6 +176,8 @@ public function collect(\Magento\Quote\Model\Quote $quote)
172176
}
173177

174178
/**
179+
* Validate coupon code.
180+
*
175181
* @param \Magento\Quote\Model\Quote $quote
176182
* @return $this
177183
*/
@@ -203,11 +209,12 @@ protected function _validateCouponCode(\Magento\Quote\Model\Quote $quote)
203209
*/
204210
protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote)
205211
{
212+
$quoteItems = $quote->getAllVisibleItems();
206213
$quote->setItemsCount(0);
207214
$quote->setItemsQty(0);
208215
$quote->setVirtualItemsQty(0);
209216

210-
foreach ($quote->getAllVisibleItems() as $item) {
217+
foreach ($quoteItems as $item) {
211218
if ($item->getParentItem()) {
212219
continue;
213220
}
@@ -231,6 +238,8 @@ protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote)
231238
}
232239

233240
/**
241+
* Collect address total.
242+
*
234243
* @param \Magento\Quote\Model\Quote $quote
235244
* @param Address $address
236245
* @return Address\Total

0 commit comments

Comments
 (0)