Skip to content

Commit

Permalink
Merge pull request #7120 from magento-gl/GL_PR_2021-10-05
Browse files Browse the repository at this point in the history
Gl pr 2021 10 05
  • Loading branch information
sidolov committed Oct 13, 2021
2 parents 9c8d636 + 367a474 commit e88d5bd
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<severity value="CRITICAL"/>
<testCaseId value="MAGETWO-94176"/>
<group value="backup"/>
<skip>
<issueId value="DEPRECATED">Magento backup functionality is deprecated</issueId>
</skip>
</annotations>
<before>
<magentoCLI command="config:set {{EnableBackupFunctionality.path}} {{EnableBackupFunctionality.value}}" stepKey="setEnableBackup"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
class Renderer extends \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer
{
/**
* Serializer
*
* @var Json
*/
private $serializer;
Expand Down Expand Up @@ -211,7 +209,7 @@ public function getValueHtml($item)
if (!$this->isChildCalculated($item)) {
$attributes = $this->getSelectionAttributes($item);
if ($attributes) {
$result .= " " . $this->getItem()->getOrder()->formatPrice($attributes['price']);
$result .= " " . $this->getItem()->getOrder()->formatBasePrice($attributes['price']);
}
}
return $result;
Expand Down
19 changes: 16 additions & 3 deletions app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
class Renderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer
{
/**
* Serializer
*
* @var Json
*/
private $serializer;
Expand All @@ -43,7 +41,10 @@ public function __construct(
}

/**
* Check if shipment type (invoice etc) is separate
*
* @param mixed $item
*
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
Expand Down Expand Up @@ -79,7 +80,10 @@ public function isShipmentSeparately($item = null)
}

/**
* Check if sub product calculations are present
*
* @param mixed $item
*
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
Expand Down Expand Up @@ -117,7 +121,10 @@ public function isChildCalculated($item = null)
}

/**
* Get bundle selection attributes
*
* @param mixed $item
*
* @return mixed|null
*/
public function getSelectionAttributes($item)
Expand All @@ -134,14 +141,17 @@ public function getSelectionAttributes($item)
}

/**
* Get html of bundle selection attributes
*
* @param mixed $item
*
* @return string
*/
public function getValueHtml($item)
{
if ($attributes = $this->getSelectionAttributes($item)) {
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
. $this->getOrder()->formatPrice($attributes['price']);
. $this->getOrder()->formatBasePrice($attributes['price']);
}
return $this->escapeHtml($item->getName());
}
Expand Down Expand Up @@ -183,7 +193,10 @@ public function getChildren($item)
}

/**
* Check if price info can be shown
*
* @param mixed $item
*
* @return bool
*/
public function canShowPriceInfo($item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ public function execute(int $listId, ContextInterface $context): Collection
$this->items->useProductItem()->setStoreId($context->getExtensionAttributes()->getStore()->getStoreId());
$this->items->addAttributeToSelect(
$this->catalogConfig->getProductAttributes()
)->loadComparableAttributes()->addMinimalPrice()->addTaxPercents()->setVisibility(
$this->catalogProductVisibility->getVisibleInSiteIds()
);
)->loadComparableAttributes()->addMinimalPrice()->addTaxPercents();

return $this->items;
}
Expand Down
41 changes: 29 additions & 12 deletions app/code/Magento/Directory/Model/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface;
use Magento\Framework\NumberFormatterFactory;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Exception\LocalizedException;

/**
* Currency model
Expand All @@ -39,8 +40,6 @@ class Currency extends \Magento\Framework\Model\AbstractModel
protected $_filter;

/**
* Currency Rates
*
* @var array
*/
protected $_rates;
Expand Down Expand Up @@ -147,11 +146,14 @@ public function __construct(
$this->_localeCurrency = $localeCurrency;
$this->currencyConfig = $currencyConfig ?: ObjectManager::getInstance()->get(CurrencyConfig::class);
$this->localeResolver = $localeResolver ?: ObjectManager::getInstance()->get(LocalResolverInterface::class);
$this->numberFormatterFactory = $numberFormatterFactory ?: ObjectManager::getInstance()->get(NumberFormatterFactory::class);
$this->numberFormatterFactory = $numberFormatterFactory ?:
ObjectManager::getInstance()->get(NumberFormatterFactory::class);
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
}

/**
* Initializing Currency Resource model
*
* @return void
*/
protected function _construct()
Expand Down Expand Up @@ -253,10 +255,10 @@ public function getAnyRate($toCurrency)
/**
* Convert price to currency format
*
* @param float $price
* @param mixed $toCurrency
* @return float
* @throws \Exception
* @param float $price
* @param mixed $toCurrency
* @return float
* @throws LocalizedException
*/
public function convert($price, $toCurrency = null)
{
Expand All @@ -266,15 +268,18 @@ public function convert($price, $toCurrency = null)
return (float)$price * (float)$rate;
}

