PHP Class Smile\ElasticsuiteCatalog\Helper\Attribute

Author: Aurelien FOUCRET ([email protected])
Inheritance: extends Smile\ElasticsuiteCore\Helper\Mapping
Show file Open project: smile-sa/elasticsuite Class Usage Examples

Public Methods

Method Description
__construct ( Magento\Framework\App\Helper\Context $context, Magento\Framework\ObjectManagerInterface $objectManager, Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory, string $collectionFactory )
getAttributeCollection ( ) : Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection Retrieve a new product attribute collection.
getFieldType ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute ) : string Get mapping field type for an attribute.
getIndexOptionText ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, string | integer $optionId ) : string | boolean Transform an options id into an array of option value for attribute that uses a source.
getIndexOptionsText ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, array $optionIds ) : array Transform an array of options ids into an arrays of option values for attribute that uses a source.
getMappingFieldOptions ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute ) : array Parse attribute to get mapping field creation parameters.
prepareIndexValue ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, mixed $value ) : array Parse attribute raw value (as saved in the database) to prepare the indexed value.

Private Methods

Method Description
getAttributeByStore ( Magento\Eav\Model\Entity\Attribute\AttributeInterface | integer $attribute, integer $storeId ) : Magento\Catalog\Api\Data\EavAttributeInterface Load the localized version of an attribute.
getAttributeId ( Magento\Eav\Model\Entity\Attribute\AttributeInterface | integer $attribute ) : integer This util method is used to ensure the attribute is an integer and uses it's id if it is an object.
prepareSimpleIndexAttributeValue ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, mixed $value ) : mixed Ensure types of numerical values is correct before indexing.

Method Details

__construct() public method

public __construct ( Magento\Framework\App\Helper\Context $context, Magento\Framework\ObjectManagerInterface $objectManager, Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory, string $collectionFactory )
$context Magento\Framework\App\Helper\Context Helper context.
$objectManager Magento\Framework\ObjectManagerInterface The object manager
$attributeFactory Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory Factory used to create attributes.
$collectionFactory string Factory class name to use for create attribute collections.

getAttributeCollection() public method

Retrieve a new product attribute collection.
public getAttributeCollection ( ) : Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection
return Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection

getFieldType() public method

Get mapping field type for an attribute.
public getFieldType ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute ) : string
$attribute Magento\Eav\Model\Entity\Attribute\AttributeInterface Product attribute.
return string

getIndexOptionText() public method

Value islocalized for a store id.
public getIndexOptionText ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, string | integer $optionId ) : string | boolean
$attribute Magento\Eav\Model\Entity\Attribute\AttributeInterface Product attribute.
$storeId integer Store id.
$optionId string | integer Option id.
return string | boolean

getIndexOptionsText() public method

Values are localized for a store id.
public getIndexOptionsText ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, array $optionIds ) : array
$attribute Magento\Eav\Model\Entity\Attribute\AttributeInterface Product attribute.
$storeId integer Store id
$optionIds array Array of options ids.
return array

getMappingFieldOptions() public method

Parse attribute to get mapping field creation parameters.
public getMappingFieldOptions ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute ) : array
$attribute Magento\Eav\Model\Entity\Attribute\AttributeInterface Product attribute.
return array

prepareIndexValue() public method

For attribute using options the option value is also added to the result which contains two keys : - one is "attribute_code" and contained the option id(s) - the other one is "option_text_attribute_code" and contained option value(s) All value are transformed into arays to have a more simple management of multivalued attributes merging on composite products). ES doesn't care of having array of int when it an int is required.
public prepareIndexValue ( Magento\Eav\Model\Entity\Attribute\AttributeInterface $attribute, integer $storeId, mixed $value ) : array
$attribute Magento\Eav\Model\Entity\Attribute\AttributeInterface Product attribute.
$storeId integer Store id.
$value mixed Raw value to be parsed.
return array