Skip to content

Commit

Permalink
Merge pull request #22 from aleksandrsm/catalog-performance
Browse files Browse the repository at this point in the history
Performance improvement - attribute group data and swatch check scaling
  • Loading branch information
carinadues authored Sep 28, 2021
2 parents bea28fe + 29b389a commit 3cc3ca7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Model/Resolver/Products/DataPostProcessor/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@ protected function appendWithGroup(
->load();

foreach ($attributeDataBySetId as $attributeSetId => $attributeData) {
$dataPath = sprintf('attribute_set_info/%s/group_id', $attributeSetId);

foreach ($attributeData as $attributeCode => $data) {
$attributeGroupId = $attributes[$attributeCode]->getData($dataPath);

// Find the correct group for every attribute
/** @var AttributeGroupInterface $group */
foreach ($groupCollection as $group) {
if ($attributes[$attributeCode]->isInGroup($attributeSetId, $group->getAttributeGroupId())) {
if ($attributeGroupId === $group->getAttributeGroupId()) {
$attributeDataBySetId[$attributeSetId][$attributeCode]['attribute_group_name'] = $group->getAttributeGroupName();
$attributeDataBySetId[$attributeSetId][$attributeCode]['attribute_group_id'] = $group->getAttributeGroupId();
$attributeDataBySetId[$attributeSetId][$attributeCode]['attribute_group_code'] = $group->getAttributeGroupCode();
Expand Down Expand Up @@ -414,14 +418,17 @@ public function process(
if (!isset($attributes[$attributeCode])) {
$attributes[$attributeCode] = $attribute;

// Collect all swatches (we will need additional data for them)
if ($isCollectOptions && $this->swatchHelper->isSwatchAttribute($attribute)) {
$swatchAttributes[] = $attributeCode;
}
}
}
}

foreach ($attributes as $attributeCode => $attribute) {
// Collect all swatches (we will need additional data for them)
if ($isCollectOptions && $this->swatchHelper->isSwatchAttribute($attribute)) {
$swatchAttributes[] = $attributeCode;
}
}

$this->appendWithGroup(
$attributes,
array_keys($attributesBySetId),
Expand Down

0 comments on commit 3cc3ca7

Please sign in to comment.