Skip to content

Commit d696d32

Browse files
committed
Merge branch '2.3-develop' of github.com:magento/magento2ce into 2.3.5-develop
2 parents 6d655f2 + f0f3081 commit d696d32

File tree

76 files changed

+1729
-370
lines changed

Some content is hidden

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

76 files changed

+1729
-370
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ define([
269269
*/
270270
onError: function () {
271271
self.showError($t('Payment ' + self.getTitle() + ' can\'t be initialized'));
272+
self.reInitPayPal();
272273
}
273274
}, self.paypalButtonSelector);
274275
},

app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
namespace Magento\Catalog\Block\Ui;
77

88
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\ProductRenderFactory;
10+
use Magento\Catalog\Model\ProductRepository;
911
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\EntityManager\Hydrator;
1015
use Magento\Framework\Registry;
1116
use Magento\Framework\Serialize\SerializerInterface;
1217
use Magento\Framework\Url;
1318
use Magento\Framework\View\Element\Template;
1419
use Magento\Store\Model\Store;
15-
use Magento\Catalog\Model\ProductRenderFactory;
16-
use Magento\Catalog\Model\ProductRepository;
17-
use Magento\Framework\EntityManager\Hydrator;
1820
use Magento\Store\Model\StoreManager;
1921

2022
/**
@@ -25,6 +27,7 @@
2527
*
2628
* @api
2729
* @since 101.1.0
30+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2831
*/
2932
class ProductViewCounter extends Template
3033
{
@@ -68,6 +71,13 @@ class ProductViewCounter extends Template
6871
*/
6972
private $registry;
7073

74+
/**
75+
* Core store config
76+
*
77+
* @var ScopeConfigInterface
78+
*/
79+
private $scopeConfig;
80+
7181
/**
7282
* @param Template\Context $context
7383
* @param ProductRepository $productRepository
@@ -78,6 +88,8 @@ class ProductViewCounter extends Template
7888
* @param SerializerInterface $serialize
7989
* @param Url $url
8090
* @param Registry $registry
91+
* @param ScopeConfigInterface|null $scopeConfig
92+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8193
*/
8294
public function __construct(
8395
Template\Context $context,
@@ -88,7 +100,8 @@ public function __construct(
88100
Hydrator $hydrator,
89101
SerializerInterface $serialize,
90102
Url $url,
91-
Registry $registry
103+
Registry $registry,
104+
?ScopeConfigInterface $scopeConfig = null
92105
) {
93106
parent::__construct($context);
94107
$this->productRepository = $productRepository;
@@ -99,6 +112,7 @@ public function __construct(
99112
$this->serialize = $serialize;
100113
$this->url = $url;
101114
$this->registry = $registry;
115+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
102116
}
103117

104118
/**
@@ -116,14 +130,19 @@ public function getCurrentProductData()
116130
{
117131
/** @var ProductInterface $product */
118132
$product = $this->registry->registry('product');
133+
$productsScope = $this->scopeConfig->getValue(
134+
'catalog/recently_products/scope',
135+
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE
136+
);
119137
/** @var Store $store */
120138
$store = $this->storeManager->getStore();
121139

122140
if (!$product || !$product->getId()) {
123141
return $this->serialize->serialize([
124142
'items' => [],
125143
'store' => $store->getId(),
126-
'currency' => $store->getCurrentCurrency()->getCode()
144+
'currency' => $store->getCurrentCurrency()->getCode(),
145+
'productCurrentScope' => $productsScope
127146
]);
128147
}
129148

@@ -140,7 +159,8 @@ public function getCurrentProductData()
140159
$product->getId() => $data
141160
],
142161
'store' => $store->getId(),
143-
'currency' => $store->getCurrentCurrency()->getCode()
162+
'currency' => $store->getCurrentCurrency()->getCode(),
163+
'productCurrentScope' => $productsScope
144164
];
145165

146166
return $this->serialize->serialize($currentProductData);

app/code/Magento/Catalog/Controller/Product/Compare/Index.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\View\Result\PageFactory;
1313

1414
/**
15+
* View products compare in frontend
16+
*
1517
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1618
*/
1719
class Index extends \Magento\Catalog\Controller\Product\Compare implements HttpGetActionInterface
@@ -74,23 +76,12 @@ public function __construct(
7476
*/
7577
public function execute()
7678
{
77-
$items = $this->getRequest()->getParam('items');
78-
7979
$beforeUrl = $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED);
8080
if ($beforeUrl) {
8181
$this->_catalogSession->setBeforeCompareUrl(
8282
$this->urlDecoder->decode($beforeUrl)
8383
);
8484
}
85-
86-
if ($items) {
87-
$items = explode(',', $items);
88-
/** @var \Magento\Catalog\Model\Product\Compare\ListCompare $list */
89-
$list = $this->_catalogProductCompareList;
90-
$list->addProducts($items);
91-
$resultRedirect = $this->resultRedirectFactory->create();
92-
return $resultRedirect->setPath('*/*/*');
93-
}
9485
return $this->resultPageFactory->create();
9586
}
9687
}

