Skip to content

Commit

Permalink
merge magento/2.4.0-develop into magento-borg/2.4.0-bugfixes-030929
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-mts-svc authored Apr 27, 2020
2 parents 47e7dad + dbc71bc commit 09bc685
Show file tree
Hide file tree
Showing 87 changed files with 956 additions and 930 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ public function getViewHeader(string $viewName): string
public function getDropViewSql(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
return sprintf('DROP VIEW IF EXISTS %s;\n', $quotedViewName);
return sprintf("DROP VIEW IF EXISTS %s;\n", $quotedViewName);
}
}

This file was deleted.

This file was deleted.

109 changes: 46 additions & 63 deletions app/code/Magento/Catalog/Helper/Product/ProductList.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,37 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Helper\Product;

use Magento\Catalog\Model\Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Registry;
use Magento\Store\Model\ScopeInterface;

/**
* Class ProductList
* Returns data for toolbars of Sorting and Pagination
*
* @api
* @since 100.0.2
*/
class ProductList
{
/**
* List mode configuration path
*/
const XML_PATH_LIST_MODE = 'catalog/frontend/list_mode';
public const XML_PATH_LIST_MODE = 'catalog/frontend/list_mode';
public const DEFAULT_SORT_DIRECTION = 'asc';

const VIEW_MODE_LIST = 'list';
const VIEW_MODE_GRID = 'grid';

const DEFAULT_SORT_DIRECTION = 'asc';
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
* @var ScopeConfigInterface
*/
protected $scopeConfig;

/**
* @var \Magento\Framework\Registry
* @var Registry
*/
private $coreRegistry;

Expand All @@ -38,20 +42,18 @@ class ProductList
*
* @var array
*/
protected $_defaultAvailableLimit = [10 => 10,20 => 20,50 => 50];
protected $_defaultAvailableLimit = [10 => 10, 20 => 20, 50 => 50];

/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Registry $coreRegistry
* @param ScopeConfigInterface $scopeConfig
* @param Registry $coreRegistry
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Registry $coreRegistry = null
ScopeConfigInterface $scopeConfig,
Registry $coreRegistry = null
) {
$this->scopeConfig = $scopeConfig;
$this->coreRegistry = $coreRegistry ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\Registry::class
);
$this->coreRegistry = $coreRegistry ?? ObjectManager::getInstance()->get(Registry::class);
}

/**
Expand All @@ -61,31 +63,23 @@ public function __construct(
*/
public function getAvailableViewMode()
{
$value = $this->scopeConfig->getValue(
self::XML_PATH_LIST_MODE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
$value = $this->scopeConfig->getValue(self::XML_PATH_LIST_MODE, ScopeInterface::SCOPE_STORE);

switch ($value) {
case 'grid':
$availableMode = ['grid' => __('Grid')];
break;
return ['grid' => __('Grid')];

case 'list':
$availableMode = ['list' => __('List')];
break;
return ['list' => __('List')];

case 'grid-list':
$availableMode = ['grid' => __('Grid'), 'list' => __('List')];
break;
return ['grid' => __('Grid'), 'list' => __('List')];

case 'list-grid':
$availableMode = ['list' => __('List'), 'grid' => __('Grid')];
break;
default:
$availableMode = null;
break;
return ['list' => __('List'), 'grid' => __('Grid')];
}
return $availableMode;

return null;
}

/**
Expand All @@ -99,12 +93,14 @@ public function getDefaultViewMode($options = [])
if (empty($options)) {
$options = $this->getAvailableViewMode();
}

return current(array_keys($options));
}

/**
* Get default sort field
*
* @FIXME Helper should be context-independent
* @return null|string
*/
public function getDefaultSortField()
Expand All @@ -114,59 +110,46 @@ public function getDefaultSortField()
return $currentCategory->getDefaultSortBy();
}

return $this->scopeConfig->getValue(
\Magento\Catalog\Model\Config::XML_PATH_LIST_DEFAULT_SORT_BY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
return $this->scopeConfig->getValue(Config::XML_PATH_LIST_DEFAULT_SORT_BY, ScopeInterface::SCOPE_STORE);
}

