Skip to content

Commit

Permalink
Merge pull request Smile-SA#119 from romainruaud/fix_null-query-relat…
Browse files Browse the repository at this point in the history
…ion-indexing

Ensure avoiding processing NULL query if there is no relations for in…
  • Loading branch information
afoucret authored Sep 19, 2016
2 parents 2f19598 + ebad188 commit 5d9cb80
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,19 @@ public function addData($storeId, array $indexData)
$indexData = $this->addAttributeData($storeId, $productIds, $indexData);

$relationsByChildId = $this->resourceModel->loadChildrens($productIds);
$allChildrenIds = array_keys($relationsByChildId);
$childrenIndexData = $this->addAttributeData($storeId, $allChildrenIds);

foreach ($relationsByChildId as $childId => $relations) {
foreach ($relations as $relation) {
$parentId = (int) $relation['parent_id'];
if (isset($indexData[$parentId]) && isset($childrenIndexData[$childId])) {
$indexData[$parentId]['children_ids'][] = $childId;
$this->addRelationData($indexData[$parentId], $childrenIndexData[$childId], $relation);
$this->addChildData($indexData[$parentId], $childrenIndexData[$childId]);

if (!empty($relationsByChildId)) {
$allChildrenIds = array_keys($relationsByChildId);
$childrenIndexData = $this->addAttributeData($storeId, $allChildrenIds);

foreach ($relationsByChildId as $childId => $relations) {
foreach ($relations as $relation) {
$parentId = (int) $relation['parent_id'];
if (isset($indexData[$parentId]) && isset($childrenIndexData[$childId])) {
$indexData[$parentId]['children_ids'][] = $childId;
$this->addRelationData($indexData[$parentId], $childrenIndexData[$childId], $relation);
$this->addChildData($indexData[$parentId], $childrenIndexData[$childId]);
}
}
}
}
Expand Down

0 comments on commit 5d9cb80

Please sign in to comment.