-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
The Model/Config/TemplateFinder.php class causes lots of recursive lookups in the category tree. It would be similar to having a look doing heavy db calls in it:
public function forCategory(Category $category, $type)
{
$attribute = $this->getAttribute($type);
$templateId = (int) $category->getData($attribute);
if ($templateId === RecommendationOption::OPTION_CODE) {
$groupAttribute = $this->getGroupCodeAttribute($type);
return (string) $category->getData($groupAttribute);
}
if ($templateId) {
return $templateId;
}
if ($category->getParentId()) {
$parent = $category->getParentCategory();
return $this->forCategory($parent, $type);
}
return null;
}
This is of course a well-known bad practice. My advice would be to do a smarter lookup, probably by not utilizing the repository pattern and using a dedicated prepared query for this, to do the lookup in one call. I've seen projects were almost a dozen category repository calls were done on a single PDP.
Metadata
Metadata
Assignees
Labels
No labels
