attribute_category.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxtitle', 'oxcategories', 1, 1, 0 ),
00005                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00006                                         array( 'oxid',    'oxcategories', 0, 0, 1 )
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle', 'oxcategories', 1, 1, 0 ),
00010                                         array( 'oxdesc',  'oxcategories', 1, 1, 0 ),
00011                                         array( 'oxid',    'oxcategory2attribute', 0, 0, 1 ),
00012                                         array( 'oxid',    'oxcategories', 0, 0, 1 )
00013                                         ),
00014                      'container3' => array(
00015                                         array( 'oxtitle', 'oxattribute', 1, 1, 0 ),
00016                                         array( 'oxsort',  'oxcategory2attribute', 1, 0, 0 ),
00017                                         array( 'oxid',    'oxcategory2attribute', 0, 0, 1 )
00018                                         )
00019                     );
00023 class ajaxComponent extends ajaxListComponent
00024 {
00030     protected function _getQuery()
00031     {
00032         $myConfig = $this->getConfig();
00033 
00034         $sCatTable = getViewName('oxcategories');
00035         $sDiscountId      = oxConfig::getParameter( 'oxid' );
00036         $sSynchDiscountId = oxConfig::getParameter( 'synchoxid' );
00037 
00038         // category selected or not ?
00039         if ( !$sDiscountId) {
00040             $sQAdd  = " from $sCatTable where $sCatTable.oxshopid = '".$myConfig->getShopId()."' ";
00041             $sQAdd .= " and $sCatTable.oxactive".oxLang::getInstance()->getLanguageTag()." = '1' ";
00042         } else {
00043             $sQAdd  = " from $sCatTable left join oxcategory2attribute on $sCatTable.oxid=oxcategory2attribute.oxobjectid ";
00044             $sQAdd .= " where oxcategory2attribute.oxattrid = '$sDiscountId' and $sCatTable.oxshopid = '".$myConfig->getShopId()."' ";
00045             $sQAdd .= " and $sCatTable.oxactive".oxLang::getInstance()->getLanguageTag()." = '1' ";
00046         }
00047 
00048         if ( $sSynchDiscountId && $sSynchDiscountId != $sDiscountId) {
00049             $sQAdd .= " and $sCatTable.oxid not in ( select $sCatTable.oxid from $sCatTable left join oxcategory2attribute on $sCatTable.oxid=oxcategory2attribute.oxobjectid ";
00050             $sQAdd .= " where oxcategory2attribute.oxattrid = '$sSynchDiscountId' and $sCatTable.oxshopid = '".$myConfig->getShopId()."' ";
00051             $sQAdd .= " and $sCatTable.oxactive".oxLang::getInstance()->getLanguageTag()." = '1' ) ";
00052         }
00053 
00054         return $sQAdd;
00055     }
00056 
00062     public function removecatfromattr()
00063     {
00064         $aChosenCat = $this->_getActionIds( 'oxcategory2attribute.oxid' );
00065         if ( oxConfig::getParameter( 'all' ) ) {
00066 
00067             $sQ = $this->_addFilter( "delete oxcategory2attribute.* ".$this->_getQuery() );
00068             oxDb::getDb()->Execute( $sQ );
00069 
00070         } elseif ( is_array( $aChosenCat ) ) {
00071             $sQ = "delete from oxcategory2attribute where oxcategory2attribute.oxid in ('" . implode( "', '", $aChosenCat ) . "') ";
00072             oxDb::getDb()->Execute( $sQ );
00073         }
00074     }
00075 
00081     public function addcattoattr()
00082     {
00083         $aAddCategory = $this->_getActionIds( 'oxcategories.oxid' );
00084         $soxId        = oxConfig::getParameter( 'synchoxid');
00085 
00086         $oAttribute   = oxNew( "oxattribute" );
00087         // adding
00088         if ( oxConfig::getParameter( 'all' ) ) {
00089             $sCatTable = getViewName('oxcategories');
00090             $aAddCategory = $this->_getAll( $this->_addFilter( "select $sCatTable.oxid ".$this->_getQuery() ) );
00091         }
00092 
00093         if ( $oAttribute->load( $soxId ) && is_array( $aAddCategory ) ) {
00094             foreach ($aAddCategory as $sAdd) {
00095                 $oNewGroup = oxNew( "oxbase" );
00096                 $oNewGroup->init( "oxcategory2attribute" );
00097                 $oNewGroup->oxcategory2attribute__oxobjectid = new oxField($sAdd);
00098                 $oNewGroup->oxcategory2attribute__oxattrid = new oxField($oAttribute->oxattribute__oxid->value);
00099                 $oNewGroup->oxcategory2attribute__oxsort   = new oxField( ( int ) oxDb::getDb()->getOne( "select max(oxsort) + 1 from oxcategory2attribute where oxobjectid = '$sAdd' " ) );
00100                 $oNewGroup->save();
00101             }
00102         }
00103     }
00104 
00105 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5