src/Callbacks/AbstractMultiselectCallback.php
/**
     * Will be invoked by a observer it has been registered for.
     *
     * @param \TechDivision\Import\Observers\AttributeCodeAndValueAwareObserverInterface|null $observer The observer
     *
     * @return mixed The modified value
     */
Will be invoked by a observer it has been registered for.

@return mixed The modified value
Will be invoked by a observer it has been registered for . @return mixed The modified value
public function handle(AttributeCodeAndValueAwareObserverInterface $observer = null)
    {
        $this->setObserver($observer);
        $attributeCode = $observer->getAttributeCode();
        $attributeValue = $observer->getAttributeValue();
        if ($attributeValue == null || $attributeValue === '') {
            return;
        }
        $storeId = $this->getStoreId(StoreViewCodes::ADMIN);
        $vals = $this->explode($attributeValue);
        $mappedValues = array();
        foreach ($vals as $val) {
            if ($eavAttributeOptionValue = $this->loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($this->getEntityTypeId(), $attributeCode, $storeId, $val)) {
                $mappedValues[] = $eavAttributeOptionValue[MemberNames::OPTION_ID];
                continue;
            }
            if ($this->isDebugMode()) {
                $this->getSystemLogger()->warning(
                    $this->appendExceptionSuffix(
                        sprintf(
                            'Can\'t find multiselect option value "%s" for attribute "%s"',
                            $val,
                            $attributeCode
                        )
                    )
                );
                $this->mergeAttributesRecursive(
                    array(
                        RegistryKeys::MISSING_OPTION_VALUES => array(
                            $attributeCode => array(
                                $val => array(
                                    $this->raiseCounter($val),
                                    array($this->getUniqueIdentifier() => true)
                                )
                            )
                        )
                    )
                );
                continue;
            }
            throw new \Exception(
                $this->appendExceptionSuffix(
                    sprintf(
                        'Can\'t find multiselect option value "%s" for attribute "%s"',
                        $val,
                        $attributeCode
                    )
                )
            );
        }
        if (sizeof($mappedValues) === 0) {
            return;
        }
        return implode(',', $mappedValues);
    }
public function handle ( AttributeCodeAndValueAwareObserverInterface $ observer = null ) { $ this -> setObserver ( $ observer ) ; $ attributeCode = $ observer -> getAttributeCode ( ) ; $ attributeValue = $ observer -> getAttributeValue ( ) ; if ( $ attributeValue == null || $ attributeValue === '' ) { return ; } $ storeId = $ this -> getStoreId ( StoreViewCodes :: ADMIN ) ; $ vals = $ this -> explode ( $ attributeValue ) ; $ mappedValues = array ( ) ; foreach ( $ vals as $ val ) { if ( $ eavAttributeOptionValue = $ this -> loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue ( $ this -> getEntityTypeId ( ) , $ attributeCode , $ storeId , $ val ) ) { $ mappedValues [ ] = $ eavAttributeOptionValue [ MemberNames :: OPTION_ID ] ; continue ; } if ( $ this -> isDebugMode ( ) ) { $ this -> getSystemLogger ( ) -> warning ( $ this -> appendExceptionSuffix ( sprintf ( 'Can\'t find multiselect option value "%s" for attribute "%s"' , $ val , $ attributeCode ) ) ) ; $ this -> mergeAttributesRecursive ( array ( RegistryKeys :: MISSING_OPTION_VALUES => array ( $ attributeCode => array ( $ val => array ( $ this -> raiseCounter ( $ val ) , array ( $ this -> getUniqueIdentifier ( ) => true ) ) ) ) ) ) ; continue ; } throw new \ Exception ( $ this -> appendExceptionSuffix ( sprintf ( 'Can\'t find multiselect option value "%s" for attribute "%s"' , $ val , $ attributeCode ) ) ) ; } if ( sizeof ( $ mappedValues ) === 0 ) { return ; } return implode ( ',' , $ mappedValues ) ; }
Will be invoked by a observer it has been registered for.
Will be invoked by a observer it has been registered for .
// set the observer // load the attribute code and value // query whether or not a value for the attibute with the diven code has been set // load the ID of the actual store // explode the multiselect values // initialize the array for the mapped values // convert the option values into option value ID's // try to load the attribute option value and add the option ID // query whether or not we're in debug mode // log a warning and continue with the next value // add the missing option value to the registry // continue with the next option value // throw an exception if the attribute is not available // return NULL, if NO value can be mapped to an option // re-concatenate and return the values