src/ShopBundle/objects/db/TShopArticle.class.php
public function GetVariantFromValues($aTypeValuePairs)
    {
        $oArticle = null;
        if (!$this->IsVariant()) {
            $query = "SELECT `shop_article`.*
                    FROM `shop_article`
              INNER JOIN `shop_article_shop_variant_type_value_mlt` ON `shop_article`.`id` = `shop_article_shop_variant_type_value_mlt`.`source_id`
              INNER 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)."'
                 ";
            $aParts = array();
            foreach ($aTypeValuePairs as $sVariantTypeId => $sVariantTypeValueId) {
                $aParts[] = "`shop_variant_type_value`.`shop_variant_type_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sVariantTypeId)."' AND `shop_variant_type_value`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sVariantTypeValueId)."'";
            }
            $query .= ' AND ('.implode(') OR (', $aParts).')';
            $query .= ' GROUP BY `shop_article`.`id`';
            $query .= ' HAVING COUNT(`shop_article`.`id`) = '.MySqlLegacySupport::getInstance()->real_escape_string(count($aParts));
            $query .= ' ORDER BY `shop_article`.`active` DESC'; //we want the active article if multiple present
            if ($aMatch = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
                $oArticle = TdbShopArticle::GetNewInstance();
                $oArticle->LoadFromRow($aMatch);
            }
        }

        return $oArticle;
    }
public function GetVariantFromValues($aTypeValuePairs)
    {
        $oArticle = null;
        if (!$this->IsVariant()) {
            $query = "SELECT `shop_article`.*
                    FROM `shop_article`
              INNER JOIN `shop_article_shop_variant_type_value_mlt` ON `shop_article`.`id` = `shop_article_shop_variant_type_value_mlt`.`source_id`
              INNER 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)."'
                 ";
            $aParts = array();
            foreach ($aTypeValuePairs as $sVariantTypeId => $sVariantTypeValueId) {
                $aParts[] = "`shop_variant_type_value`.`shop_variant_type_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sVariantTypeId)."' AND `shop_variant_type_value`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sVariantTypeValueId)."'";
            }
            $query .= ' AND ('.implode(') OR (', $aParts).')';
            $query .= ' GROUP BY `shop_article`.`id`';
            $query .= ' HAVING COUNT(`shop_article`.`id`) = '.MySqlLegacySupport::getInstance()->real_escape_string(count($aParts));
            $query .= ' ORDER BY `shop_article`.`active` DESC'; //we want the active article if multiple present
            if ($aMatch = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
                $oArticle = TdbShopArticle::GetNewInstance();
                $oArticle->LoadFromRow($aMatch);
            }
        }

        return $oArticle;
    }
public function GetVariantFromValues ( $ aTypeValuePairs ) { $ oArticle = null ; if ( ! $ this -> IsVariant ( ) ) { $ query = "SELECT `shop_article`.*
                    FROM `shop_article`
              INNER JOIN `shop_article_shop_variant_type_value_mlt` ON `shop_article`.`id` = `shop_article_shop_variant_type_value_mlt`.`source_id`
              INNER 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 ) . "'
                 " ; $ aParts = array ( ) ; foreach ( $ aTypeValuePairs as $ sVariantTypeId => $ sVariantTypeValueId ) { $ aParts [ ] = "`shop_variant_type_value`.`shop_variant_type_id` = '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ sVariantTypeId ) . "' AND `shop_variant_type_value`.`id` = '" . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( $ sVariantTypeValueId ) . "'" ; } $ query .= ' AND (' . implode ( ') OR (' , $ aParts ) . ')' ; $ query .= ' GROUP BY `shop_article`.`id`' ; $ query .= ' HAVING COUNT(`shop_article`.`id`) = ' . MySqlLegacySupport :: getInstance ( ) -> real_escape_string ( count ( $ aParts ) ) ; $ query .= ' ORDER BY `shop_article`.`active` DESC' ; //we want the active article if multiple present if ( $ aMatch = MySqlLegacySupport :: getInstance ( ) -> fetch_assoc ( MySqlLegacySupport :: getInstance ( ) -> query ( $ query ) ) ) { $ oArticle = TdbShopArticle :: GetNewInstance ( ) ; $ oArticle -> LoadFromRow ( $ aMatch ) ; } } return $ oArticle ; }
return the variant matching the shop_variant_type_value paris.

@param array $aTypeValuePairs

@return TdbShopArticle
return the variant matching the shop_variant_type_value paris .