src/Callbacks/OptionValueAndSwatchHandler.php
protected function prepareAttributeOption($entityTypeId, $attributeCode)
    {

        // load the attribute ID
        $attribute = $this->loadAttributeByEntityTypeIdAndAttributeCode($entityTypeId, $attributeCode);

        // initialize the sort order
        $sortOrder = 0;

        // try to load the option with the highest sort order and raise it by one if available
        if ($attributeOption = $this->loadAttributeOptionByAttributeIdAndHighestSortOrder($attributeId = $attribute[MemberNames::ATTRIBUTE_ID])) {
            $sortOrder = (integer) $attributeOption[MemberNames::SORT_ORDER] + 1;
        }

        // return the prepared attribute option
        return $this->initializeEntity(
            array(
                MemberNames::ATTRIBUTE_ID => $attributeId,
                MemberNames::SORT_ORDER   => $sortOrder
            )
        );
    }
protected function prepareAttributeOption($entityTypeId, $attributeCode)
    {

        // load the attribute ID
        $attribute = $this->loadAttributeByEntityTypeIdAndAttributeCode($entityTypeId, $attributeCode);

        // initialize the sort order
        $sortOrder = 0;

        // try to load the option with the highest sort order and raise it by one if available
        if ($attributeOption = $this->loadAttributeOptionByAttributeIdAndHighestSortOrder($attributeId = $attribute[MemberNames::ATTRIBUTE_ID])) {
            $sortOrder = (integer) $attributeOption[MemberNames::SORT_ORDER] + 1;
        }

        // return the prepared attribute option
        return $this->initializeEntity(
            array(
                MemberNames::ATTRIBUTE_ID => $attributeId,
                MemberNames::SORT_ORDER   => $sortOrder
            )
        );
    }
Prepare the attributes of the entity that has to be persisted.

@param integer $entityTypeId  The entity type ID of the option
@param string  $attributeCode The attribute code of the option

@return array The prepared option