src/ShopBundle/mappers/article/TPkgShopMapper_ArticleTeaserBase.class.php
protected function GetVariantInfo($oArticle, $aData, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aColors = array();
        $aVariantTypeList = array();
        if ($oArticle->HasVariants()) {
            $oVariantSet = $oArticle->GetFieldShopVariantSet();
            if ($oVariantSet && $bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oVariantSet->table, $oVariantSet->id);
            }
            $oVariantTypes = $oVariantSet->GetFieldShopVariantTypeList();

            $bLoadInactiveItems = false;
            $oShop = TShop::GetInstance();
            if (property_exists($oShop, 'fieldLoadInactiveVariants') && $oShop->fieldLoadInactiveVariants) {
                $bLoadInactiveItems = true;
            }

            while ($oVariantType = $oVariantTypes->Next()) {
                if ($bCachingEnabled) {
                    $oCacheTriggerManager->addTrigger($oVariantType->table, $oVariantType->id);
                }

                if ($bLoadInactiveItems) {
                    $oAvailableValues = $oArticle->GetVariantValuesAvailableForTypeIncludingInActive($oVariantType);
                } else {
                    $oAvailableValues = $oArticle->GetVariantValuesAvailableForType($oVariantType);
                }

                if (!$oAvailableValues) {
                    continue;
                }
                if ('color' == $oVariantType->fieldIdentifier) {
                    while ($oValue = $oAvailableValues->Next()) {
                        if ($bCachingEnabled) {
                            $oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
                        }
                        $aColors[] = array(
                            'sLink' => $oValue->fieldUrlName,
                            'sHex' => '#'.$oValue->fieldColorCode,
                            'cms_media_id' => $oValue->fieldCmsMediaId,
                        );
                    }
                } else {
                    $aType = array(
                        'sTitle' => $oVariantType->fieldName,
                        'sSystemName' => $oVariantType->fieldIdentifier,
                        'cms_media_id' => $oVariantType->fieldCmsMediaId,
                        'aItems' => array(),
                        'bAllowSelection' => true,
                    );
                    $aItems = array();
                    while ($oValue = $oAvailableValues->Next()) {
                        if ($bCachingEnabled) {
                            $oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
                        }
                        $aItem = array(
                            'sTitle' => $oValue->fieldName,
                            'sColor' => $oValue->fieldColorCode,
                            'cms_media_id' => $oValue->fieldCmsMediaId,
                            'bIsActive' => false,  // currently selected article variant (shows activate state)
                            'bArticleIsActive' => '1',
                            'sSelectLink' => '',
                        );

                        if ($bLoadInactiveItems) {
                            if (isset($oValue->sqlData['articleactive']) && $oValue->sqlData['articleactive'] > 0) {
                                $aItem['bArticleIsActive'] = '1'; // if 0 the variant is not active and the variant values should be rendered as non-available
                            } else {
                                $aItem['bArticleIsActive'] = '0';
                            }
                        }

                        $aItems[] = $aItem;
                    }
                    $aType['aItems'] = $aItems;
                    $aVariantTypeList[] = $aType;
                }
            }
        }
        $aData['aColors'] = $aColors;
        $aData['aVariantTypes'] = $aVariantTypeList;

        return $aData;
    }
protected function GetVariantInfo($oArticle, $aData, IMapperCacheTriggerRestricted $oCacheTriggerManager, $bCachingEnabled)
    {
        $aColors = array();
        $aVariantTypeList = array();
        if ($oArticle->HasVariants()) {
            $oVariantSet = $oArticle->GetFieldShopVariantSet();
            if ($oVariantSet && $bCachingEnabled) {
                $oCacheTriggerManager->addTrigger($oVariantSet->table, $oVariantSet->id);
            }
            $oVariantTypes = $oVariantSet->GetFieldShopVariantTypeList();

            $bLoadInactiveItems = false;
            $oShop = TShop::GetInstance();
            if (property_exists($oShop, 'fieldLoadInactiveVariants') && $oShop->fieldLoadInactiveVariants) {
                $bLoadInactiveItems = true;
            }

            while ($oVariantType = $oVariantTypes->Next()) {
                if ($bCachingEnabled) {
                    $oCacheTriggerManager->addTrigger($oVariantType->table, $oVariantType->id);
                }

                if ($bLoadInactiveItems) {
                    $oAvailableValues = $oArticle->GetVariantValuesAvailableForTypeIncludingInActive($oVariantType);
                } else {
                    $oAvailableValues = $oArticle->GetVariantValuesAvailableForType($oVariantType);
                }

                if (!$oAvailableValues) {
                    continue;
                }
                if ('color' == $oVariantType->fieldIdentifier) {
                    while ($oValue = $oAvailableValues->Next()) {
                        if ($bCachingEnabled) {
                            $oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
                        }
                        $aColors[] = array(
                            'sLink' => $oValue->fieldUrlName,
                            'sHex' => '#'.$oValue->fieldColorCode,
                            'cms_media_id' => $oValue->fieldCmsMediaId,
                        );
                    }
                } else {
                    $aType = array(
                        'sTitle' => $oVariantType->fieldName,
                        'sSystemName' => $oVariantType->fieldIdentifier,
                        'cms_media_id' => $oVariantType->fieldCmsMediaId,
                        'aItems' => array(),
                        'bAllowSelection' => true,
                    );
                    $aItems = array();
                    while ($oValue = $oAvailableValues->Next()) {
                        if ($bCachingEnabled) {
                            $oCacheTriggerManager->addTrigger($oValue->table, $oValue->id);
                        }
                        $aItem = array(
                            'sTitle' => $oValue->fieldName,
                            'sColor' => $oValue->fieldColorCode,
                            'cms_media_id' => $oValue->fieldCmsMediaId,
                            'bIsActive' => false,  // currently selected article variant (shows activate state)
                            'bArticleIsActive' => '1',
                            'sSelectLink' => '',
                        );

                        if ($bLoadInactiveItems) {
                            if (isset($oValue->sqlData['articleactive']) && $oValue->sqlData['articleactive'] > 0) {
                                $aItem['bArticleIsActive'] = '1'; // if 0 the variant is not active and the variant values should be rendered as non-available
                            } else {
                                $aItem['bArticleIsActive'] = '0';
                            }
                        }

                        $aItems[] = $aItem;
                    }
                    $aType['aItems'] = $aItems;
                    $aVariantTypeList[] = $aType;
                }
            }
        }
        $aData['aColors'] = $aColors;
        $aData['aVariantTypes'] = $aVariantTypeList;

        return $aData;
    }
