From 898379d4a34a614776c3b4dbbd9086cf034512fa Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 14 Aug 2024 13:38:30 +0200
Subject: [PATCH 01/23] feat: bucket slider
---
.../RenderLayered/SliderRenderer.php | 64 +++++++++-
Model/Catalog/Layer/Filter.php | 25 ++++
Model/Client/Type/FacetType.php | 26 +++-
Model/Client/Type/FacetType/SettingsType.php | 16 +++
Model/NavigationConfig.php | 2 +
.../templates/product/layered/slider.phtml | 117 ++++++++++++++++--
.../web/js/navigation-slider-widget.js | 20 +++
7 files changed, 256 insertions(+), 14 deletions(-)
diff --git a/Block/LayeredNavigation/RenderLayered/SliderRenderer.php b/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
index efded38c..66e5afe1 100644
--- a/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
+++ b/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
@@ -85,7 +85,6 @@ protected function getItemValue($index, $default = 0)
return (float) $items[$index]->getLabel();
}
-
/**
* @return int
*/
@@ -173,4 +172,67 @@ public function getCssId()
return 'slider-' . $urlKey;
}
+
+ /**
+ * @return bool
+ */
+ public function containsBuckets(): bool
+ {
+ return $this->filter->getFacet()->getFacetSettings()->containsBuckets();
+ }
+
+ /**
+ * @return bool
+ */
+ public function containsClickpoints(): bool
+ {
+ return $this->filter->getFacet()->getFacetSettings()->containsClickpoints();
+ }
+
+ /**
+ * @return array
+ */
+ public function getBuckets() : array
+ {
+ if ($this->containsBuckets()) {
+ return $this->filter->getFacet()->getBuckets();
+ }
+
+ return [];
+ }
+
+ public function getClickPoints() : array
+ {
+ if ($this->containsClickpoints()) {
+ return $this->filter->getFacet()->getClickpoints();
+ }
+
+ return [];
+ }
+
+ public function getBucketHightFactor() : float
+ {
+ $maxRelativeRange = 1;
+ if ($this->containsBuckets()) {
+ $buckets = $this->getBuckets();
+ foreach ($buckets as $bucket) {
+ //get max range from bucket array
+ if ($bucket['relativeamount'] > $maxRelativeRange) {
+ $relativeAmount = ceil($bucket['relativeamount']);
+ if ($relativeAmount > $maxRelativeRange) {
+ $maxRelativeRange = $relativeAmount;
+ }
+ }
+ }
+ }
+
+ $bucketHightFactor = 60 / $maxRelativeRange;
+
+ return $bucketHightFactor;
+ }
+
+ public function getTotalrange() : float
+ {
+ return ($this->getMaxValue() - $this->getMinValue());
+ }
}
diff --git a/Model/Catalog/Layer/Filter.php b/Model/Catalog/Layer/Filter.php
index 9ce3a445..d6ec77ee 100644
--- a/Model/Catalog/Layer/Filter.php
+++ b/Model/Catalog/Layer/Filter.php
@@ -42,6 +42,11 @@ class Filter extends AbstractFilter implements FilterInterface
*/
protected $items;
+ /**
+ * @var array
+ */
+ protected $buckets;
+
/**
* @var Layer
*/
@@ -174,6 +179,18 @@ public function getItems()
return $this->items;
}
+ /**
+ * @return array
+ */
+ public function getBuckets() : array
+ {
+ if (!$this->buckets) {
+ $this->initBuckets();
+ }
+
+ return $this->buckets;
+ }
+
/**
* @param AttributeType $item
* @return $this
@@ -375,6 +392,14 @@ protected function initItems()
return $this;
}
+ /**
+ * @return void
+ */
+ protected function initBuckets() : void
+ {
+ $this->buckets = $this->facet->getBuckets();
+ }
+
/**
* @return int[]
*/
diff --git a/Model/Client/Type/FacetType.php b/Model/Client/Type/FacetType.php
index 56ca4cfd..a00155ef 100644
--- a/Model/Client/Type/FacetType.php
+++ b/Model/Client/Type/FacetType.php
@@ -51,7 +51,7 @@ public function setAttributes(array $attributes)
$this->data['attributes'] = $values;
return $this;
}
-
+
public function getFacetSettings(): ?SettingsType
{
return $this->getValue('facet_settings');
@@ -64,4 +64,28 @@ public function getAttributes(): ?array
{
return $this->getValue('attributes');
}
+
+ /**
+ * @return array
+ */
+ public function getBuckets(): array {
+ //only return buckets if there is more than one bucket
+ if (isset($this->data['buckets']['bucket'][0]) && is_array($this->data['buckets']['bucket'][0])) {
+ return $this->data['buckets']['bucket'];
+ }
+
+ return [];
+ }
+
+ /**
+ * @return array
+ */
+ public function getClickpoints(): array {
+ if (isset($this->data['clickpoints']['clickpoint'][0]) && is_array($this->data['clickpoints']['clickpoint'][0])) {
+ return $this->data['clickpoints']['clickpoint'];
+ } else if (isset($this->data['clickpoints']['clickpoint'])) {
+ return $this->data['clickpoints'];
+ }
+ return [];
+ }
}
diff --git a/Model/Client/Type/FacetType/SettingsType.php b/Model/Client/Type/FacetType/SettingsType.php
index 00bc28ef..dc2754fb 100644
--- a/Model/Client/Type/FacetType/SettingsType.php
+++ b/Model/Client/Type/FacetType/SettingsType.php
@@ -234,4 +234,20 @@ public function getSearchNoResultsText()
{
return empty($this->getValue('searchnoresultstext')) ? '' : $this->getValue('searchnoresultstext');
}
+
+ /**
+ * @return bool
+ */
+ public function containsBuckets() : bool
+ {
+ return $this->getBoolValue('containsbuckets');
+ }
+
+ /**
+ * @return bool
+ */
+ public function containsClickpoints() : bool
+ {
+ return $this->getBoolValue('containsclickpoints');
+ }
}
diff --git a/Model/NavigationConfig.php b/Model/NavigationConfig.php
index 5b272c31..373d7058 100644
--- a/Model/NavigationConfig.php
+++ b/Model/NavigationConfig.php
@@ -158,6 +158,8 @@ public function getJsSliderConfig(SliderRenderer $sliderRenderer)
'max' => $sliderRenderer->getMaxValue(),
'currentMin' => $sliderRenderer->getCurrentMinValue(),
'currentMax' => $sliderRenderer->getCurrentMaxValue(),
+ 'containsBuckets' => $sliderRenderer->containsBuckets(),
+ 'containsClickpoints' => $sliderRenderer->containsClickpoints(),
]
]
);
diff --git a/view/frontend/templates/product/layered/slider.phtml b/view/frontend/templates/product/layered/slider.phtml
index 7c5979e7..f6aefe18 100644
--- a/view/frontend/templates/product/layered/slider.phtml
+++ b/view/frontend/templates/product/layered/slider.phtml
@@ -16,24 +16,58 @@ $itemPostfix = $block->getItemPostfix();
$urlKey = $block->getUrlKey();
$minValue = $block->getMinValue();
$maxValue = $block->getMaxValue();
+$totalRange = $block->getTotalRange();
$currentMinValue = $block->getCurrentMinValue();
$currentMaxValue = $block->getCurrentMaxValue();
$sliderUrlInputValue = sprintf('%s-%s', $currentMinValue, $currentMaxValue);
$disabledSliderUrlInputValue = sprintf('%s-%s', $minValue, $maxValue);
+$cointainsBuckets = $block->containsBuckets();
+$cointainsClickpoints = $block->containsClickpoints();
+$clickpointCounter = 0;
?>
-
-
- = $itemPrefix ?>
- =$block->renderValue($minValue)?>
- = $itemPostfix ?>
-
-
- = $itemPrefix ?>
- =$block->renderValue($maxValue)?>
- = $itemPostfix ?>
-
-
+
+
+ getBucketHightFactor();
+ ?>
+ getBuckets() as $bucket): ?>
+
+
+
+
+
+
+
+
+
+ getClickpoints());
+ $totalClickpointsRange = $totalRange + ($totalClickpoints * 2);
+ ?>
+
+
+
@@ -78,3 +112,62 @@ $disabledSliderUrlInputValue = sprintf('%s-%s', $minValue, $maxValue);
>
+
+
diff --git a/view/frontend/web/js/navigation-slider-widget.js b/view/frontend/web/js/navigation-slider-widget.js
index 576a8b19..b5a8449d 100644
--- a/view/frontend/web/js/navigation-slider-widget.js
+++ b/view/frontend/web/js/navigation-slider-widget.js
@@ -24,6 +24,8 @@ define([
currentMax: 99999999,
formFilters: false,
ajaxFilters: false,
+ containsBucket: false,
+ containsClickpoints: false
},
/**
@@ -88,6 +90,10 @@ define([
var sliderContainer = $(this.options.container);
sliderContainer.on('change', '.slider-min', this._updateSliderUrlInput.bind(this));
sliderContainer.on('change', '.slider-max', this._updateSliderUrlInput.bind(this));
+ if (this.options.containsBucket) {
+ sliderContainer.on('click', '.bucket-link', this._clickBucketSlider.bind(this));
+ }
+
},
/**
@@ -105,6 +111,20 @@ define([
this._updateSliderDisabledAttribute(sliderUrlInput, inputValue)
},
+ _clickBucketSlider: function (event) {
+
+ var sliderContainer = $(this.options.container);
+ var sliderUrlInput = sliderContainer.find('.slider-url-value');
+ var bucket = $(event.currentTarget);
+ var minValue = bucket.data('rangemin');
+ var maxValue = bucket.data('rangemax');
+ var inputValue = minValue + '-' + maxValue;
+ sliderUrlInput.val(inputValue);
+ // Trigger change event on sliderUrlInput
+ this._updateSliderDisabledAttribute(sliderUrlInput, inputValue);
+ sliderUrlInput.trigger('change');
+ },
+
/**
*
* @param sliderUrlInput
From e1534d7f353c4c0b5b427072af37afe5284bc55f Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 14 Aug 2024 13:48:33 +0200
Subject: [PATCH 02/23] style fixes
---
.../RenderLayered/SliderRenderer.php | 9 +++++----
Model/Catalog/Layer/Filter.php | 4 ++--
Model/Client/Type/FacetType.php | 11 +++++++----
Model/Client/Type/FacetType/SettingsType.php | 4 ++--
view/frontend/templates/product/layered/slider.phtml | 4 ++--
5 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/Block/LayeredNavigation/RenderLayered/SliderRenderer.php b/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
index 66e5afe1..14b90579 100644
--- a/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
+++ b/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
@@ -85,6 +85,7 @@ protected function getItemValue($index, $default = 0)
return (float) $items[$index]->getLabel();
}
+
/**
* @return int
*/
@@ -192,7 +193,7 @@ public function containsClickpoints(): bool
/**
* @return array
*/
- public function getBuckets() : array
+ public function getBuckets(): array
{
if ($this->containsBuckets()) {
return $this->filter->getFacet()->getBuckets();
@@ -201,7 +202,7 @@ public function getBuckets() : array
return [];
}
- public function getClickPoints() : array
+ public function getClickPoints(): array
{
if ($this->containsClickpoints()) {
return $this->filter->getFacet()->getClickpoints();
@@ -210,7 +211,7 @@ public function getClickPoints() : array
return [];
}
- public function getBucketHightFactor() : float
+ public function getBucketHightFactor(): float
{
$maxRelativeRange = 1;
if ($this->containsBuckets()) {
@@ -231,7 +232,7 @@ public function getBucketHightFactor() : float
return $bucketHightFactor;
}
- public function getTotalrange() : float
+ public function getTotalrange(): float
{
return ($this->getMaxValue() - $this->getMinValue());
}
diff --git a/Model/Catalog/Layer/Filter.php b/Model/Catalog/Layer/Filter.php
index d6ec77ee..9e1237d3 100644
--- a/Model/Catalog/Layer/Filter.php
+++ b/Model/Catalog/Layer/Filter.php
@@ -182,7 +182,7 @@ public function getItems()
/**
* @return array
*/
- public function getBuckets() : array
+ public function getBuckets(): array
{
if (!$this->buckets) {
$this->initBuckets();
@@ -395,7 +395,7 @@ protected function initItems()
/**
* @return void
*/
- protected function initBuckets() : void
+ protected function initBuckets(): void
{
$this->buckets = $this->facet->getBuckets();
}
diff --git a/Model/Client/Type/FacetType.php b/Model/Client/Type/FacetType.php
index a00155ef..9d581600 100644
--- a/Model/Client/Type/FacetType.php
+++ b/Model/Client/Type/FacetType.php
@@ -68,7 +68,8 @@ public function getAttributes(): ?array
/**
* @return array
*/
- public function getBuckets(): array {
+ public function getBuckets(): array
+ {
//only return buckets if there is more than one bucket
if (isset($this->data['buckets']['bucket'][0]) && is_array($this->data['buckets']['bucket'][0])) {
return $this->data['buckets']['bucket'];
@@ -80,10 +81,12 @@ public function getBuckets(): array {
/**
* @return array
*/
- public function getClickpoints(): array {
- if (isset($this->data['clickpoints']['clickpoint'][0]) && is_array($this->data['clickpoints']['clickpoint'][0])) {
+ public function getClickpoints(): array
+ {
+ if (isset($this->data['clickpoints']['clickpoint'][0])
+ && is_array($this->data['clickpoints']['clickpoint'][0])) {
return $this->data['clickpoints']['clickpoint'];
- } else if (isset($this->data['clickpoints']['clickpoint'])) {
+ } elseif (isset($this->data['clickpoints']['clickpoint'])) {
return $this->data['clickpoints'];
}
return [];
diff --git a/Model/Client/Type/FacetType/SettingsType.php b/Model/Client/Type/FacetType/SettingsType.php
index dc2754fb..bfdf63cd 100644
--- a/Model/Client/Type/FacetType/SettingsType.php
+++ b/Model/Client/Type/FacetType/SettingsType.php
@@ -238,7 +238,7 @@ public function getSearchNoResultsText()
/**
* @return bool
*/
- public function containsBuckets() : bool
+ public function containsBuckets(): bool
{
return $this->getBoolValue('containsbuckets');
}
@@ -246,7 +246,7 @@ public function containsBuckets() : bool
/**
* @return bool
*/
- public function containsClickpoints() : bool
+ public function containsClickpoints(): bool
{
return $this->getBoolValue('containsclickpoints');
}
diff --git a/view/frontend/templates/product/layered/slider.phtml b/view/frontend/templates/product/layered/slider.phtml
index f6aefe18..33d0a5cf 100644
--- a/view/frontend/templates/product/layered/slider.phtml
+++ b/view/frontend/templates/product/layered/slider.phtml
@@ -32,7 +32,7 @@ $clickpointCounter = 0;
getBucketHightFactor();
?>
- getBuckets() as $bucket): ?>
+ getBuckets() as $bucket): ?>
- getClickpoints() as $clickpoint): ?>
+ getClickpoints() as $clickpoint): ?>
Date: Wed, 14 Aug 2024 14:12:14 +0200
Subject: [PATCH 03/23] Style fixes
---
Model/Client/Type/FacetType.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Model/Client/Type/FacetType.php b/Model/Client/Type/FacetType.php
index 9d581600..cec15c80 100644
--- a/Model/Client/Type/FacetType.php
+++ b/Model/Client/Type/FacetType.php
@@ -83,12 +83,15 @@ public function getBuckets(): array
*/
public function getClickpoints(): array
{
- if (isset($this->data['clickpoints']['clickpoint'][0])
- && is_array($this->data['clickpoints']['clickpoint'][0])) {
+ if (
+ isset($this->data['clickpoints']['clickpoint'][0])
+ && is_array($this->data['clickpoints']['clickpoint'][0]))
+ {
return $this->data['clickpoints']['clickpoint'];
} elseif (isset($this->data['clickpoints']['clickpoint'])) {
return $this->data['clickpoints'];
}
+
return [];
}
}
From 6d7038236861db5c3e660f6518bfee0382fb46f7 Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 14 Aug 2024 14:31:56 +0200
Subject: [PATCH 04/23] Stye fixes
---
Model/Client/Type/FacetType.php | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/Model/Client/Type/FacetType.php b/Model/Client/Type/FacetType.php
index cec15c80..efc1778e 100644
--- a/Model/Client/Type/FacetType.php
+++ b/Model/Client/Type/FacetType.php
@@ -83,15 +83,13 @@ public function getBuckets(): array
*/
public function getClickpoints(): array
{
- if (
- isset($this->data['clickpoints']['clickpoint'][0])
- && is_array($this->data['clickpoints']['clickpoint'][0]))
+ if (isset($this->data['clickpoints']['clickpoint'][0]) && is_array($this->data['clickpoints']['clickpoint'][0]))
{
return $this->data['clickpoints']['clickpoint'];
} elseif (isset($this->data['clickpoints']['clickpoint'])) {
return $this->data['clickpoints'];
}
-
+
return [];
}
}
From 242db3f689cd8e062657e8891ffb901ae77a348f Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 14 Aug 2024 14:35:05 +0200
Subject: [PATCH 05/23] Style fixes
---
Model/Client/Type/FacetType.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Model/Client/Type/FacetType.php b/Model/Client/Type/FacetType.php
index efc1778e..fd5055cf 100644
--- a/Model/Client/Type/FacetType.php
+++ b/Model/Client/Type/FacetType.php
@@ -83,8 +83,9 @@ public function getBuckets(): array
*/
public function getClickpoints(): array
{
- if (isset($this->data['clickpoints']['clickpoint'][0]) && is_array($this->data['clickpoints']['clickpoint'][0]))
- {
+ if (isset($this->data['clickpoints']['clickpoint'][0])
+ && is_array($this->data['clickpoints']['clickpoint'][0])
+ ) {
return $this->data['clickpoints']['clickpoint'];
} elseif (isset($this->data['clickpoints']['clickpoint'])) {
return $this->data['clickpoints'];
From 20539078975e2392144b955b25be71d69c079268 Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 14 Aug 2024 14:37:30 +0200
Subject: [PATCH 06/23] Style fixes
---
Model/Client/Type/FacetType.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Model/Client/Type/FacetType.php b/Model/Client/Type/FacetType.php
index fd5055cf..16a6d343 100644
--- a/Model/Client/Type/FacetType.php
+++ b/Model/Client/Type/FacetType.php
@@ -83,7 +83,8 @@ public function getBuckets(): array
*/
public function getClickpoints(): array
{
- if (isset($this->data['clickpoints']['clickpoint'][0])
+ if (
+ isset($this->data['clickpoints']['clickpoint'][0])
&& is_array($this->data['clickpoints']['clickpoint'][0])
) {
return $this->data['clickpoints']['clickpoint'];
From 97ea26da0c27fd9f74f935eb8fc82adac2ec539d Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Thu, 22 Aug 2024 12:17:34 +0200
Subject: [PATCH 07/23] fix: remove phpcs disable
---
view/frontend/templates/form.mini.phtml | 1 -
view/frontend/templates/layer/state.phtml | 1 -
view/frontend/templates/layer/view.phtml | 1 -
view/frontend/templates/product/layered/default.phtml | 1 -
view/frontend/templates/product/layered/link.phtml | 1 -
view/frontend/templates/product/layered/link/item.phtml | 1 -
view/frontend/templates/product/layered/slider.phtml | 1 -
view/frontend/templates/product/layered/tree.phtml | 1 -
view/frontend/templates/product/layered/tree/item.phtml | 1 -
9 files changed, 9 deletions(-)
diff --git a/view/frontend/templates/form.mini.phtml b/view/frontend/templates/form.mini.phtml
index 0730c8f5..216eed86 100644
--- a/view/frontend/templates/form.mini.phtml
+++ b/view/frontend/templates/form.mini.phtml
@@ -9,7 +9,6 @@
/**
* @var $block \Tweakwise\Magento2Tweakwise\Block\Autocomplete\FormMini
* @var $escaper Escaper
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
* phpcs:disable Magento2.Legacy.PhtmlTemplate.TextJavascriptTypeFound
*/
diff --git a/view/frontend/templates/layer/state.phtml b/view/frontend/templates/layer/state.phtml
index a8045296..c21361ed 100644
--- a/view/frontend/templates/layer/state.phtml
+++ b/view/frontend/templates/layer/state.phtml
@@ -13,7 +13,6 @@ use Magento\Framework\Escaper;
*
* @var $block \Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\Navigation\State
* @var $escaper Escaper
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
?>
diff --git a/view/frontend/templates/layer/view.phtml b/view/frontend/templates/layer/view.phtml
index 4e8b54ac..1ea478a0 100644
--- a/view/frontend/templates/layer/view.phtml
+++ b/view/frontend/templates/layer/view.phtml
@@ -12,7 +12,6 @@ use Magento\LayeredNavigation\Block\Navigation;
/**
* @var $block Navigation
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
if (!$block->canShowBlock()) {
diff --git a/view/frontend/templates/product/layered/default.phtml b/view/frontend/templates/product/layered/default.phtml
index 1a64a8c4..c1a863e3 100644
--- a/view/frontend/templates/product/layered/default.phtml
+++ b/view/frontend/templates/product/layered/default.phtml
@@ -9,7 +9,6 @@ use Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\DefaultRen
/**
* @var $block DefaultRenderer
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
$hasHiddenItems = $block->hasHiddenItems();
diff --git a/view/frontend/templates/product/layered/link.phtml b/view/frontend/templates/product/layered/link.phtml
index 4aa58c0c..561702ab 100644
--- a/view/frontend/templates/product/layered/link.phtml
+++ b/view/frontend/templates/product/layered/link.phtml
@@ -9,7 +9,6 @@ use Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\TreeRender
/**
* @var $block \Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRenderer
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
$hasHiddenItems = $block->hasHiddenItems();
?>
diff --git a/view/frontend/templates/product/layered/link/item.phtml b/view/frontend/templates/product/layered/link/item.phtml
index 06917972..6e94bbe4 100644
--- a/view/frontend/templates/product/layered/link/item.phtml
+++ b/view/frontend/templates/product/layered/link/item.phtml
@@ -9,7 +9,6 @@ use Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\LinkRender
/**
* @var $block ItemRenderer
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
$item = $block->getItem();
$hasHiddenItems = $block->hasHiddenItems();
diff --git a/view/frontend/templates/product/layered/slider.phtml b/view/frontend/templates/product/layered/slider.phtml
index 7c5979e7..624d55af 100644
--- a/view/frontend/templates/product/layered/slider.phtml
+++ b/view/frontend/templates/product/layered/slider.phtml
@@ -9,7 +9,6 @@ use Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\SliderRend
/**
* @var $block SliderRenderer
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
$itemPrefix = $block->getItemPrefix();
$itemPostfix = $block->getItemPostfix();
diff --git a/view/frontend/templates/product/layered/tree.phtml b/view/frontend/templates/product/layered/tree.phtml
index c5fc38ba..c95c15c4 100644
--- a/view/frontend/templates/product/layered/tree.phtml
+++ b/view/frontend/templates/product/layered/tree.phtml
@@ -9,7 +9,6 @@ use Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\TreeRender
/**
* @var $block TreeRenderer
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
?>
diff --git a/view/frontend/templates/product/layered/tree/item.phtml b/view/frontend/templates/product/layered/tree/item.phtml
index 3e36edc8..4a7cf67f 100644
--- a/view/frontend/templates/product/layered/tree/item.phtml
+++ b/view/frontend/templates/product/layered/tree/item.phtml
@@ -9,7 +9,6 @@ use Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\TreeRender
/**
* @var $block ItemRenderer
- * phpcs:disable Magento2.Security.XssTemplate.FoundUnescaped
*/
$item = $block->getItem();
?>
From dccfbdc64f749c593b9078c4c5811c02af9d9b53 Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Thu, 22 Aug 2024 12:27:43 +0200
Subject: [PATCH 08/23] fix: remove noEscapes
---
Model/Catalog/Layer/Filter.php | 3 +-
view/frontend/templates/layer/state.phtml | 4 +-
.../templates/product/layered/swatch.phtml | 46 +++++++++----------
view/frontend/templates/product/list.phtml | 2 +-
.../templates/product/list/item.phtml | 24 +++++-----
.../templates/product/list/items.phtml | 8 ++--
.../templates/product/list/linked-item.phtml | 16 +++----
.../searchbanner/search.banner.phtml | 2 +-
8 files changed, 52 insertions(+), 53 deletions(-)
diff --git a/Model/Catalog/Layer/Filter.php b/Model/Catalog/Layer/Filter.php
index 9ce3a445..acc353f1 100644
--- a/Model/Catalog/Layer/Filter.php
+++ b/Model/Catalog/Layer/Filter.php
@@ -257,8 +257,7 @@ public function getAttributeModel()
*/
public function getName()
{
- $title = (string) $this->facet->getFacetSettings()->getTitle();
- return htmlentities($title);
+ return (string) $this->facet->getFacetSettings()->getTitle();
}
/**
diff --git a/view/frontend/templates/layer/state.phtml b/view/frontend/templates/layer/state.phtml
index c21361ed..68f50813 100644
--- a/view/frontend/templates/layer/state.phtml
+++ b/view/frontend/templates/layer/state.phtml
@@ -26,7 +26,7 @@ use Magento\Framework\Escaper;
role="heading"
aria-level="2"
data-role="title"
- data-count="= /* @noEscape */ count($_filters) ?>">= $escaper->escapeHtml(__('Now Shopping by')) ?>
+ data-count="= count($_filters) ?>">= $escaper->escapeHtml(__('Now Shopping by')) ?>
@@ -43,7 +43,7 @@ use Magento\Framework\Escaper;
?>
">
+ title="= $escaper->escapeHtmlAttr(__('Remove')) . " " . $currentFilterName ?>">
= $escaper->escapeHtml(__('Remove This Item')) ?>
diff --git a/view/frontend/templates/product/layered/swatch.phtml b/view/frontend/templates/product/layered/swatch.phtml
index 8e1f2fe9..5f573a5b 100644
--- a/view/frontend/templates/product/layered/swatch.phtml
+++ b/view/frontend/templates/product/layered/swatch.phtml
@@ -9,9 +9,9 @@
/** @var $block \Tweakwise\Magento2Tweakwise\Block\LayeredNavigation\RenderLayered\SwatchRenderer */
?>
getSwatchData(); ?>
-
-
+ option-tooltip-value="= $swatchData['swatches'][$option]['value'] ?>"
+ style="background: = $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;">
- = /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>
+ >= $swatchData['swatches'][$option]['value'] ?>
shouldDisplayProductCountOnLayer()): ?>
- =htmlentities($item->getCount())?>
+ =$item->getCount()?>
getCount() == 1):?>
=__('item')?>
@@ -104,7 +104,7 @@
diff --git a/view/frontend/templates/layer/state.phtml b/view/frontend/templates/layer/state.phtml
index 68f50813..ce598cf6 100644
--- a/view/frontend/templates/layer/state.phtml
+++ b/view/frontend/templates/layer/state.phtml
@@ -42,8 +42,8 @@ use Magento\Framework\Escaper;
);
?>
">
+ data-js-filter-id="=$escaper->escapeHtmlAttr($block->getActiveFilterCssId($_filter))?>"
+ title="= $escaper->escapeHtmlAttr(__('Remove') . " " . $currentFilterName)?>">
= $escaper->escapeHtml(__('Remove This Item')) ?>
diff --git a/view/frontend/templates/layer/view.phtml b/view/frontend/templates/layer/view.phtml
index 93d8dae3..b9c6b076 100644
--- a/view/frontend/templates/layer/view.phtml
+++ b/view/frontend/templates/layer/view.phtml
@@ -37,9 +37,8 @@ if (!$block->canShowBlock()) {
}
}
}'>
- getLayer()->getState()->getFilters()) ?>
-
-
=__('Shop By')?>
+
+ =$escaper->escapeHtml(__('Shop By'))?>
diff --git a/view/frontend/templates/product/layered/default.phtml b/view/frontend/templates/product/layered/default.phtml
index 43daf6e8..e7573a4d 100644
--- a/view/frontend/templates/product/layered/default.phtml
+++ b/view/frontend/templates/product/layered/default.phtml
@@ -22,15 +22,15 @@ $postfix = $block->getItemPostfix();
$shouldDisplayProductCountLayer = $block->shouldDisplayProductCountOnLayer();
?>
-
+
diff --git a/view/frontend/templates/product/layered/slider.phtml b/view/frontend/templates/product/layered/slider.phtml
index 68ce8ced..831ca45a 100644
--- a/view/frontend/templates/product/layered/slider.phtml
+++ b/view/frontend/templates/product/layered/slider.phtml
@@ -23,7 +23,7 @@ $currentMaxValue = $block->getCurrentMaxValue();
$sliderUrlInputValue = sprintf('%s-%s', $currentMinValue, $currentMaxValue);
$disabledSliderUrlInputValue = sprintf('%s-%s', $minValue, $maxValue);
?>
-
+
= $itemPrefix ?>
diff --git a/view/frontend/templates/searchbanner/search.banner.phtml b/view/frontend/templates/searchbanner/search.banner.phtml
index 61e4c61d..dff26abc 100644
--- a/view/frontend/templates/searchbanner/search.banner.phtml
+++ b/view/frontend/templates/searchbanner/search.banner.phtml
@@ -1,10 +1,15 @@
getData('banners');
-$styling = ($banners[0]['location'] == 'ContainerTop') ? 'style="margin-right: auto; margin-left: auto;"' : '';
+$styling = ($banners[0]['location'] == 'ContainerTop') ? 'margin-right: auto; margin-left: auto;' : '';
?>
->
+
-
+
Date: Wed, 16 Oct 2024 10:56:27 +0200
Subject: [PATCH 22/23] Fix lint issue
---
Model/Client.php | 7 +++++--
Model/Config.php | 22 +---------------------
Model/ModuleInformation.php | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 23 deletions(-)
create mode 100644 Model/ModuleInformation.php
diff --git a/Model/Client.php b/Model/Client.php
index 6c3bcedf..18ee7fcf 100644
--- a/Model/Client.php
+++ b/Model/Client.php
@@ -71,13 +71,16 @@ class Client
* @param Logger $log
* @param ResponseFactory $responseFactory
* @param EndpointManager $endpointManager
+ * @param Timer $timer
+ * @param ModuleInformation $moduleInformation
*/
public function __construct(
Config $config,
Logger $log,
ResponseFactory $responseFactory,
EndpointManager $endpointManager,
- Timer $timer
+ Timer $timer,
+ private readonly ModuleInformation $moduleInformation
) {
$this->config = $config;
$this->log = $log;
@@ -97,7 +100,7 @@ protected function getClient(): HttpClient
RequestOptions::HEADERS => [
'user-agent' => $this->config->getUserAgentString(),
'Accept-Encoding' => 'gzip, deflate',
- 'TWN-Source' => $this->config->getModuleVersion(),
+ 'TWN-Source' => $this->moduleInformation->getModuleVersion(),
]
];
$this->client = new HttpClient($options);
diff --git a/Model/Config.php b/Model/Config.php
index 6e96aa38..f356aac4 100644
--- a/Model/Config.php
+++ b/Model/Config.php
@@ -21,7 +21,6 @@
use Magento\Store\Model\Store;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\App\Config\Storage\WriterInterface;
-use Magento\Framework\Composer\ComposerInformation;
/**
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
@@ -121,7 +120,6 @@ class Config
* @param State $state
* @param WriterInterface $configWriter
* @param TypeListInterface $cacheTypeList
- * @param ComposerInformation $composerInformation
* @throws LocalizedException
*/
public function __construct(
@@ -130,8 +128,7 @@ public function __construct(
RequestInterface $request,
State $state,
WriterInterface $configWriter,
- TypeListInterface $cacheTypeList,
- private readonly ComposerInformation $composerInformation
+ TypeListInterface $cacheTypeList
) {
$this->config = $config;
$this->jsonSerializer = $jsonSerializer;
@@ -641,21 +638,4 @@ public function getProductCardLifetime(): int
{
return (int) $this->config->getValue(self::PRODUCT_CARD_LIFETIME_XML_PATH, ScopeInterface::SCOPE_STORE);
}
-
- /**
- * @return string
- */
- public function getModuleVersion(): string
- {
- $installedPackages = $this->composerInformation
- ->getInstalledMagentoPackages();
- if (!isset($installedPackages['tweakwise/magento2-tweakwise']['version'])) {
- // This should never be the case
- return '';
- }
-
- $version = $installedPackages['tweakwise/magento2-tweakwise']['version'];
-
- return sprintf('Magento2Tweakwise %s', $version);
- }
}
diff --git a/Model/ModuleInformation.php b/Model/ModuleInformation.php
new file mode 100644
index 00000000..e49b8b02
--- /dev/null
+++ b/Model/ModuleInformation.php
@@ -0,0 +1,35 @@
+composerInformation
+ ->getInstalledMagentoPackages();
+ if (!isset($installedPackages['tweakwise/magento2-tweakwise']['version'])) {
+ // This should never be the case
+ return '';
+ }
+
+ $version = $installedPackages['tweakwise/magento2-tweakwise']['version'];
+
+ return sprintf('Magento2Tweakwise %s', $version);
+ }
+}
From 092d67361603d92ebbbe9e2c83334468133ed6e9 Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 16 Oct 2024 13:15:47 +0200
Subject: [PATCH 23/23] Bump version number
---
etc/adminhtml/system.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 61284868..0503db62 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -12,7 +12,7 @@
- Tweakwise version v8.1.0
+ Tweakwise version v8.2.0
Provided by Tweakwise (8 alphanumeric characters)