Skip to content

Commit

Permalink
cleanup Smile-SA#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Crocombe authored and rbayet committed Sep 12, 2023
1 parent c0f6442 commit 707a6a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
16 changes: 10 additions & 6 deletions src/module-elasticsuite-catalog/Helper/ProductAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,18 @@ public function isFrontendProductDisplayPatternEnabled(): bool
public function formatProductAttributeValueDisplayPattern($attribute, $value)
{
// Translate attribute pattern, or default, without variable.
$pattern = $attribute->getData(self::DISPLAY_PATTERN_COLUMN) ?
(string) __($attribute->getData(self::DISPLAY_PATTERN_COLUMN)) :
(string) self::DEFAULT_DISPLAY_PATTERN;
// @codingStandardsIgnoreStart
$pattern = $attribute->getData(self::DISPLAY_PATTERN_COLUMN)
? (string) __($attribute->getData(self::DISPLAY_PATTERN_COLUMN))
: (string) self::DEFAULT_DISPLAY_PATTERN;
// @codingStandardsIgnoreEnd

// Get attribute display precision or default.
$precision = is_numeric($attribute->getData(self::DISPLAY_PRECISION_COLUMN) ?? '') ?
(int) abs($attribute->getData(self::DISPLAY_PRECISION_COLUMN)) :
(int) self::DEFAULT_DISPLAY_PRECISION;
// @codingStandardsIgnoreStart
$precision = is_numeric($attribute->getData(self::DISPLAY_PRECISION_COLUMN) ?? '')
? (int) abs($attribute->getData(self::DISPLAY_PRECISION_COLUMN))
: (int) self::DEFAULT_DISPLAY_PRECISION;
// @codingStandardsIgnoreEnd

// Round value to precision and format to locale string.
$amount = (string) $this->localeFormatter->formatNumber(round((float) $value, $precision));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ public function afterGetAdditionalData(\Magento\Catalog\Block\Product\View\Attri
foreach ($attributes as $attribute) {
// If attribute is already in array, then isVisibleOnFrontend = `true`.
if (isset($result[$attribute->getAttributeCode()])) {
$value = isset($result[$attribute->getAttributeCode()]['value']) ?
$result[$attribute->getAttributeCode()]['value'] :
'';
// @codingStandardsIgnoreStart
$value = isset($result[$attribute->getAttributeCode()]['value'])
? $result[$attribute->getAttributeCode()]['value']
: '';
// @codingStandardsIgnoreEnd

if (is_numeric($value) && strlen($attribute->getData('display_pattern') ?? '') > 0) {
$result[$attribute->getAttributeCode()]['value']
= $this->_productAttributeHelper->formatProductAttributeValueDisplayPattern($attribute, $value);
Expand Down

0 comments on commit 707a6a5

Please # to comment.