oxattributelist.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class oxAttributeList extends oxList
00007 {
00015     public function __construct( $sObjectsInListName = 'oxattribute')
00016     {
00017         parent::__construct( 'oxattribute');
00018     }
00019 
00027     public function loadAttributesByIds( $aIds)
00028     {
00029         if (!count($aIds)) {
00030             return;
00031         }
00032 
00033         foreach ($aIds as $iKey => $sVal) {
00034             $aIds[$iKey] = mysql_real_escape_string($sVal);
00035         }
00036 
00037         $sAttrViewName = getViewName( 'oxattribute' );
00038         $sLangAdd = oxLang::getInstance()->getLanguageTag();
00039         $sSelect  = "select $sAttrViewName.oxid, $sAttrViewName.oxtitle$sLangAdd, oxobject2attribute.oxvalue$sLangAdd, oxobject2attribute.oxobjectid ";
00040         $sSelect .= "from oxobject2attribute ";
00041         $sSelect .= "left join $sAttrViewName on $sAttrViewName.oxid = oxobject2attribute.oxattrid ";
00042         $sSelect .= "where oxobject2attribute.oxobjectid in ( '".implode("','", $aIds)."' ) ";
00043         $sSelect .= "order by oxobject2attribute.oxpos, $sAttrViewName.oxpos";
00044 
00045         return $this->_createAttributeListFromSql( $sSelect);
00046     }
00047 
00055     protected function _createAttributeListFromSql( $sSelect)
00056     {
00057         $aAttributes = array();
00058         $rs = oxDb::getDb()->Execute( $sSelect);
00059         if ($rs != false && $rs->recordCount() > 0) {
00060             while (!$rs->EOF) {
00061                 if ( !isset( $aAttributes[$rs->fields[0]])) {
00062                     $aAttributes[$rs->fields[0]] = new stdClass();
00063                 }
00064 
00065                 $aAttributes[$rs->fields[0]]->title = $rs->fields[1];
00066                 if ( !isset( $aAttributes[$rs->fields[0]]->aProd[$rs->fields[3]])) {
00067                     $aAttributes[$rs->fields[0]]->aProd[$rs->fields[3]] = new stdClass();
00068                 }
00069                 $aAttributes[$rs->fields[0]]->aProd[$rs->fields[3]]->value = $rs->fields[2];
00070                 $rs->moveNext();
00071             }
00072         }
00073         return $aAttributes;
00074     }
00075 
00083     public function loadAttributes( $sArtId)
00084     {
00085         if ( !$sArtId) {
00086             return;
00087         }
00088 
00089         $sSuffix = oxLang::getInstance()->getLanguageTag();
00090 
00091         $sAttrViewName = getViewName( 'oxattribute' );
00092         $sSelect  = "select $sAttrViewName.*, o2a.* ";
00093         $sSelect .= "from oxobject2attribute as o2a ";
00094         $sSelect .= "left join $sAttrViewName on $sAttrViewName.oxid = o2a.oxattrid ";
00095         $sSelect .= "where o2a.oxobjectid = '$sArtId' and o2a.oxvalue$sSuffix != '' ";
00096         $sSelect .= "order by o2a.oxpos, $sAttrViewName.oxpos";
00097 
00098         $this->selectString( $sSelect );
00099     }
00100 }

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5