src/Callbacks/SwatchTypeLoader.php
public function loadSwatchType($entityTypeId, $attributeCode)
    {

        // prepare a unique key for the swatch type from the given code and entity type ID
        $key = sprintf('%d-%s', $entityTypeId, $attributeCode);

        // query whether or not a swatch type has been set
        if ($this->hasSwatchType($key) === false) {
            // load the attribute and the catalog attribute data
            $attribute = $this->loadAttributeByEntityTypeIdAndAttributeCode($entityTypeId, $attributeCode);
            $catalogAttribute = $this->loadCatalogAttribute($attribute[MemberNames::ATTRIBUTE_ID]);

            // query whether or not additional data is available (to figure out if the attribute is a swatch type or not)
            if (is_array($catalogAttribute[MemberNames::ADDITIONAL_DATA]) && $catalogAttribute[MemberNames::ADDITIONAL_DATA] !== null) {
                // unserialize the additional data
                $additionalData = json_decode($catalogAttribute[MemberNames::ADDITIONAL_DATA]);
                // load and return the swatch type (can be either one of 'text' or 'visual')
                return $this->setSwatchType($key, $additionalData[CatalogAttributeObserver::SWATCH_INPUT_TYPE]);
            }
        }

        // return the actual swatch type
        return $this->getSwatchType($key);
    }
public function loadSwatchType($entityTypeId, $attributeCode)
    {

        // prepare a unique key for the swatch type from the given code and entity type ID
        $key = sprintf('%d-%s', $entityTypeId, $attributeCode);

        // query whether or not a swatch type has been set
        if ($this->hasSwatchType($key) === false) {
            // load the attribute and the catalog attribute data
            $attribute = $this->loadAttributeByEntityTypeIdAndAttributeCode($entityTypeId, $attributeCode);
            $catalogAttribute = $this->loadCatalogAttribute($attribute[MemberNames::ATTRIBUTE_ID]);

            // query whether or not additional data is available (to figure out if the attribute is a swatch type or not)
            if (is_array($catalogAttribute[MemberNames::ADDITIONAL_DATA]) && $catalogAttribute[MemberNames::ADDITIONAL_DATA] !== null) {
                // unserialize the additional data
                $additionalData = json_decode($catalogAttribute[MemberNames::ADDITIONAL_DATA]);
                // load and return the swatch type (can be either one of 'text' or 'visual')
                return $this->setSwatchType($key, $additionalData[CatalogAttributeObserver::SWATCH_INPUT_TYPE]);
            }
        }

        // return the actual swatch type
        return $this->getSwatchType($key);
    }
Returns the swatch type for the attribute with the passed code and entity type ID.

@param integer $entityTypeId  The entity type ID of the EAV attribute to return the swatch type for
@param string  $attributeCode The attribute code

@return string|null The swatch type (either one of 'text' or 'visual') or NULL, if the attribute is NOT a swatch type