eavAttribute = $eavAttribute; $this->externalBuilder = $externalBuilder; } /** * @param array $documentData * @param int $storeId * @param array $context * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function map(array $documentData, $storeId, array $context = []) { $documents = []; $externalAttributeIds = []; foreach (array_keys($this->externalBuilder->getExtraValueFields()) as $attributeCode) { $externalAttributeIds[$attributeCode . '_value'] = $this->eavAttribute->getIdByCode(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode); } foreach ($documentData as $productId => $indexData) { foreach ($externalAttributeIds as $filterName => $attributeId) { if (isset($indexData[$attributeId])) { if (is_array($indexData[$attributeId])) { $value = isset($indexData[$attributeId][$productId]) ? $indexData[$attributeId][$productId] : ''; } else { $value = $indexData[$attributeId]; } $documents[$productId][$filterName] = $value; } } } return $documents; } }