Skip to content

Commit

Permalink
Merge branch '2.4-develop' into issue-26437-customer-shopping-cart-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
novikor authored Feb 6, 2020
2 parents 58c4cc9 + 7404d9d commit 907d0d6
Show file tree
Hide file tree
Showing 54 changed files with 1,216 additions and 1,045 deletions.
4 changes: 1 addition & 3 deletions app/code/Magento/Catalog/Block/Rss/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use Magento\Framework\Exception\NoSuchEntityException;

/**
* Class Category
*
* @package Magento\Catalog\Block\Rss
* Category feed block
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
Expand Down
28 changes: 18 additions & 10 deletions app/code/Magento/Catalog/Block/Rss/Product/NewProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
use Magento\Framework\App\Rss\DataProviderInterface;

/**
* Class NewProducts
* @package Magento\Catalog\Block\Rss\Product
* New products feed block
*/
class NewProducts extends \Magento\Framework\View\Element\AbstractBlock implements DataProviderInterface
{
Expand Down Expand Up @@ -55,6 +54,8 @@ public function __construct(
}

/**
* Init
*
* @return void
*/
protected function _construct()
Expand All @@ -64,15 +65,15 @@ protected function _construct()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function isAllowed()
{
return $this->_scopeConfig->isSetFlag('rss/catalog/new', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getRssData()
{
Expand All @@ -97,10 +98,13 @@ public function getRssData()
$item->setAllowedInRss(true);
$item->setAllowedPriceInRss(true);

$this->_eventManager->dispatch('rss_catalog_new_xml_callback', [
'row' => $item->getData(),
'product' => $item
]);
$this->_eventManager->dispatch(
'rss_catalog_new_xml_callback',
[
'row' => $item->getData(),
'product' => $item
]
);

if (!$item->getAllowedInRss()) {
continue;
Expand Down Expand Up @@ -132,6 +136,8 @@ public function getRssData()
}

/**
* Get store id
*
* @return int
*/
protected function getStoreId()
Expand Down Expand Up @@ -177,14 +183,16 @@ protected function renderPriceHtml(\Magento\Catalog\Model\Product $product)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getCacheLifetime()
{
return 600;
}

/**
* Get feeds
*
* @return array
*/
public function getFeeds()
Expand All @@ -199,7 +207,7 @@ public function getFeeds()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function isAuthRequired()
{
Expand Down
15 changes: 11 additions & 4 deletions app/code/Magento/Catalog/Block/Rss/Product/Special.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use Magento\Framework\App\Rss\DataProviderInterface;

/**
* Class Special
* @package Magento\Catalog\Block\Rss\Product
* Special products feed block
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Special extends \Magento\Framework\View\Element\AbstractBlock implements DataProviderInterface
Expand Down Expand Up @@ -98,6 +97,8 @@ public function __construct(
}

/**
* Init
*
* @return void
*/
protected function _construct()
Expand All @@ -107,6 +108,8 @@ protected function _construct()
}

/**
* Get RSS data
*
* @return array
*/
public function getRssData()
Expand Down Expand Up @@ -156,6 +159,8 @@ public function getRssData()
}

/**
* Get entry data
*
* @param \Magento\Catalog\Model\Product $item
* @return array
*/
Expand Down Expand Up @@ -245,14 +250,16 @@ public function isAllowed()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getCacheLifetime()
{
return 600;
}

/**
* Get feeds
*
* @return array
*/
public function getFeeds()
Expand All @@ -266,7 +273,7 @@ public function getFeeds()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function isAuthRequired()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Magento\Framework\Exception\LocalizedException;

/**
* Class Upload
* Upload product image action controller
*/
class Upload extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
Expand Down
43 changes: 35 additions & 8 deletions app/code/Magento/Catalog/Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
*/
namespace Magento\Catalog\Helper;

use Magento\Catalog\Model\Config\CatalogMediaConfig;
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Element\Block\ArgumentInterface;

/**
* Catalog image helper
* Catalog image helper.
*
* @api
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Image extends AbstractHelper implements ArgumentInterface
Expand Down Expand Up @@ -40,13 +45,15 @@ class Image extends AbstractHelper implements ArgumentInterface
* Scheduled for rotate image
*
* @var bool
* @deprecated unused
*/
protected $_scheduleRotate = false;

/**
* Angle
*
* @var int
* @deprecated unused
*/
protected $_angle;

Expand Down Expand Up @@ -129,31 +136,38 @@ class Image extends AbstractHelper implements ArgumentInterface
protected $attributes = [];

/**
* @var \Magento\Catalog\Model\View\Asset\PlaceholderFactory
* @var PlaceholderFactory
*/
private $viewAssetPlaceholderFactory;

/**
* @var CatalogMediaConfig
*/
private $mediaConfig;

/**
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Catalog\Model\Product\ImageFactory $productImageFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\ConfigInterface $viewConfig
* @param \Magento\Catalog\Model\View\Asset\PlaceholderFactory $placeholderFactory
* @param PlaceholderFactory $placeholderFactory
* @param CatalogMediaConfig $mediaConfig
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Catalog\Model\Product\ImageFactory $productImageFactory,
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\ConfigInterface $viewConfig,
\Magento\Catalog\Model\View\Asset\PlaceholderFactory $placeholderFactory = null
PlaceholderFactory $placeholderFactory = null,
CatalogMediaConfig $mediaConfig = null
) {
$this->_productImageFactory = $productImageFactory;
parent::__construct($context);
$this->_assetRepo = $assetRepo;
$this->viewConfig = $viewConfig;
$this->viewAssetPlaceholderFactory = $placeholderFactory
?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Catalog\Model\View\Asset\PlaceholderFactory::class);
?: ObjectManager::getInstance()->get(PlaceholderFactory::class);
$this->mediaConfig = $mediaConfig ?: ObjectManager::getInstance()->get(CatalogMediaConfig::class);
}

/**
Expand Down Expand Up @@ -382,9 +396,10 @@ public function constrainOnly($flag)
*/
public function backgroundColor($colorRGB)
{
$args = func_get_args();
// assume that 3 params were given instead of array
if (!is_array($colorRGB)) {
$colorRGB = func_get_args();
$colorRGB = $args;
}
$this->_getModel()->setBackgroundColor($colorRGB);
return $this;
Expand All @@ -395,6 +410,7 @@ public function backgroundColor($colorRGB)
*
* @param int $angle
* @return $this
* @deprecated unused
*/
public function rotate($angle)
{
Expand Down Expand Up @@ -526,7 +542,16 @@ protected function isScheduledActionsAllowed()
public function getUrl()
{
try {
$this->applyScheduledActions();
switch ($this->mediaConfig->getMediaUrlFormat()) {
case CatalogMediaConfig::IMAGE_OPTIMIZATION_PARAMETERS:
$this->initBaseFile();
break;
case CatalogMediaConfig::HASH:
$this->applyScheduledActions();
break;
default:
throw new LocalizedException(__("The specified Catalog media URL format is not supported."));
}
return $this->_getModel()->getUrl();
} catch (\Exception $e) {
return $this->getDefaultPlaceholderUrl();
Expand Down Expand Up @@ -595,6 +620,7 @@ protected function _getModel()
*
* @param int $angle
* @return $this
* @deprecated unused
*/
protected function setAngle($angle)
{
Expand All @@ -606,6 +632,7 @@ protected function setAngle($angle)
* Get Rotation Angle
*
* @return int
* @deprecated unused
*/
protected function getAngle()
{
Expand Down
50 changes: 50 additions & 0 deletions app/code/Magento/Catalog/Model/Config/CatalogMediaConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\Config;

use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Config for catalog media
*/
class CatalogMediaConfig
{
private const XML_PATH_CATALOG_MEDIA_URL_FORMAT = 'web/url/catalog_media_url_format';

const IMAGE_OPTIMIZATION_PARAMETERS = 'image_optimization_parameters';
const HASH = 'hash';

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* Constructor
*
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
}

/**
* Get media URL format for catalog images
*
* @param string $scopeType
* @param null|int|string $scopeCode
* @return string
*/
public function getMediaUrlFormat($scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
{
return $this->scopeConfig->getValue(
CatalogMediaConfig::XML_PATH_CATALOG_MEDIA_URL_FORMAT,
$scopeType,
$scopeCode
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\Config\Source\Web;

use Magento\Catalog\Model\Config\CatalogMediaConfig;

/**
* Option provider for catalog media URL format system setting.
*/
class CatalogMediaUrlFormat implements \Magento\Framework\Data\OptionSourceInterface
{
/**
* Get a list of supported catalog media URL formats.
*
* @codeCoverageIgnore
*/
public function toOptionArray()
{
return [
[
'value' => CatalogMediaConfig::IMAGE_OPTIMIZATION_PARAMETERS,
'label' => __('Image optimization based on query parameters')
],
['value' => CatalogMediaConfig::HASH, 'label' => __('Unique hash per image variant (Legacy mode)')]
];
}
}
Loading

0 comments on commit 907d0d6

Please sign in to comment.