article_bundle.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00005                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00006                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00007                                         array( 'oxmpn',    'oxarticles', 0, 0, 0 ),
00008                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00009                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00010                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00011                                         )
00012                     );
00016 class ajaxComponent extends ajaxListComponent
00017 {
00023     protected $_blAllowExtColumns = true;
00024 
00030     protected function _getQuery()
00031     {
00032         $myConfig      = $this->getConfig();
00033         $oDb           = oxDb::getDb();
00034         $sArticleTable = $this->_getViewName( 'oxarticles' );
00035         $sO2CView      = $this->_getViewName( 'oxobject2category' );
00036 
00037         $sSelId      = oxConfig::getParameter( 'oxid' );
00038         $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00039 
00040         // category selected or not ?
00041         if ( !$sSelId ) {
00042             $sQAdd  = " from $sArticleTable where 1 ";
00043             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00044         } else {
00045             // selected category ?
00046             if ( $sSynchSelId ) {
00047                 $sQAdd  = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00048                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00049                 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
00050             }
00051         }
00052         // #1513C/#1826C - skip references, to not existing articles
00053         $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00054 
00055         // skipping self from list
00056         $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSynchSelId ) . " ";
00057 
00058         return $sQAdd;
00059     }
00060 
00068     protected function _addFilter( $sQ )
00069     {
00070         $sArtTable = $this->_getViewName('oxarticles');
00071         $sQ = parent::_addFilter( $sQ );
00072 
00073         // display variants or not ?
00074         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00075         return $sQ;
00076     }
00077 
00083     public function removearticlebundle()
00084     {
00085         $aChosenArt = oxConfig::getParameter( 'oxid');
00086         $oDb        = oxDb::getDb();
00087 
00088         $sQ = "update oxarticles set oxarticles.oxbundleid = '' where oxarticles.oxid  =  " . $oDb->quote( $aChosenArt ) . " ";
00089         $oDb->Execute( $sQ );
00090     }
00091 
00097     public function addarticlebundle()
00098     {
00099         $sChosenArt = oxConfig::getParameter( 'oxbundleid' );
00100         $soxId      = oxConfig::getParameter( 'oxid' );
00101         $oDb        = oxDb::getDb();
00102 
00103         $sQ = "update oxarticles set oxarticles.oxbundleid =  " . $oDb->quote( $sChosenArt ) . " where oxarticles.oxid  =  " . $oDb->quote( $soxId ) . " ";
00104         $oDb->Execute( $sQ );
00105     }
00106 }