Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - magento-engcom/magento2ce#1380: [EngCom Team] Batch 35. Forwardports to 2.3-develop (by @magento-engcom-team)
 - #13912: Update Travis CI build status image in Readme (by @didactic-umbrella)
 - #13877: Fix grammar in demo store notice (by @erikhansen)


Fixed GitHub Issues:
 - #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

 - #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

 - #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

 - #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
  • Loading branch information
Oleksii Korshenko authored Mar 2, 2018
2 parents 91a4d18 + 3d7b063 commit 0f61d2d
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=develop)](https://travis-ci.org/magento/magento2)
[![Build Status](https://travis-ci.org/magento/magento2.svg?branch=2.3-develop)](https://travis-ci.org/magento/magento2)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
<h2>Welcome</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,45 @@
*/
namespace Magento\Analytics\Block\Adminhtml\System\Config;

use Magento\Framework\App\ObjectManager;

/**
* Provides label with default Time Zone
*/
class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Add default time zone to comment
* @var \Magento\Framework\Locale\ResolverInterface
*/
private $localeResolver;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
* @param \Magento\Framework\Locale\ResolverInterface|null $localeResolver
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
array $data = [],
\Magento\Framework\Locale\ResolverInterface $localeResolver = null
) {
$this->localeResolver = $localeResolver ?:
ObjectManager::getInstance()->get(\Magento\Framework\Locale\ResolverInterface::class);
parent::__construct($context, $data);
}

/**
* Add current time zone to comment, properly translated according to locale
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$timeZoneCode = $this->_localeDate->getConfigTimezone();
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName();
$locale = $this->localeResolver->getLocale();
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)
->getDisplayName(false, \IntlTimeZone::DISPLAY_LONG, $locale);
$element->setData(
'comment',
sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;

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

/**
* @var ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $localeResolver;

protected function setUp()
{
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
Expand All @@ -53,12 +59,17 @@ protected function setUp()
$this->contextMock->expects($this->any())
->method('getLocaleDate')
->willReturn($this->timeZoneMock);
$this->localeResolver = $this->getMockBuilder(ResolverInterface::class)
->disableOriginalConstructor()
->setMethods(['getLocale'])
->getMockForAbstractClass();

$objectManager = new ObjectManager($this);
$this->collectionTimeLabel = $objectManager->getObject(
CollectionTimeLabel::class,
[
'context' => $this->contextMock
'context' => $this->contextMock,
'localeResolver' => $this->localeResolver
]
);
}
Expand All @@ -73,6 +84,9 @@ public function testRender()
$this->abstractElementMock->expects($this->any())
->method('getComment')
->willReturn('Eastern Standard Time (America/New_York)');
$this->localeResolver->expects($this->once())
->method('getLocale')
->willReturn('en_US');
$this->assertRegexp(
"/Eastern Standard Time \(America\/New_York\)/",
$this->collectionTimeLabel->render($this->abstractElementMock)
Expand Down
138 changes: 103 additions & 35 deletions app/code/Magento/Catalog/Block/Product/ListProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Block\Product\ProductList\Toolbar;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Config;
use Magento\Catalog\Model\Layer;
use Magento\Catalog\Model\Layer\Resolver;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\App\Config\Element;
use Magento\Framework\Data\Helper\PostHelper;
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Pricing\Render;
use Magento\Framework\Url\Helper\Data;

/**
* Product list
Expand All @@ -40,17 +49,17 @@ class ListProduct extends AbstractProduct implements IdentityInterface
/**
* Catalog layer
*
* @var \Magento\Catalog\Model\Layer
* @var Layer
*/
protected $_catalogLayer;

/**
* @var \Magento\Framework\Data\Helper\PostHelper
* @var PostHelper
*/
protected $_postDataHelper;

/**
* @var \Magento\Framework\Url\Helper\Data
* @var Data
*/
protected $urlHelper;

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

/**
* @param Context $context
* @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param PostHelper $postDataHelper
* @param Resolver $layerResolver
* @param CategoryRepositoryInterface $categoryRepository
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param Data $urlHelper
* @param array $data
*/
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
Context $context,
PostHelper $postDataHelper,
Resolver $layerResolver,
CategoryRepositoryInterface $categoryRepository,
\Magento\Framework\Url\Helper\Data $urlHelper,
Data $urlHelper,
array $data = []
) {
$this->_catalogLayer = $layerResolver->get();
Expand Down Expand Up @@ -113,7 +122,7 @@ protected function _getProductCollection()
/**
* Get catalog layer model
*
* @return \Magento\Catalog\Model\Layer
* @return Layer
*/
public function getLayer()
{
Expand All @@ -137,7 +146,35 @@ public function getLoadedProductCollection()
*/
public function getMode()
{
return $this->getChildBlock('toolbar')->getCurrentMode();
if ($this->getChildBlock('toolbar')) {
return $this->getChildBlock('toolbar')->getCurrentMode();
}

return $this->getDefaultListingMode();
}

/**
* Get listing mode for products if toolbar is removed from layout.
* Use the general configuration for product list mode from config path catalog/frontend/list_mode as default value
* or mode data from block declaration from layout.
*
* @return string
*/
private function getDefaultListingMode()
{
// default Toolbar when the toolbar layout is not used
$defaultToolbar = $this->getToolbarBlock();
$availableModes = $defaultToolbar->getModes();

// layout config mode
$mode = $this->getData('mode');

if (!$mode || !isset($availableModes[$mode])) {
// default config mode
$mode = $defaultToolbar->getCurrentMode();
}

return $mode;
}

/**
Expand All @@ -148,28 +185,60 @@ public function getMode()
protected function _beforeToHtml()
{
$collection = $this->_getProductCollection();
$this->configureToolbar($this->getToolbarBlock(), $collection);

$this->addToolbarBlock($collection);

$collection->load();

return parent::_beforeToHtml();
}

/**
* Retrieve Toolbar block
* Add toolbar block from product listing layout
*
* @param Collection $collection
*/
private function addToolbarBlock(Collection $collection)
{
$toolbarLayout = $this->getToolbarFromLayout();

if ($toolbarLayout) {
$this->configureToolbar($toolbarLayout, $collection);
}
}

/**
* Retrieve Toolbar block from layout or a default Toolbar
*
* @return Toolbar
*/
public function getToolbarBlock()
{
$block = $this->getToolbarFromLayout();

if (!$block) {
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
}

return $block;
}

/**
* Get toolbar block from layout
*
* @return bool|Toolbar
*/
private function getToolbarFromLayout()
{
$blockName = $this->getToolbarBlockName();

$toolbarLayout = false;

if ($blockName) {
$block = $this->getLayout()->getBlock($blockName);
if ($block) {
return $block;
}
$toolbarLayout = $this->getLayout()->getBlock($blockName);
}
$block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
return $block;

return $toolbarLayout;
}

/**
Expand Down Expand Up @@ -203,7 +272,7 @@ public function setCollection($collection)
}

/**
* @param array|string|integer|\Magento\Framework\App\Config\Element $code
* @param array|string|integer| Element $code
* @return $this
*/
public function addAttribute($code)
Expand All @@ -223,7 +292,7 @@ public function getPriceBlockTemplate()
/**
* Retrieve Catalog Config object
*
* @return \Magento\Catalog\Model\Config
* @return Config
*/
protected function _getConfig()
{
Expand All @@ -233,8 +302,8 @@ protected function _getConfig()
/**
* Prepare Sort By fields from Category Data
*
* @param \Magento\Catalog\Model\Category $category
* @return \Magento\Catalog\Block\Product\ListProduct
* @param Category $category
* @return $this
*/
public function prepareSortableFieldsByCategory($category)
{
Expand Down Expand Up @@ -286,38 +355,38 @@ public function getIdentities()
/**
* Get post parameters
*
* @param \Magento\Catalog\Model\Product $product
* @param Product $product
* @return string
*/
public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product)
public function getAddToCartPostParams(Product $product)
{
$url = $this->getAddToCartUrl($product);
return [
'action' => $url,
'data' => [
'product' => $product->getEntityId(),
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url),
]
];
}

/**
* @param \Magento\Catalog\Model\Product $product
* @param Product $product
* @return string
*/
public function getProductPrice(\Magento\Catalog\Model\Product $product)
public function getProductPrice(Product $product)
{
$priceRender = $this->getPriceRender();

$price = '';
if ($priceRender) {
$price = $priceRender->render(
\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE,
FinalPrice::PRICE_CODE,
$product,
[
'include_container' => true,
'display_minimal_price' => true,
'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
'zone' => Render::ZONE_ITEM_LIST,
'list_category_page' => true
]
);
Expand All @@ -330,7 +399,7 @@ public function getProductPrice(\Magento\Catalog\Model\Product $product)
* Specifies that price rendering should be done for the list of products
* i.e. rendering happens in the scope of product list, but not single product
*
* @return \Magento\Framework\Pricing\Render
* @return Render
*/
protected function getPriceRender()
{
Expand All @@ -356,7 +425,7 @@ protected function getPriceRender()
private function initializeProductCollection()
{
$layer = $this->getLayer();
/* @var $layer \Magento\Catalog\Model\Layer */
/* @var $layer Layer */
if ($this->getShowRootCategory()) {
$this->setCategoryId($this->_storeManager->getStore()->getRootCategoryId());
}
Expand Down Expand Up @@ -395,8 +464,7 @@ private function initializeProductCollection()
$layer->setCurrentCategory($origCategory);
}

$toolbar = $this->getToolbarBlock();
$this->configureToolbar($toolbar, $collection);
$this->addToolbarBlock($collection);

$this->_eventManager->dispatch(
'catalog_block_product_list_collection',
Expand Down
Loading

0 comments on commit 0f61d2d

Please sign in to comment.