throw new \Exception(__(
throw new LocalizedException(__(
'Undefined rate from "%1-%2".',
$this->getCode(),
$this->getCurrencyCodeFromToCurrency($toCurrency)
));
}

/**
* Return the currency code
*
* @param mixed $toCurrency
*
* @return string
* @throws \Magento\Framework\Exception\InputException
*/
Expand Down Expand Up @@ -348,8 +353,11 @@ public function formatPrecision(
}

/**
* Return formatted currency
*
* @param float $price
* @param array $options
*
* @return string
*/
public function formatTxt($price, $options = [])
Expand Down Expand Up @@ -420,7 +428,8 @@ private function formatCurrency(string $price, array $options): string
$this->numberFormatter = $this->getNumberFormatter($options);

$formattedCurrency = $this->numberFormatter->formatCurrency(
$price, $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
$price,
$this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
);

if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
Expand All @@ -430,7 +439,7 @@ private function formatCurrency(string $price, array $options): string

if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
$formattedCurrency = str_replace(' ', '', $formattedCurrency);
$formattedCurrency = preg_replace(['/[^0-9.,۰٫]+/', '/ /'], '', $formattedCurrency);
}

return preg_replace('/^\s+|\s+$/u', '', $formattedCurrency);
Expand All @@ -444,7 +453,10 @@ private function formatCurrency(string $price, array $options): string
*/
private function getNumberFormatter(array $options): \Magento\Framework\NumberFormatter
{
$key = 'currency_' . md5($this->localeResolver->getLocale() . $this->serializer->serialize($options));
$key = 'currency_' . hash(
'sha256',
($this->localeResolver->getLocale() . $this->serializer->serialize($options))
);
if (!isset($this->numberFormatterCache[$key])) {
$this->numberFormatter = $this->numberFormatterFactory->create(
['locale' => $this->localeResolver->getLocale(), 'style' => \NumberFormatter::CURRENCY]
Expand All @@ -467,7 +479,8 @@ private function setOptions(array $options): void
{
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
$this->numberFormatter->setSymbol(
\NumberFormatter::CURRENCY_SYMBOL, $options[LocaleCurrency::CURRENCY_OPTION_SYMBOL]
\NumberFormatter::CURRENCY_SYMBOL,
$options[LocaleCurrency::CURRENCY_OPTION_SYMBOL]
);
}
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
Expand All @@ -490,6 +503,8 @@ public function getCurrencySymbol()
}

/**
* Return the price format to be displayed to user
*
* @return string
*/
public function getOutputFormat()
Expand Down Expand Up @@ -532,6 +547,8 @@ public function getConfigDefaultCurrencies()
}

/**
* Retrieve base config currency data by config path.
*
* @return array
*/
public function getConfigBaseCurrencies()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function execute(string $path): AssetInterface
* SPL file info is not compatible with remote storages and must not be used.
*/
$file = $this->getFileInfo->execute($absolutePath);
[$width, $height] = getimagesize($absolutePath);
[$width, $height] = getimagesizefromstring($absolutePath);
$meta = [
'size' => $file->getSize(),
'extension' => $file->getExtension(),
Expand All @@ -98,12 +98,12 @@ public function execute(string $path): AssetInterface
[
'id' => null,
'path' => $path,
'title' => $meta['basename'],
'width' => $meta['extra']['image-width'],
'height' => $meta['extra']['image-height'],
'title' => $meta['basename'] ?? '',
'width' => $meta['extra']['image-width'] ?? 0,
'height' => $meta['extra']['image-height'] ?? 0,
'hash' => $this->getHash($path),
'size' => $meta['size'],
'contentType' => 'image/' . $meta['extension'],
'size' => $meta['size'] ?? 0,
'contentType' => sprintf('%s/%s', 'image', $meta['extension'] ?? ''),
'source' => 'Local'
]
);
Expand Down
8 changes: 8 additions & 0 deletions app/code/Magento/Sales/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@
<async_indexing>0</async_indexing>
</grid>
</dev>
<system>
<media_storage_configuration>
<allowed_resources>
<sales_logo_folder>sales/store/logo</sales_logo_folder>
<sales_logo_html_folder>sales/store/logo_html</sales_logo_html_folder>
</allowed_resources>
</media_storage_configuration>
</system>
<customer>
<create_account>
<email_required_create_order>1</email_required_create_order>
Expand Down
32 changes: 14 additions & 18 deletions app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Helper;
use Magento\Framework\DB\Select;
use Magento\Framework\Event\ManagerInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
Expand All @@ -26,22 +27,16 @@
class Collection extends AbstractCollection
{
/**
* Store for filter
*
* @var int
*/
protected $_storeId;

/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $_storeManager;

/**
* Search resource helper
*
* @var Helper
*/
protected $_resourceHelper;
Expand Down Expand Up @@ -116,21 +111,22 @@ public function getStoreId()
*/
public function setQueryFilter($query)
{
$this->getSelect()->reset(
\Magento\Framework\DB\Select::FROM
)->distinct(
true
)->from(
['main_table' => $this->getTable('search_query')]
)->where(
'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?',
$this->_resourceHelper->addLikeEscape($query, ['position' => 'start'])
)->order(
'popularity ' . \Magento\Framework\DB\Select::SQL_DESC
);
$this->getSelect()
->reset(Select::FROM)
->distinct(true)
->from(['main_table' => $this->getTable('search_query')])
->reset(Select::COLUMNS)
->columns(['query_text', 'num_results', 'popularity'])
->where(
'num_results > 0 AND display_in_terms = 1 AND query_text LIKE ?',
$this->_resourceHelper->addLikeEscape($query, ['position' => 'start'])
)
->order('popularity ' . \Magento\Framework\DB\Select::SQL_DESC);

if ($this->getStoreId()) {
$this->getSelect()->where('store_id = ?', (int)$this->getStoreId());
}

return $this;
}

Expand Down

0 comments on commit e88d5bd

Please sign in to comment.