Skip to content

Commit

Permalink
Merge pull request #39 from techdivision/pac-5-optimize-code
Browse files Browse the repository at this point in the history
Add a generic method for loading categories based on different values…
  • Loading branch information
kenza-ya authored Oct 16, 2023
2 parents 5a2f557 + 78c308d commit ce18b07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/Observers/ProductUrlRewriteObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -362,4 +362,16 @@ protected function addArtefacts(array $artefacts)
{
$this->getSubject()->addArtefacts(ProductUrlRewriteObserver::ARTEFACT_TYPE, $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)
{
return $this->getValue($defaultValue);
}
}

0 comments on commit ce18b07

Please sign in to comment.