Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\AttributeList::getField PHP Method

getField() public method

Retrieve the mapping field for the rule attribute.
public getField ( string $attributeName ) : Smile\ElasticsuiteCore\Api\Index\Mapping\FieldInterface
$attributeName string Attribute code.
return Smile\ElasticsuiteCore\Api\Index\Mapping\FieldInterface
    public function getField($attributeName)
    {
        if (isset($this->fieldNameMapping[$attributeName])) {
            $attributeName = $this->fieldNameMapping[$attributeName];
        }
        return $this->getMapping()->getField($attributeName);
    }

Usage Example

Example #1
0
 /**
  * Retrieve ES mapping field name used for the current condition (including analyzer).
  *
  * @param ProductCondition $productCondition Product condition.
  *
  * @return string
  */
 private function getSearchFieldName(ProductCondition $productCondition)
 {
     $attributeName = $productCondition->getAttribute();
     $field = $this->attributeList->getField($attributeName);
     $analyzer = FieldInterface::ANALYZER_UNTOUCHED;
     if ($productCondition->getInputType() === "string") {
         $analyzer = FieldInterface::ANALYZER_STANDARD;
     }
     return $field->getMappingProperty($analyzer);
 }