Skip to content

Commit

Permalink
Some code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Torsten Freyda committed Feb 25, 2024
1 parent dd4392d commit aaf70b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
22 changes: 2 additions & 20 deletions src/Indexing/Write.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,12 @@ public function getIndexStructureInstances(?string $itemId=null): array

case 'product':

if ($itemId) {
$items = $this->products->getProductByProductId(
$itemId,
$indexStructure->getSalesChannelId()
)->getElements();
} else {
$items = $this->products->getAllActiveProduct(
$indexStructure->getSalesChannelId()
)->getElements();
}
$items = $this->products->getItems($itemId, $indexStructure->getSalesChannelId());
break;

case 'category':

if ($itemId) {
$items = $this->categories->getCategoryByCategoryId(
$itemId,
$indexStructure->getSalesChannelId()
)->getElements();
} else {
$items = $this->categories->getAllActiveCategories(
$indexStructure->getSalesChannelId()
)->getElements();
}
$items = $this->categories->getItems($itemId, $indexStructure->getSalesChannelId());
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"saveSuccessAlertMessage": "Search index structure was saved successfully."
},
"tabs": {
"structureList": "Index configurations",
"structureList": "Index Configurations",
"structureIndices": "Indices Structures",
"serverInfo": "Server Info"
},
Expand Down
9 changes: 9 additions & 0 deletions src/Services/Content/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,14 @@ protected function getCriteriaAssociations(string $salesChannelId): Criteria
->addFilter(new EqualsFilter('type', CategoryDefinition::TYPE_PAGE))
;
}

public function getItems(?string $itemId, string $salesChannelId): array
{
if ($itemId) {
return $this->getCategoryByCategoryId($itemId, $salesChannelId)->getElements();
} else {
return $this->getAllActiveCategories($salesChannelId)->getElements();
}
}
}

9 changes: 9 additions & 0 deletions src/Services/Content/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,14 @@ protected function getCriteriaAssociations(string $salesChannelId): Criteria
]))
;
}

public function getItems(?string $itemId, string $salesChannelId): array
{
if ($itemId) {
return $this->getProductByProductId($itemId, $salesChannelId)->getElements();
} else {
return $this->getAllActiveProduct($salesChannelId)->getElements();
}
}
}

0 comments on commit aaf70b7

Please sign in to comment.