From 6532ad922f7678e90f692e1c5a5a70546831ac4f Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 16 Oct 2023 16:14:30 +0200 Subject: [PATCH 1/2] Add a generic method for loading categories based on different values with serialized return. --- CHANGELOG.md | 6 ++++++ src/Observers/ProductUrlRewriteObserver.php | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18480f2..06c2d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 25.0.4 + +## Features + +* Add a generic method `getCategoryByValue` to load categories based on different values with serialized return. + # 25.0.3 ## Bugfixes diff --git a/src/Observers/ProductUrlRewriteObserver.php b/src/Observers/ProductUrlRewriteObserver.php index fbacfd2..bc55b9e 100755 --- a/src/Observers/ProductUrlRewriteObserver.php +++ b/src/Observers/ProductUrlRewriteObserver.php @@ -120,7 +120,7 @@ protected function process() // remember the admin row on SKU to be safe on later process $this->adminRow[$sku] = array( - ColumnKeys::CATEGORIES => $this->getValue(ColumnKeys::CATEGORIES), + ColumnKeys::CATEGORIES => $this->getCategoryPath(), ColumnKeys::PRODUCT_WEBSITES => $this->getValue(ColumnKeys::PRODUCT_WEBSITES), ColumnKeys::VISIBILITY => $this->getValue(ColumnKeys::VISIBILITY), ColumnKeys::URL_KEY => $this->getValue(ColumnKeys::URL_KEY) @@ -362,4 +362,14 @@ protected function addArtefacts(array $artefacts) { $this->getSubject()->addArtefacts(ProductUrlRewriteObserver::ARTEFACT_TYPE, $artefacts); } + + /** + * Generic method to load categories based on different values with serialized return. + * + * @return mixed|null + */ + protected function getCategoryPath($defaultValue = null) + { + return $this->getValue($defaultValue); + } } From 78c308d6b0916cde51a07a32546b20f9efbdc8ea Mon Sep 17 00:00:00 2001 From: Kenza Yamlahi Date: Mon, 16 Oct 2023 16:18:46 +0200 Subject: [PATCH 2/2] fix static test issue --- src/Observers/ProductUrlRewriteObserver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Observers/ProductUrlRewriteObserver.php b/src/Observers/ProductUrlRewriteObserver.php index bc55b9e..2e85d78 100755 --- a/src/Observers/ProductUrlRewriteObserver.php +++ b/src/Observers/ProductUrlRewriteObserver.php @@ -366,6 +366,8 @@ protected function addArtefacts(array $artefacts) /** * Generic method to load categories based on different values with serialized return. * + * @param string $defaultValue The default value + * * @return mixed|null */ protected function getCategoryPath($defaultValue = null)