/** * ES field used in attribute autocomplete. * * @param \Magento\Catalog\Model\ResourceModel\Product\Attribute $attribute Attribute. * * @return string */ public function getAttributeAutocompleteField(\Magento\Catalog\Api\Data\ProductAttributeInterface $attribute) { $fieldName = $attribute->getAttributeCode(); if ($attribute->usesSource()) { $fieldName = $this->mappingHelper->getOptionTextFieldName($fieldName); } return $fieldName; }
/** * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context * @param array $config * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface */ public function create($attribute, $context, $config = []) { $columnName = $attribute->getAttributeCode(); $config = array_merge(['dataScope' => $columnName, 'label' => __($attribute->getDefaultFrontendLabel())], $config); if ($attribute->usesSource() && $attribute->getSourceModel()) { $config['options'] = $attribute->getSource()->getAllOptions(); $config['caption'] = __('Select...'); } $arguments = ['data' => ['config' => $config], 'context' => $context]; return $this->componentFactory->create($columnName, $this->getFilterType($attribute), $arguments); }