article_bundle_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class article_bundle_ajax extends ajaxListComponent
00007 {
00013     protected $_blAllowExtColumns = true;
00014     
00020     protected $_aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00021                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00022                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00023                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00024                                         array( 'oxmpn',    'oxarticles', 0, 0, 0 ),
00025                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00026                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00027                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00028                                         )
00029                                 );
00030 
00036     protected function _getQuery()
00037     {
00038         $myConfig      = $this->getConfig();
00039         $oDb           = oxDb::getDb();
00040         $sArticleTable = $this->_getViewName( 'oxarticles' );
00041         $sO2CView      = $this->_getViewName( 'oxobject2category' );
00042 
00043         $sSelId      = oxConfig::getParameter( 'oxid' );
00044         $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00045 
00046         // category selected or not ?
00047         if ( !$sSelId ) {
00048             $sQAdd  = " from $sArticleTable where 1 ";
00049             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00050         } else {
00051             // selected category ?
00052             if ( $sSynchSelId ) {
00053                 $sQAdd  = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00054                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00055                 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
00056             }
00057         }
00058         // #1513C/#1826C - skip references, to not existing articles
00059         $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00060 
00061         // skipping self from list
00062         $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSynchSelId ) . " ";
00063 
00064         return $sQAdd;
00065     }
00066 
00074     protected function _addFilter( $sQ )
00075     {
00076         $sArtTable = $this->_getViewName('oxarticles');
00077         $sQ = parent::_addFilter( $sQ );
00078 
00079         // display variants or not ?
00080         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00081         return $sQ;
00082     }
00083 
00089     public function removeArticleBundle()
00090     {
00091         $aChosenArt = oxConfig::getParameter( 'oxid');
00092         $oDb        = oxDb::getDb();
00093 
00094         $sQ = "update oxarticles set oxarticles.oxbundleid = '' where oxarticles.oxid  =  " . $oDb->quote( $aChosenArt ) . " ";
00095         $oDb->Execute( $sQ );
00096     }
00097 
00103     public function addArticleBundle()
00104     {
00105         $sChosenArt = oxConfig::getParameter( 'oxbundleid' );
00106         $soxId      = oxConfig::getParameter( 'oxid' );
00107         $oDb        = oxDb::getDb();
00108 
00109         $sQ = "update oxarticles set oxarticles.oxbundleid =  " . $oDb->quote( $sChosenArt ) . " where oxarticles.oxid  =  " . $oDb->quote( $soxId ) . " ";
00110         $oDb->Execute( $sQ );
00111     }
00112 }