src/ShopBundle/objects/db/TShopArticle.class.php
public function &GetFieldShopArticleVariantsList($aSelectedTypeValues = array(), $bLoadOnlyActive = true)
    {
        $sKey = 'oFieldShopArticleVariantsList'.serialize($aSelectedTypeValues);
        if ($bLoadOnlyActive) {
            $sKey .= 'active';
        } else {
            $sKey .= 'inactive';
        }
        $oVariantList = &$this->GetFromInternalCache($sKey);
        if (is_null($oVariantList)) {
            if (count($aSelectedTypeValues) > 0) {
                $query = "SELECT `shop_article`.*
                      FROM `shop_article`
                 LEFT JOIN `shop_article_shop_variant_type_value_mlt` ON `shop_article`.`id` = `shop_article_shop_variant_type_value_mlt`.`source_id`
                 LEFT JOIN `shop_variant_type_value` ON `shop_article_shop_variant_type_value_mlt`.`target_id` = `shop_variant_type_value`.`id`
                     WHERE `shop_article`.`variant_parent_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
                   ";
                $aRestriction = array();
                foreach ($aSelectedTypeValues as $sShopVariantTypeId => $sShopVariantTypeValueId) {
                    $aRestriction[] = "(`shop_variant_type_value`.`shop_variant_type_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sShopVariantTypeId)."' AND `shop_variant_type_value`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sShopVariantTypeValueId)."')";
                }
                $query .= ' AND ('.implode(' OR ', $aRestriction).')';

                if ($bLoadOnlyActive) {
                    $sActiveArticleRestriction = TdbShopArticleList::GetActiveArticleQueryRestriction(false);
                    if (!empty($sActiveArticleRestriction)) {
                        $query .= ' AND ('.$sActiveArticleRestriction.')';
                    }
                }
                $query .= ' GROUP BY `shop_article`.`id` HAVING COUNT(`shop_article`.`id`) = '.count($aSelectedTypeValues);
                $oVariantList = TdbShopArticleList::GetList($query);
            } else {
                $query = "SELECT `shop_article`.*
                      FROM `shop_article`
                     WHERE `shop_article`.`variant_parent_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
                   ";
                if ($bLoadOnlyActive) {
                    $sActiveArticleRestriction = TdbShopArticleList::GetActiveArticleQueryRestriction(false);
                    if (!empty($sActiveArticleRestriction)) {
                        $query .= ' AND ('.$sActiveArticleRestriction.')';
                    }
                }
                $oVariantList = TdbShopArticleList::GetList($query);
            }

            $oVariantList->bAllowItemCache = true;
            $this->SetInternalCache($sKey, $oVariantList);
        }
        $oVariantList->GoToStart();

        return $oVariantList;
    }
public function &GetFieldShopArticleVariantsList($aSelectedTypeValues = array(), $bLoadOnlyActive = true)
    {
        $sKey = 'oFieldShopArticleVariantsList'.serialize($aSelectedTypeValues);
        if ($bLoadOnlyActive) {
            $sKey .= 'active';
        } else {
            $sKey .= 'inactive';
        }
        $oVariantList = &$this->GetFromInternalCache($sKey);
        if (is_null($oVariantList)) {
            if (count($aSelectedTypeValues) > 0) {
                $query = "SELECT `shop_article`.*
                      FROM `shop_article`
                 LEFT JOIN `shop_article_shop_variant_type_value_mlt` ON `shop_article`.`id` = `shop_article_shop_variant_type_value_mlt`.`source_id`
                 LEFT JOIN `shop_variant_type_value` ON `shop_article_shop_variant_type_value_mlt`.`target_id` = `shop_variant_type_value`.`id`
                     WHERE `shop_article`.`variant_parent_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
                   ";
                $aRestriction = array();
                foreach ($aSelectedTypeValues as $sShopVariantTypeId => $sShopVariantTypeValueId) {
                    $aRestriction[] = "(`shop_variant_type_value`.`shop_variant_type_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sShopVariantTypeId)."' AND `shop_variant_type_value`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sShopVariantTypeValueId)."')";
                }
                $query .= ' AND ('.implode(' OR ', $aRestriction).')';

                if ($bLoadOnlyActive) {
                    $sActiveArticleRestriction = TdbShopArticleList::GetActiveArticleQueryRestriction(false);
                    if (!empty($sActiveArticleRestriction)) {
                        $query .= ' AND ('.$sActiveArticleRestriction.')';
                    }
                }
                $query .= ' GROUP BY `shop_article`.`id` HAVING COUNT(`shop_article`.`id`) = '.count($aSelectedTypeValues);
                $oVariantList = TdbShopArticleList::GetList($query);
            } else {
                $query = "SELECT `shop_article`.*
                      FROM `shop_article`
                     WHERE `shop_article`.`variant_parent_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
                   ";
                if ($bLoadOnlyActive) {
                    $sActiveArticleRestriction = TdbShopArticleList::GetActiveArticleQueryRestriction(false);
                    if (!empty($sActiveArticleRestriction)) {
                        $query .= ' AND ('.$sActiveArticleRestriction.')';
                    }
                }
                $oVariantList = TdbShopArticleList::GetList($query);
            }

            $oVariantList->bAllowItemCache = true;
            $this->SetInternalCache($sKey, $oVariantList);
        }
        $oVariantList->GoToStart();

        return $oVariantList;
    }
public function & GetFieldShopArticleVariantsList ( $ aSelectedTypeValues = array ( ) , $ bLoadOnlyActive = true ) { $ sKey = 'oFieldShopArticleVariantsList' . serialize ( $ aSelectedTypeValues ) ; if ( $ bLoadOnlyActive ) { $ sKey .= 'active' ; } else { $ sKey .= 'inactive' ; } $ oVariantList = & $ this -> GetFromInternalCache ( $ sKey ) ; if ( is_null ( $ oVariantList ) ) { if ( count ( $ aSelectedTypeValues ) > 0 ) { $ query = "SELECT `shop_article`.*
                      FROM `shop_article`
                 LEFT JOIN `shop_article_shop_variant_type_value_mlt` ON `shop_article`.`id` = `shop_article_shop_variant_type_value_mlt`.`source_id`
                 LEFT JOIN `shop_variant_type_value` ON `shop_article_shop_variant_type_value_mlt`.`target_id` = `shop_variant_type_value`.`id`
                     WHERE `shop_article`.`variant_parent_id` = '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ this -> id ) . "'
                   " ; $ aRestriction = array ( ) ; foreach ( $ aSelectedTypeValues as $ sShopVariantTypeId => $ sShopVariantTypeValueId ) { $ aRestriction [ ] = "(`shop_variant_type_value`.`shop_variant_type_id` = '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ sShopVariantTypeId ) . "' AND `shop_variant_type_value`.`id` = '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ sShopVariantTypeValueId ) . "')" ; } $ query .= ' AND (' . implode ( ' OR ' , $ aRestriction ) . ')' ; if ( $ bLoadOnlyActive ) { $ sActiveArticleRestriction = TdbShopArticleList :: GetActiveArticleQueryRestriction ( false ) ; if ( ! empty ( $ sActiveArticleRestriction ) ) { $ query .= ' AND (' . $ sActiveArticleRestriction . ')' ; } } $ query .= ' GROUP BY `shop_article`.`id` HAVING COUNT(`shop_article`.`id`) = ' . count ( $ aSelectedTypeValues ) ; $ oVariantList = TdbShopArticleList :: GetList ( $ query ) ; } else { $ query = "SELECT `shop_article`.*
                      FROM `shop_article`
                     WHERE `shop_article`.`variant_parent_id` = '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ this -> id ) . "'
                   " ; if ( $ bLoadOnlyActive ) { $ sActiveArticleRestriction = TdbShopArticleList :: GetActiveArticleQueryRestriction ( false ) ; if ( ! empty ( $ sActiveArticleRestriction ) ) { $ query .= ' AND (' . $ sActiveArticleRestriction . ')' ; } } $ oVariantList = TdbShopArticleList :: GetList ( $ query ) ; } $ oVariantList -> bAllowItemCache = true ; $ this -> SetInternalCache ( $ sKey , $ oVariantList ) ; } $ oVariantList -> GoToStart ( ) ; return $ oVariantList ; }
load list of article variants.

@param array $aSelectedTypeValues - restrict list to values matching this preselection (format: array(shop_variant_type_id=>shop_variant_type_value_id,...)
@param bool  $bLoadOnlyActive

@return TdbShopArticleList
load list of article variants .