app/code/Magento/Catalog/CustomerData/CompareProducts.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
namespace Magento\Catalog\CustomerData;
77

88
use Magento\Customer\CustomerData\SectionSourceInterface;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Exception\LocalizedException;
912

13+
/**
14+
* Catalog Product Compare Widget
15+
*/
1016
class CompareProducts implements SectionSourceInterface
1117
{
1218
/**
@@ -24,23 +30,33 @@ class CompareProducts implements SectionSourceInterface
2430
*/
2531
private $outputHelper;
2632

33+
/**
34+
* Core store config
35+
*
36+
* @var ScopeConfigInterface
37+
*/
38+
private $scopeConfig;
39+
2740
/**
2841
* @param \Magento\Catalog\Helper\Product\Compare $helper
2942
* @param \Magento\Catalog\Model\Product\Url $productUrl
3043
* @param \Magento\Catalog\Helper\Output $outputHelper
44+
* @param ScopeConfigInterface|null $scopeConfig
3145
*/
3246
public function __construct(
3347
\Magento\Catalog\Helper\Product\Compare $helper,
3448
\Magento\Catalog\Model\Product\Url $productUrl,
35-
\Magento\Catalog\Helper\Output $outputHelper
49+
\Magento\Catalog\Helper\Output $outputHelper,
50+
?ScopeConfigInterface $scopeConfig = null
3651
) {
3752
$this->helper = $helper;
3853
$this->productUrl = $productUrl;
3954
$this->outputHelper = $outputHelper;
55+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
4056
}
4157

4258
/**
43-
* {@inheritdoc}
59+
* @inheritdoc
4460
*/
4561
public function getSectionData()
4662
{
@@ -54,18 +70,26 @@ public function getSectionData()
5470
}
5571

5672
/**
73+
* Get the list of compared product items
74+
*
5775
* @return array
76+
* @throws LocalizedException
5877
*/
5978
protected function getItems()
6079
{
6180
$items = [];
81+
$productsScope = $this->scopeConfig->getValue(
82+
'catalog/recently_products/scope',
83+
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE
84+
);
6285
/** @var \Magento\Catalog\Model\Product $item */
6386
foreach ($this->helper->getItemCollection() as $item) {
6487
$items[] = [
6588
'id' => $item->getId(),
6689
'product_url' => $this->productUrl->getUrl($item),
6790
'name' => $this->outputHelper->productAttribute($item, $item->getName(), 'name'),
6891
'remove_url' => $this->helper->getPostDataRemove($item),
92+
'productScope' => $productsScope
6993
];
7094
}
7195
return $items;

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @api
1515
* @SuppressWarnings(PHPMD.LongVariable)
1616
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1718
* @since 100.0.2
1819
*/
1920
class Compare extends \Magento\Framework\Url\Helper\Data
@@ -145,16 +146,9 @@ public function __construct(
145146
*/
146147
public function getListUrl()
147148
{
148-
$itemIds = [];
149-
foreach ($this->getItemCollection() as $item) {
150-
$itemIds[] = $item->getId();
151-
}
152-
153149
$params = [
154-
'items' => implode(',', $itemIds),
155150
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl()
156151
];
157-
158152
return $this->_getUrl('catalog/product_compare', $params);
159153
}
160154

app/code/Magento/Catalog/Test/Mftf/Data/ConstData.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
<entity name="prodNameWithSpecChars">
1717
<data key="trademark">"Pursuit Lumaflex™ Tone Band"</data>
1818
<data key="skumark">"x™"</data>
19+
<data key="trademark_without_quotes">Pursuit Lumaflex™ Tone Band</data>
20+
<data key="skumark_without_quotes">x™</data>
1921
</entity>
2022
</entities>

app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryProductsSection.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
<element name="sectionHeader" type="button" selector="div[data-index='assign_products']" timeout="30"/>
1313
<element name="addProducts" type="button" selector="#catalog_category_add_product_tabs" timeout="30"/>
1414
<element name="addProductsDisabled" type="button" selector="#catalog_category_add_product_tabs[disabled]" timeout="30"/>
15+
<element name="productsInCategorySectionTitle" type="text" selector="div[data-index='assign_products'] .fieldset-wrapper-title" timeout="10"/>
16+
<element name="productsInCategorySectionBody" type="text" selector="div[data-index='assign_products'] .admin__fieldset-wrapper-content"/>
1517
</section>
16-
</sections>
18+
</sections>

app/code/Magento/Catalog/Test/Unit/Block/Ui/ProductViewCounterTest.php

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

77
namespace Magento\Catalog\Test\Unit\Block\Ui;
88

9+
use Magento\Catalog\Api\Data\ProductInterface;
10+
use Magento\Catalog\Api\Data\ProductRenderInterface;
11+
use Magento\Catalog\Block\Ui\ProductViewCounter;
12+
use Magento\Catalog\Model\ProductRenderFactory;
913
use Magento\Catalog\Model\ProductRepository;
1014
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite;
11-
use Magento\Catalog\Model\ProductRenderFactory;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
1216
use Magento\Framework\EntityManager\Hydrator;
17+
use Magento\Framework\Registry;
1318
use Magento\Framework\Serialize\SerializerInterface;
1419
use Magento\Framework\Url;
1520
use Magento\Framework\View\Element\Template\Context;
16-
use Magento\Store\Model\StoreManager;
1721
use Magento\Store\Model\Store;
18-
use Magento\Framework\Registry;
19-
use Magento\Catalog\Api\Data\ProductInterface;
20-
use Magento\Catalog\Api\Data\ProductRenderInterface;
21-
use Magento\Catalog\Block\Ui\ProductViewCounter;
22+
use Magento\Store\Model\StoreManager;
2223

2324
/**
2425
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -70,6 +71,11 @@ class ProductViewCounterTest extends \PHPUnit\Framework\TestCase
7071
*/
7172
private $storeManagerMock;
7273

74+
/**
75+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
76+
*/
77+
private $scopeConfigMock;
78+
7379
/**
7480
* @var ProductRenderFactory|\PHPUnit_Framework_MockObject_MockObject
7581
*/
@@ -104,6 +110,9 @@ protected function setUp()
104110
$this->storeManagerMock = $this->getMockBuilder(StoreManager::class)
105111
->disableOriginalConstructor()
106112
->getMock();
113+
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
114+
->disableOriginalConstructor()
115+
->getMock();
107116

108117
$this->productViewCounter = new ProductViewCounter(
109118
$this->contextMock,
@@ -114,7 +123,8 @@ protected function setUp()
114123
$this->hydratorMock,
115124
$this->serializeMock,
116125
$this->urlMock,
117-
$this->registryMock
126+
$this->registryMock,
127+
$this->scopeConfigMock
118128
);
119129
}
120130

app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public function testExecute()
129129
->method('getParam')
130130
->willReturnMap(
131131
[
132-
['items', null, null],
133132
['uenc', null, $beforeUrl],
134133
]
135134
);
@@ -141,34 +140,7 @@ public function testExecute()
141140
->method('setBeforeCompareUrl')
142141
->with($beforeUrl . '1')
143142
->willReturnSelf();
144-
$this->listCompareMock->expects($this->never())->method('addProducts');
145143
$this->redirectFactoryMock->expects($this->never())->method('create');
146144
$this->index->execute();
147145
}
148-
149-
public function testExecuteWithItems()
150-
{
151-
$this->request->expects($this->any())
152-
->method('getParam')
153-
->willReturnMap(
154-
[
155-
['items', null, '1,2,3'],
156-
['uenc', null, null],
157-
]
158-
);
159-
$this->decoderMock->expects($this->never())->method('decode');
160-
$this->catalogSession->expects($this->never())->method('setBeforeCompareUrl');
161-
162-
$this->listCompareMock->expects($this->once())
163-
->method('addProducts')
164-
->with([1, 2, 3]);
165-
$redirect = $this->createPartialMock(\Magento\Framework\Controller\Result\Redirect::class, ['setPath']);
166-
$redirect->expects($this->once())
167-
->method('setPath')
168-
->with('*/*/*');
169-
$this->redirectFactoryMock->expects($this->once())
170-
->method('create')
171-
->willReturn($redirect);
172-
$this->index->execute();
173-
}
174146
}

0 commit comments

Comments
 (0)