Skip to content

Commit 0f61d2d

Browse files
author
Oleksii Korshenko
authored
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento-engcom/magento2ce#1380: [EngCom Team] Batch 35. Forwardports to 2.3-develop (by @magento-engcom-team) - magento/magento2#13912: Update Travis CI build status image in Readme (by @didactic-umbrella) - magento/magento2#13877: Fix grammar in demo store notice (by @erikhansen) Fixed GitHub Issues: - magento/magento2#9413: Cannot remove product_list_toolbar in XML (reported by @joshfortyfour) has been fixed in magento-engcom/magento2ce#1380 by @magento-engcom-team in 2.3-develop branch Related commits: 1. e9238bc 2. c46acb7 3. 3d5cc51 4. fcd3e7a 5. a37313a 6. 4e00485 7. d73cca2 8. 0d8938c 9. d544ca2 10. e075ca7 11. a6c2bc2 12. 960d58c 13. dbdb772 14. bac46ce 15. 1503f3a 16. 17662c6 17. 2a72e5c 18. ddaf5c6 19. 7bf80fd 20. efb8bf6 21. 3212630 22. ac9c10b 23. 2c6c9c0 24. 73522bf 25. 818cf61 26. 61d0d96 27. 85e0956 28. 1698afc 29. ce7faf6 30. 7005102 31. bd07bcc 32. 1693019 33. ba7da59 34. d9e8b87 35. 0bb740b 36. c51f94c 37. 9f3f3e0 - magento/magento2#10417: Wysywig editor shows broken image icons (reported by @deadlyw1re) has been fixed in magento-engcom/magento2ce#1380 by @magento-engcom-team in 2.3-develop branch Related commits: 1. e9238bc 2. c46acb7 3. 3d5cc51 4. fcd3e7a 5. a37313a 6. 4e00485 7. d73cca2 8. 0d8938c 9. d544ca2 10. e075ca7 11. a6c2bc2 12. 960d58c 13. dbdb772 14. bac46ce 15. 1503f3a 16. 17662c6 17. 2a72e5c 18. ddaf5c6 19. 7bf80fd 20. efb8bf6 21. 3212630 22. ac9c10b 23. 2c6c9c0 24. 73522bf 25. 818cf61 26. 61d0d96 27. 85e0956 28. 1698afc 29. ce7faf6 30. 7005102 31. bd07bcc 32. 1693019 33. ba7da59 34. d9e8b87 35. 0bb740b 36. c51f94c 37. 9f3f3e0 - magento/magento2#12320: Newsletter subscribe button title wrapped (reported by @Gvigner) has been fixed in magento-engcom/magento2ce#1380 by @magento-engcom-team in 2.3-develop branch Related commits: 1. e9238bc 2. c46acb7 3. 3d5cc51 4. fcd3e7a 5. a37313a 6. 4e00485 7. d73cca2 8. 0d8938c 9. d544ca2 10. e075ca7 11. a6c2bc2 12. 960d58c 13. dbdb772 14. bac46ce 15. 1503f3a 16. 17662c6 17. 2a72e5c 18. ddaf5c6 19. 7bf80fd 20. efb8bf6 21. 3212630 22. ac9c10b 23. 2c6c9c0 24. 73522bf 25. 818cf61 26. 61d0d96 27. 85e0956 28. 1698afc 29. ce7faf6 30. 7005102 31. bd07bcc 32. 1693019 33. ba7da59 34. d9e8b87 35. 0bb740b 36. c51f94c 37. 9f3f3e0 - magento/magento2#13327: Menu ui-state-active not removed from previous opened menu item (reported by @arnoudhgz) has been fixed in magento-engcom/magento2ce#1380 by @magento-engcom-team in 2.3-develop branch Related commits: 1. e9238bc 2. c46acb7 3. 3d5cc51 4. fcd3e7a 5. a37313a 6. 4e00485 7. d73cca2 8. 0d8938c 9. d544ca2 10. e075ca7 11. a6c2bc2 12. 960d58c 13. dbdb772 14. bac46ce 15. 1503f3a 16. 17662c6 17. 2a72e5c 18. ddaf5c6 19. 7bf80fd 20. efb8bf6 21. 3212630 22. ac9c10b 23. 2c6c9c0 24. 73522bf 25. 818cf61 26. 61d0d96 27. 85e0956 28. 1698afc 29. ce7faf6 30. 7005102 31. bd07bcc 32. 1693019 33. ba7da59 34. d9e8b87 35. 0bb740b 36. c51f94c 37. 9f3f3e0
2 parents 91a4d18 + 3d7b063 commit 0f61d2d

