Smile\ElasticsuiteCatalog\Model\Product\Indexer\Fulltext\Datasource\AttributeData::addRelationData PHP Method

addRelationData() private method

Append relation information to the index for composite products.
private addRelationData ( array &$parentData, array $childAttributes, array $relation ) : void
$parentData array Parent product data.
$childAttributes array Child product attributes data.
$relation array Relation data between the child and the parent.
return void
    private function addRelationData(&$parentData, $childAttributes, $relation)
    {
        $childAttributeCodes = array_keys($childAttributes);
        $parentAttributeCodes = array_keys($parentData);
        if (!isset($parentData['children_attributes'])) {
            $parentData['children_attributes'] = [];
        }
        $childrenAttributes = array_merge($parentData['children_attributes'], array_diff($childAttributeCodes, $this->forbidenChildrenAttributeCode));
        if (isset($relation['configurable_attributes']) && !empty($relation['configurable_attributes'])) {
            $addedChildrenAttributes = array_diff($childAttributeCodes, $this->forbidenChildrenAttributeCode, $parentAttributeCodes);
            $childrenAttributes = array_merge($addedChildrenAttributes, $parentData['children_attributes']);
            if (!isset($parentData['configurable_attributes'])) {
                $parentData['configurable_attributes'] = [];
            }
            $configurableAttributesCodes = array_map(function ($attributeId) {
                if (isset($this->attributesById[(int) $attributeId])) {
                    return $this->attributesById[(int) $attributeId]->getAttributeCode();
                }
            }, $relation['configurable_attributes']);
            $parentData['configurable_attributes'] = array_values(array_unique(array_merge($configurableAttributesCodes, $parentData['configurable_attributes'])));
        }
        $parentData['children_attributes'] = array_values(array_unique($childrenAttributes));
    }