private function addRelationData(&$parentData, $childAttributes, $relation)
    {
        $childAttributeCodes  = array_keys($childAttributes);
        $parentAttributeCodes = array_keys($parentData);

        if (!isset($parentData['children_attributes'])) {
            $parentData['children_attributes'] = ['indexed_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));
    }
private function addRelationData(&$parentData, $childAttributes, $relation)
    {
        $childAttributeCodes  = array_keys($childAttributes);
        $parentAttributeCodes = array_keys($parentData);

        if (!isset($parentData['children_attributes'])) {
            $parentData['children_attributes'] = ['indexed_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));
    }
private function addRelationData ( & $ parentData , $ childAttributes , $ relation ) { $ childAttributeCodes = array_keys ( $ childAttributes ) ; $ parentAttributeCodes = array_keys ( $ parentData ) ; if ( ! isset ( $ parentData [ 'children_attributes' ] ) ) { $ parentData [ 'children_attributes' ] = [ 'indexed_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 ) ) ; }
Append relation information to the index for composite products.

@param array $parentData      Parent product data.
@param array $childAttributes Child product attributes data.
@param array $relation        Relation data between the child and the parent.

@return void
Append relation information to the index for composite products .