protected function GetVariantInfo ( $ oArticle , $ aData , IMapperCacheTriggerRestricted $ oCacheTriggerManager , $ bCachingEnabled ) { $ aColors = array ( ) ; $ aVariantTypeList = array ( ) ; if ( $ oArticle -> HasVariants ( ) ) { $ oVariantSet = $ oArticle -> GetFieldShopVariantSet ( ) ; if ( $ oVariantSet && $ bCachingEnabled ) { $ oCacheTriggerManager -> addTrigger ( $ oVariantSet -> table , $ oVariantSet -> id ) ; } $ oVariantTypes = $ oVariantSet -> GetFieldShopVariantTypeList ( ) ; $ bLoadInactiveItems = false ; $ oShop = TShop :: GetInstance ( ) ; if ( property_exists ( $ oShop , 'fieldLoadInactiveVariants' ) && $ oShop -> fieldLoadInactiveVariants ) { $ bLoadInactiveItems = true ; } while ( $ oVariantType = $ oVariantTypes -> Next ( ) ) { if ( $ bCachingEnabled ) { $ oCacheTriggerManager -> addTrigger ( $ oVariantType -> table , $ oVariantType -> id ) ; } if ( $ bLoadInactiveItems ) { $ oAvailableValues = $ oArticle -> GetVariantValuesAvailableForTypeIncludingInActive ( $ oVariantType ) ; } else { $ oAvailableValues = $ oArticle -> GetVariantValuesAvailableForType ( $ oVariantType ) ; } if ( ! $ oAvailableValues ) { continue ; } if ( 'color' == $ oVariantType -> fieldIdentifier ) { while ( $ oValue = $ oAvailableValues -> Next ( ) ) { if ( $ bCachingEnabled ) { $ oCacheTriggerManager -> addTrigger ( $ oValue -> table , $ oValue -> id ) ; } $ aColors [ ] = array ( 'sLink' => $ oValue -> fieldUrlName , 'sHex' => '#' . $ oValue -> fieldColorCode , 'cms_media_id' => $ oValue -> fieldCmsMediaId , ) ; } } else { $ aType = array ( 'sTitle' => $ oVariantType -> fieldName , 'sSystemName' => $ oVariantType -> fieldIdentifier , 'cms_media_id' => $ oVariantType -> fieldCmsMediaId , 'aItems' => array ( ) , 'bAllowSelection' => true , ) ; $ aItems = array ( ) ; while ( $ oValue = $ oAvailableValues -> Next ( ) ) { if ( $ bCachingEnabled ) { $ oCacheTriggerManager -> addTrigger ( $ oValue -> table , $ oValue -> id ) ; } $ aItem = array ( 'sTitle' => $ oValue -> fieldName , 'sColor' => $ oValue -> fieldColorCode , 'cms_media_id' => $ oValue -> fieldCmsMediaId , 'bIsActive' => false , // currently selected article variant (shows activate state) 'bArticleIsActive' => '1' , 'sSelectLink' => '' , ) ; if ( $ bLoadInactiveItems ) { if ( isset ( $ oValue -> sqlData [ 'articleactive' ] ) && $ oValue -> sqlData [ 'articleactive' ] > 0 ) { $ aItem [ 'bArticleIsActive' ] = '1' ; // if 0 the variant is not active and the variant values should be rendered as non-available } else { $ aItem [ 'bArticleIsActive' ] = '0' ; } } $ aItems [ ] = $ aItem ; } $ aType [ 'aItems' ] = $ aItems ; $ aVariantTypeList [ ] = $ aType ; } } } $ aData [ 'aColors' ] = $ aColors ; $ aData [ 'aVariantTypes' ] = $ aVariantTypeList ; return $ aData ; }
Add color variant data if available for article
Add all other available article variants in separate data.

@param TdbShopArticle                $oArticle
@param array                         $aData
@param IMapperCacheTriggerRestricted $oCacheTriggerManager
@param bool                          $bCachingEnabled

@return array
Add color variant data if available for article Add all other available article variants in separate data .