/**
* Retrieve available limits for specified view mode
*
* @param string $mode
* @param string $viewMode
* @return array
*/
public function getAvailableLimit($mode)
public function getAvailableLimit($viewMode): array
{
if (!in_array($mode, [self::VIEW_MODE_GRID, self::VIEW_MODE_LIST])) {
$availableViewModes = $this->getAvailableViewMode();

if (!isset($availableViewModes[$viewMode])) {
return $this->_defaultAvailableLimit;
}
$perPageConfigKey = 'catalog/frontend/' . $mode . '_per_page_values';
$perPageValues = (string)$this->scopeConfig->getValue(
$perPageConfigKey,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);

$perPageConfigPath = 'catalog/frontend/' . $viewMode . '_per_page_values';
$perPageValues = (string)$this->scopeConfig->getValue($perPageConfigPath, ScopeInterface::SCOPE_STORE);
$perPageValues = explode(',', $perPageValues);
$perPageValues = array_combine($perPageValues, $perPageValues);
if ($this->scopeConfig->isSetFlag(
'catalog/frontend/list_allow_all',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)) {
if ($this->scopeConfig->isSetFlag('catalog/frontend/list_allow_all', ScopeInterface::SCOPE_STORE)) {
return ($perPageValues + ['all' => __('All')]);
} else {
return $perPageValues;
}
}

/**
* Retrieve default per page values
* Returns default value of `per_page` for view mode provided
*
* @param string $viewMode
* @return string (comma separated)
* @return int
*/
public function getDefaultLimitPerPageValue($viewMode)
public function getDefaultLimitPerPageValue($viewMode): int
{
if ($viewMode == self::VIEW_MODE_LIST) {
return $this->scopeConfig->getValue(
'catalog/frontend/list_per_page',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
} elseif ($viewMode == self::VIEW_MODE_GRID) {
return $this->scopeConfig->getValue(
'catalog/frontend/grid_per_page',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
return 0;
$xmlConfigPath = sprintf('catalog/frontend/%s_per_page', $viewMode);
$defaultLimit = $this->scopeConfig->getValue($xmlConfigPath, ScopeInterface::SCOPE_STORE);

$availableLimits = $this->getAvailableLimit($viewMode);
return (int)($availableLimits[$defaultLimit] ?? current($availableLimits));
}
}
5 changes: 2 additions & 3 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
const STORE_ID = 'store_id';

/**
* @var string
* @var string|bool
*/
protected $_cacheTag = self::CACHE_TAG;
protected $_cacheTag = false;

/**
* @var string
Expand Down Expand Up @@ -878,7 +878,6 @@ public function getAttributes($groupId = null, $skipSuper = false)
*/
public function beforeSave()
{
$this->cleanCache();
$this->setTypeHasOptions(false);
$this->setTypeHasRequiredOptions(false);
$this->setHasOptions(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminProductGridSection">
<element name="productRowBySku" type="block" selector="//td[count(../../..//th[./*[.='SKU']]/preceding-sibling::th) + 1][./*[.='{{sku}}']]" parameterized="true" />
<element name="productRowByName" type="block" selector="//td[count(../../..//th[./*[.='Name']]/preceding-sibling::th) + 1][./*[.='{{sku}}']]" parameterized="true" />
<element name="productRowCheckboxBySku" type="block" selector="//td[count(../../..//th[./*[.='SKU']]/preceding-sibling::th) + 1][./*[.='{{sku}}']]/../td//input[@data-action='select-row']" parameterized="true" />
<element name="loadingMask" type="text" selector=".admin__data-grid-loading-mask[data-component*='product_listing']"/>
<element name="columnHeader" type="button" selector="//div[@data-role='grid-wrapper']//table[contains(@class, 'data-grid')]/thead/tr/th[contains(@class, 'data-grid-th')]/span[text() = '{{label}}']" parameterized="true" timeout="30"/>
Expand All @@ -35,5 +36,6 @@
<element name="productGridContentsOnRow" type="checkbox" selector="//*[@id='container']//tr[{{row}}]/td" parameterized="true"/>
<element name="selectRowBasedOnName" type="input" selector="//td/div[text()='{{var1}}']" parameterized="true"/>
<element name="changeStatus" type="button" selector="//div[contains(@class,'admin__data-grid-header-row') and contains(@class, 'row')]//div[contains(@class, 'action-menu-item')]//ul/li/span[text() = '{{status}}']" parameterized="true"/>
<element name="productRowByTypeAndName" type="block" selector="//div[@data-role='grid-wrapper']//table[contains(@class, 'data-grid')]//td[count(../../..//th[./*[.='Type']]/preceding-sibling::th) + 1][./*[.='{{type}}']]/../td[contains(.,'{{name}}')]" parameterized="true" />
</section>
</sections>
Loading

0 comments on commit 09bc685

Please sign in to comment.