File tree

13 files changed

+249
-49
lines changed

13 files changed

+249
-49
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=develop)](https://travis-ci.org/magento/magento2)
1+
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=2.3-develop)](https://travis-ci.org/magento/magento2)
22
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
33
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
44
<h2>Welcome</h2>

Diff for: app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php

+26-2
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,45 @@
55
*/
66
namespace Magento\Analytics\Block\Adminhtml\System\Config;
77

8+
use Magento\Framework\App\ObjectManager;
9+
810
/**
911
* Provides label with default Time Zone
1012
*/
1113
class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
1214
{
1315
/**
14-
* Add default time zone to comment
16+
* @var \Magento\Framework\Locale\ResolverInterface
17+
*/
18+
private $localeResolver;
19+
20+
/**
21+
* @param \Magento\Backend\Block\Template\Context $context
22+
* @param array $data
23+
* @param \Magento\Framework\Locale\ResolverInterface|null $localeResolver
24+
*/
25+
public function __construct(
26+
\Magento\Backend\Block\Template\Context $context,
27+
array $data = [],
28+
\Magento\Framework\Locale\ResolverInterface $localeResolver = null
29+
) {
30+
$this->localeResolver = $localeResolver ?:
31+
ObjectManager::getInstance()->get(\Magento\Framework\Locale\ResolverInterface::class);
32+
parent::__construct($context, $data);
33+
}
34+
35+
/**
36+
* Add current time zone to comment, properly translated according to locale
1537
*
1638
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
1739
* @return string
1840
*/
1941
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
2042
{
2143
$timeZoneCode = $this->_localeDate->getConfigTimezone();
22-
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName();
44+
$locale = $this->localeResolver->getLocale();
45+
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)
46+
->getDisplayName(false, \IntlTimeZone::DISPLAY_LONG, $locale);
2347
$element->setData(
2448
'comment',
2549
sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)

Diff for: app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Backend\Block\Template\Context;
1010
use Magento\Framework\Data\Form;
1111
use Magento\Framework\Data\Form\Element\AbstractElement;
12+
use Magento\Framework\Locale\ResolverInterface;
1213
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415

@@ -34,6 +35,11 @@ class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
3435
*/
3536
private $abstractElementMock;
3637

38+
/**
39+
* @var ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $localeResolver;
42+
3743
protected function setUp()
3844
{
3945
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
@@ -53,12 +59,17 @@ protected function setUp()
5359
$this->contextMock->expects($this->any())
5460
->method('getLocaleDate')
5561
->willReturn($this->timeZoneMock);
62+
$this->localeResolver = $this->getMockBuilder(ResolverInterface::class)
63+
->disableOriginalConstructor()
64+
->setMethods(['getLocale'])
65+
->getMockForAbstractClass();
5666

5767
$objectManager = new ObjectManager($this);
5868
$this->collectionTimeLabel = $objectManager->getObject(
5969
CollectionTimeLabel::class,
6070
[
61-
'context' => $this->contextMock
71+
'context' => $this->contextMock,
72+
'localeResolver' => $this->localeResolver
6273
]
6374
);
6475
}
@@ -73,6 +84,9 @@ public function testRender()
7384
$this->abstractElementMock->expects($this->any())
7485
->method('getComment')
7586
->willReturn('Eastern Standard Time (America/New_York)');
87+
$this->localeResolver->expects($this->once())
88+
->method('getLocale')
89+
->willReturn('en_US');
7690
$this->assertRegexp(
7791
"/Eastern Standard Time \(America\/New_York\)/",
7892
$this->collectionTimeLabel->render($this->abstractElementMock)

Diff for: app/code/Magento/Catalog/Block/Product/ListProduct.php

+103-35
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@
99
use Magento\Catalog\Api\CategoryRepositoryInterface;
1010
use Magento\Catalog\Block\Product\ProductList\Toolbar;
1111
use Magento\Catalog\Model\Category;
12+
use Magento\Catalog\Model\Config;
13+
use Magento\Catalog\Model\Layer;
14+
use Magento\Catalog\Model\Layer\Resolver;
1215
use Magento\Catalog\Model\Product;
1316
use Magento\Catalog\Model\ResourceModel\Product\Collection;
17+
use Magento\Catalog\Pricing\Price\FinalPrice;
1418
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
19+
use Magento\Framework\App\ActionInterface;
20+
use Magento\Framework\App\Config\Element;
21+
use Magento\Framework\Data\Helper\PostHelper;
1522
use Magento\Framework\DataObject\IdentityInterface;
1623
use Magento\Framework\Exception\NoSuchEntityException;
24+
use Magento\Framework\Pricing\Render;
25+
use Magento\Framework\Url\Helper\Data;
1726

1827
/**
1928
* Product list
@@ -40,17 +49,17 @@ class ListProduct extends AbstractProduct implements IdentityInterface
4049
/**
4150
* Catalog layer
4251
*
43-
* @var \Magento\Catalog\Model\Layer
52+
* @var Layer
4453
*/
4554
protected $_catalogLayer;
4655

4756
/**
48-
* @var \Magento\Framework\Data\Helper\PostHelper
57+
* @var PostHelper
4958
*/
5059
protected $_postDataHelper;
5160

5261
/**
53-
* @var \Magento\Framework\Url\Helper\Data
62+
* @var Data
5463
*/
5564
protected $urlHelper;
5665

@@ -61,18 +70,18 @@ class ListProduct extends AbstractProduct implements IdentityInterface
6170

6271
/**
6372
* @param Context $context
64-
* @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper
65-
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
73+
* @param PostHelper $postDataHelper
74+
* @param Resolver $layerResolver
6675
* @param CategoryRepositoryInterface $categoryRepository
67-
* @param \Magento\Framework\Url\Helper\Data $urlHelper
76+
* @param Data $urlHelper
6877
* @param array $data
6978
*/
7079
public function __construct(
71-
\Magento\Catalog\Block\Product\Context $context,
72-
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
73-
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
80+
Context $context,
81+
PostHelper $postDataHelper,
82+
Resolver $layerResolver,
7483
CategoryRepositoryInterface $categoryRepository,
75-
\Magento\Framework\Url\Helper\Data $urlHelper,
84+
Data $urlHelper,
7685
array $data = []
7786
) {
7887
$this->_catalogLayer = $layerResolver->get();
@@ -113,7 +122,7 @@ protected function _getProductCollection()
113122
/**
114123
* Get catalog layer model
115124
*
116-
* @return \Magento\Catalog\Model\Layer
125+
* @return Layer
117126
*/
118127
public function getLayer()
119128
{
@@ -137,7 +146,35 @@ public function getLoadedProductCollection()
137146
*/
138147
public function getMode()
139148
{
140-
return $this->getChildBlock('toolbar')->getCurrentMode();
149+
if ($this->getChildBlock('toolbar')) {
150+
return $this->getChildBlock('toolbar')->getCurrentMode();
151+
}
152+
153+
return $this->getDefaultListingMode();
154+
}
155+
156+
/**
157+
* Get listing mode for products if toolbar is removed from layout.
158+
* Use the general configuration for product list mode from config path catalog/frontend/list_mode as default value
159+
* or mode data from block declaration from layout.
160+
*
161+
* @return string
162+
*/
163+
private function getDefaultListingMode()
164+
{
165+
// default Toolbar when the toolbar layout is not used
166+
$defaultToolbar = $this->getToolbarBlock();
167+
$availableModes = $defaultToolbar->getModes();
168+
169+
// layout config mode
170+
$mode = $this->getData('mode');
171+
172+
if (!$mode || !isset($availableModes[$mode])) {
173+
// default config mode
174+
$mode = $defaultToolbar->getCurrentMode();
175+
}
176+
177+
return $mode;
141178
}
142179

143180
/**
@@ -148,28 +185,60 @@ public function getMode()
148185
protected function _beforeToHtml()
149186
{
150187
$collection = $this->_getProductCollection();
151-
$this->configureToolbar($this->getToolbarBlock(), $collection);
188+
189+
$this->addToolbarBlock($collection);
190+
152191
$collection->load();
153192

154193
return parent::_beforeToHtml();
155194
}
156195

157196
/**
158-
* Retrieve Toolbar block
197+
* Add toolbar block from product listing layout
198+
*
199+
* @param Collection $collection
200+
*/
201+
private function addToolbarBlock(Collection $collection)
202+
{
203+
$toolbarLayout = $this->getToolbarFromLayout();
204+
205+
if ($toolbarLayout) {
206+
$this->configureToolbar($toolbarLayout, $collection);
207+
}
208+
}
209+
210+
/**
211+
* Retrieve Toolbar block from layout or a default Toolbar
159212
*
160213
* @return Toolbar
161214
*/
162215
public function getToolbarBlock()
216+
{
217+
$block = $this->getToolbarFromLayout();
218+
219+
if (!$block) {
220+
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
221+
}
222+
223+
return $block;
224+
}
225+
226+
/**
227+
* Get toolbar block from layout
228+
*
229+
* @return bool|Toolbar
230+
*/
231+
private function getToolbarFromLayout()
163232
{
164233
$blockName = $this->getToolbarBlockName();
234+
235+
$toolbarLayout = false;
236+
165237
if ($blockName) {
166-
$block = $this->getLayout()->getBlock($blockName);
167-
if ($block) {
168-
return $block;
169-
}
238+
$toolbarLayout = $this->getLayout()->getBlock($blockName);
170239
}
171-
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
172-
return $block;
240+
241+
return $toolbarLayout;
173242
}
174243

175244
/**
@@ -203,7 +272,7 @@ public function setCollection($collection)
203272
}
204273

205274
/**
206-
* @param array|string|integer|\Magento\Framework\App\Config\Element $code
275+
* @param array|string|integer| Element $code
207276
* @return $this
208277
*/
209278
public function addAttribute($code)
@@ -223,7 +292,7 @@ public function getPriceBlockTemplate()
223292
/**
224293
* Retrieve Catalog Config object
225294
*
226-
* @return \Magento\Catalog\Model\Config
295+
* @return Config
227296
*/
228297
protected function _getConfig()
229298
{
@@ -233,8 +302,8 @@ protected function _getConfig()
233302
/**
234303
* Prepare Sort By fields from Category Data
235304
*
236-
* @param \Magento\Catalog\Model\Category $category
237-
* @return \Magento\Catalog\Block\Product\ListProduct
305+
* @param Category $category
306+
* @return $this
238307
*/
239308
public function prepareSortableFieldsByCategory($category)
240309
{
@@ -286,38 +355,38 @@ public function getIdentities()
286355
/**
287356
* Get post parameters
288357
*
289-
* @param \Magento\Catalog\Model\Product $product
358+
* @param Product $product
290359
* @return string
291360
*/
292-
public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
361+
public function getAddToCartPostParams(Product $product)
293362
{
294363
$url = $this->getAddToCartUrl($product);
295364
return [
296365
'action' => $url,
297366
'data' => [
298367
'product' => $product->getEntityId(),
299-
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
368+
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
300369
]
301370
];
302371
}
303372

304373
/**
305-
* @param \Magento\Catalog\Model\Product $product
374+
* @param Product $product
306375
* @return string
307376
*/
308-
public function getProductPrice(\Magento\Catalog\Model\Product $product)
377+
public function getProductPrice(Product $product)
309378
{
310379
$priceRender = $this->getPriceRender();
311380

312381
$price = '';
313382
if ($priceRender) {
314383
$price = $priceRender->render(
315-
\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
384+
FinalPrice::PRICE_CODE,
316385
$product,
317386
[
318387
'include_container' => true,
319388
'display_minimal_price' => true,
320-
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
389+
'zone' => Render::ZONE_ITEM_LIST,
321390
'list_category_page' => true
322391
]
323392
);
@@ -330,7 +399,7 @@ public function getProductPrice(\Magento\Catalog\Model\Product $product)
330399
* Specifies that price rendering should be done for the list of products
331400
* i.e. rendering happens in the scope of product list, but not single product
332401
*
333-
* @return \Magento\Framework\Pricing\Render
402+
* @return Render
334403
*/
335404
protected function getPriceRender()
336405
{
@@ -356,7 +425,7 @@ protected function getPriceRender()
356425
private function initializeProductCollection()
357426
{
358427
$layer = $this->getLayer();
359-
/* @var $layer \Magento\Catalog\Model\Layer */
428+
/* @var $layer Layer */
360429
if ($this->getShowRootCategory()) {
361430
$this->setCategoryId($this->_storeManager->getStore()->getRootCategoryId());
362431
}
@@ -395,8 +464,7 @@ private function initializeProductCollection()
395464
$layer->setCurrentCategory($origCategory);
396465
}
397466

398-
$toolbar = $this->getToolbarBlock();
399-
$this->configureToolbar($toolbar, $collection);
467+
$this->addToolbarBlock($collection);
400468

401469
$this->_eventManager->dispatch(
402470
'catalog_block_product_list_collection',

0 commit comments

Comments
 (0)