[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: attributeManagerInstant.class.php,v 1.0 21/02/06 Sam West$ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Released under the GNU General Public License 9 10 Copyright © 2006 Kangaroo Partners 11 http://kangaroopartners.com 12 [email protected] 13 */ 14 15 class attributeManagerInstant extends attributeManager { 16 17 /** 18 * @access private 19 */ 20 var $intPID; 21 22 /** 23 * __construct() assigns pid, calls the parent construct, registers page actions 24 * @access public 25 * @author Sam West aka Nimmit - [email protected] 26 * @param $intPID int 27 * @return void 28 */ 29 function attributeManagerInstant($intPID) { 30 31 parent::attributeManager(); 32 33 $this->intPID = (int)$intPID; 34 35 $this->registerPageAction('addAttributeToProduct','addAttributeToProduct'); 36 $this->registerPageAction('addOptionValueToProduct','addOptionValueToProduct'); 37 $this->registerPageAction('addNewOptionValueToProduct','addNewOptionValueToProduct'); 38 $this->registerPageAction('removeOptionFromProduct','removeOptionFromProduct'); 39 $this->registerPageAction('removeOptionValueFromProduct','removeOptionValueFromProduct'); 40 // QT Pro Plugin 41 $this->registerPageAction('RemoveStockOptionValueFromProduct','RemoveStockOptionValueFromProduct'); 42 $this->registerPageAction('AddStockToProduct','AddStockToProduct'); 43 // QT Pro Plugin 44 $this->registerPageAction('update','update'); 45 $this->registerPageAction('updateProductStockQuantity','updateProductStockQuantity'); 46 47 if(AM_USE_SORT_ORDER) { 48 $this->registerPageAction('moveOption','moveOption'); 49 $this->registerPageAction('moveOptionValue','moveOptionValue'); 50 } 51 52 //---------------------------- 53 // Change: Add download attributes function for AM 54 // @author Urs Nyffenegger ak mytool 55 // Function: register PageActions for Download options 56 //----------------------------- 57 58 $this->registerPageAction('addDownloadAttributeToProduct','addDownloadAttributeToProduct'); 59 $this->registerPageAction('updateDownloadAttributeToProduct','updateDownloadAttributeToProduct'); 60 $this->registerPageAction('removeDownloadAttributeToProduct','removeDownloadAttributeToProduct'); 61 //---------------------------- 62 // EOF Change: download attributes for AM 63 //----------------------------- 64 65 66 } 67 68 //----------------------------------------------- page actions 69 70 /** 71 * Adds the selected attribute to the current product 72 * @access public 73 * @author Sam West aka Nimmit - [email protected] 74 * @param $get $_GET 75 * @return void 76 */ 77 function addAttributeToProduct($get) { 78 79 $this->getAndPrepare('option_id', $get, $optionId); 80 $this->getAndPrepare('option_value_id', $get, $optionValueId); 81 $this->getAndPrepare('price', $get, $price); 82 $this->getAndPrepare('prefix', $get, $prefix); 83 $this->getAndPrepare('sortOrder', $get, $sortOrder); 84 85 if((empty($price))||($price=='0')){ 86 $price='0.0000'; 87 }else{ 88 if((empty($prefix))||($prefix==' ')){ 89 $prefix='+'; 90 } 91 } 92 if(empty($prefix)){ 93 $prefix=' '; 94 } 95 96 $data = array( 97 'products_id' => $this->intPID, 98 'options_id' => $optionId, 99 'options_values_id' => $optionValueId, 100 'options_values_price' => $price, 101 'price_prefix' => $prefix 102 ); 103 104 if (AM_USE_SORT_ORDER) { 105 106 // changes by mytool 107 // get highest sort order value 108 109 $insertIndex = -1; 110 111 $result = $this -> getSortedProductAttributes( AM_FIELD_OPTION_SORT_ORDER ); 112 113 // search for the current Sort Order where the new value needs to be added 114 $i = -1; 115 while ( list($key, $val) = each($result) ) { 116 $i++; 117 if( $val['options_id'] == $optionId ){ 118 $insertIndex = $i; 119 } 120 } 121 122 // if InsertIndex is still -1 then this is a new option and will be added at the end 123 if($insertIndex > -1){ 124 $i = -1; 125 $newArray = array(); 126 127 for ($n=0; $n < count($result) ; $n++){ 128 $i++; 129 if( $i == $insertIndex ){ 130 $i++; 131 $data[AM_FIELD_OPTION_SORT_ORDER] = $i; 132 $newArray[$i] = $result[$n]; 133 } else { 134 $result[$n][AM_FIELD_OPTION_SORT_ORDER] = $i; 135 $newArray[$i] = $result[$n]; 136 } 137 } 138 139 $this->updateSortedProductArray($newArray); 140 141 } else { 142 $lastrow = end($result); 143 $data[AM_FIELD_OPTION_SORT_ORDER] = (int)$lastrow[AM_FIELD_OPTION_SORT_ORDER] + 1; 144 } 145 // EO mytool 146 } 147 148 amDB::perform(TABLE_PRODUCTS_ATTRIBUTES, $data); 149 } 150 151 /** 152 * Adds an existing option value to a product 153 * @see addAttributeToProduct() 154 */ 155 function addOptionValueToProduct($get) { 156 $this->addAttributeToProduct($get); 157 } 158 159 /** 160 * Adds a new option value to the database then assigns it to the product 161 * @author Sam West aka Nimmit - [email protected] 162 * @param $get $_GET 163 * @return void 164 */ 165 function addNewOptionValueToProduct($get) { 166 $returnInfo = $this->addOptionValue($get); 167 $get['option_value_id'] = $returnInfo['selectedOptionValue']; 168 $this->addAttributeToProduct($get); 169 } 170 171 /** 172 * Removes a specific option and its option values from the current product 173 * @access public 174 * @author Sam West aka Nimmit - [email protected] 175 * @param $get $_GET 176 * @return void 177 */ 178 function removeOptionFromProduct($get) { 179 $this->getAndPrepare('option_id',$get,$optionId); 180 amDB::query("delete from ".TABLE_PRODUCTS_ATTRIBUTES." where options_id = '$optionId' and products_id = '$this->intPID'"); 181 182 $this->updateSortOrder(); 183 } 184 185 /** 186 * Removes a specific option value from a the current product 187 * @access public 188 * @author Sam West aka Nimmit - [email protected] 189 * @param $get $_GET 190 * @return void 191 */ 192 function removeOptionValueFromProduct($get) { 193 $this->getAndPrepare('option_id',$get,$optionId); 194 $this->getAndPrepare('option_value_id',$get,$optionValueId); 195 amDB::query("delete from ".TABLE_PRODUCTS_ATTRIBUTES." where options_id = '$optionId' and options_values_id = '$optionValueId' and products_id = '$this->intPID'"); 196 197 $this->updateSortOrder(); 198 } 199 200 201 //---------------------------- 202 // Change: Add download attributes function for AM 203 // @author Urs Nyffenegger ak mytool 204 // Function: Add, delete and edit Download options 205 //----------------------------- 206 207 function updateDownloadAttributeToProduct($get) { 208 $this->getAndPrepare('option_id',$get,$optionId); 209 $this->getAndPrepare('option_value_id',$get,$optionValueId); 210 $this->getAndPrepare('products_attributes_filename',$get,$products_attributes_filename); 211 $this->getAndPrepare('products_attributes_maxdays',$get,$products_attributes_maxdays); 212 $this->getAndPrepare('products_attributes_maxcount',$get,$products_attributes_maxcount); 213 $this->getAndPrepare('products_attributes_id',$get,$products_attributes_id); 214 215 amDB::query('update '.TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD.' SET products_attributes_filename=\'' .$products_attributes_filename .'\', products_attributes_maxdays = '.$products_attributes_maxdays.', products_attributes_maxcount='.$products_attributes_maxcount.' where products_attributes_id = '.$products_attributes_id ); 216 } 217 218 function addDownloadAttributeToProduct($get) { 219 $this->getAndPrepare('option_id',$get,$optionId); 220 $this->getAndPrepare('option_value_id',$get,$optionValueId); 221 $this->getAndPrepare('products_attributes_filename',$get,$products_attributes_filename); 222 $this->getAndPrepare('products_attributes_maxdays',$get,$products_attributes_maxdays); 223 $this->getAndPrepare('products_attributes_maxcount',$get,$products_attributes_maxcount); 224 $this->getAndPrepare('products_attributes_id',$get,$products_attributes_id); 225 226 amDB::query('insert into '.TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD.' (products_attributes_id, products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount) values('.$products_attributes_id.',\''.$products_attributes_filename.'\', '.$products_attributes_maxdays.', '.$products_attributes_maxcount.')'); 227 } 228 229 function removeDownloadAttributeToProduct($get) { 230 $this->getAndPrepare('option_id',$get,$optionId); 231 $this->getAndPrepare('option_value_id',$get,$optionValueId); 232 $this->getAndPrepare('products_attributes_id',$get,$products_attributes_id); 233 234 amDB::query('delete from '.TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD.' where products_attributes_id='.$products_attributes_id ); 235 } 236 //---------------------------- 237 // EOF Change: download attributes for AM 238 //----------------------------- 239 240 241 // Begin QT Pro Plugin 242 /** 243 * Removes a specific stock option value from a the current product // for QT pro Plugin 244 * @access public 245 * @author Greg A. aka phocea - 246 * @param $get $_GET 247 * @return void 248 */ 249 function RemoveStockOptionValueFromProduct($get) { 250 $this->getAndPrepare('option_id',$get,$optionId); 251 amDB::query("delete from ".TABLE_PRODUCTS_STOCK." where products_stock_id = '$optionId'");// and products_id = '$this->intPID'"); 252 } 253 /** 254 * Removes a specific stock option value from a the current product // for QT pro Plugin 255 * @access public 256 * @author Greg A. aka phocea 257 * @param $get $_GET 258 * @return void 259 */ 260 /** 261 * Adds the selected attribute to the current product 262 * @access public 263 * @author Sam West aka Nimmit - [email protected] 264 * @param $get $_GET 265 * @return void 266 */ 267 function addStockToProduct($get) { 268 269 // $this->getAndPrepare('option_id', $get, $optionId); 270 // $this->getAndPrepare('option_value_id', $get, $optionValueId); 271 // $this->getAndPrepare('price', $get, $price); 272 // $this->getAndPrepare('prefix', $get, $prefix); 273 // $this->getAndPrepare('sortOrder', $get, $sortOrder); 274 $this->getAndPrepare('stockQuantity',$get,$stockQuantity); 275 276 amDB::query("delete from ".TABLE_PRODUCTS_STOCK." where products_stock_id = '$stockQuantity'");// and products_id = '$this->intPID'"); 277 // $data = array( 278 // 'products_id' => $this->intPID, 279 // 'options_id' => $optionId, 280 // 'options_values_id' => $optionValueId, 281 // 'options_values_price' => $price, 282 // 'price_prefix' => $prefix, 283 // AM_FIELD_OPTION_VALUE_SORT_ORDER => $sortOrder 284 // ); 285 // 286 // amDB::perform(TABLE_PRODUCTS_ATTRIBUTES, $data); 287 } 288 289 // function addStockToProduct($get) { 290 // customPrompt('debug','we are here'); 291 // $inputok = true; 292 // // Work out how many option were sent 293 // while(list($v1,$v2)=each($get)) { 294 // if (preg_match("/^option(\d+)$/",$v1,$m1)) { 295 // if (is_numeric($v2) and ($v2==(int)$v2)) $val_array[]=$m1[1]."-".$v2; 296 // else $inputok = false; 297 // } 298 // } 299 // 300 // $this->getAndPrepare('stockQuantity',$get,$stockQuantity); 301 // if (($inputok)) { 302 // sort($val_array, SORT_NUMERIC); 303 // $val=join(",",$val_array); 304 // $q=tep_db_query("select products_stock_id as stock_id from " . TABLE_PRODUCTS_STOCK . " where products_id ='$this->intPID' and products_stock_attributes='" . $val . "' order by products_stock_attributes"); 305 // if (tep_db_num_rows($q)>0) { 306 // $stock_item=tep_db_fetch_array($q); 307 // $stock_id=$stock_item[stock_id]; 308 // if ($stockQuantity=intval($stockQuantity)) { 309 // amDB::query("update " . TABLE_PRODUCTS_STOCK . " set products_stock_quantity=" . (int)$stockQuantity . " where products_stock_id=$stock_id"); 310 // 311 // } else { 312 // amDB::query("delete from " . TABLE_PRODUCTS_STOCK . " where products_stock_id=$stock_id"); 313 // } 314 // } else { 315 // amDB::query("insert into " . TABLE_PRODUCTS_STOCK . " values (0," . $this->intPID . ",'$val'," . (int)$stockQuantity . ")"); 316 // } 317 // $q=tep_db_query("select sum(products_stock_quantity) as summa from " . TABLE_PRODUCTS_STOCK . " where products_id=" . (int)$VARS['product_id'] . " and products_stock_quantity>0"); 318 // $list=tep_db_fetch_array($q); 319 // $summa= (empty($list[summa])) ? 0 : $list[summa]; 320 // amDB::query("update " . TABLE_PRODUCTS . " set products_quantity=$summa where products_id=" . $this->intPID); 321 // if (($summa<1) && (STOCK_ALLOW_CHECKOUT == 'false')) { 322 // amDB::query("update " . TABLE_PRODUCTS . " set products_status='0' where products_id=" . $this->intPI); 323 // } 324 // } 325 // } 326 327 /** 328 * Updates the quantity on the products stock table 329 * @author Phocea 330 * @param $get $_GET 331 * @return void 332 */ 333 function updateProductStockQuantity($get) { 334 customprompt(); 335 $this->getAndPrepare('products_stock_id', $get, $products_stock_id); 336 $this->getAndPrepare('productStockQuantity', $get, $productStockQuantity); 337 $data = array( 338 'product_stock_quantity' => $productStockQuantity 339 ); 340 amDB::perform(TABLE_PRODUCTS_STOCK,$data, 'update',"products_stock_id='$products_stock_id'"); 341 } 342 // End QT Pro Plugin 343 344 /** 345 * Updates the price and prefix in the products attribute table 346 * @author Sam West aka Nimmit - [email protected] 347 * @param $get $_GET 348 * @return void 349 */ 350 function update($get) { 351 352 $this->getAndPrepare('option_id', $get, $optionId); 353 $this->getAndPrepare('option_value_id', $get, $optionValueId); 354 $this->getAndPrepare('price', $get, $price); 355 $this->getAndPrepare('prefix', $get, $prefix); 356 $this->getAndPrepare('sortOrder', $get, $sortOrder); 357 358 if((empty($price))||($price=='0')){ 359 $price='0.0000'; 360 }else{ 361 if((empty($prefix))||($prefix==' ')){ 362 $prefix='+'; 363 } 364 } 365 366 $data = array( 367 'options_values_price' => $price, 368 'price_prefix' => $prefix 369 ); 370 /*if (AM_USE_SORT_ORDER) { 371 $data[AM_FIELD_OPTION_VALUE_SORT_ORDER] = $sortOrder; 372 } 373 */ 374 375 amDB::perform(TABLE_PRODUCTS_ATTRIBUTES,$data, 'update',"products_id='$this->intPID' and options_id='$optionId' and options_values_id='$optionValueId'"); 376 377 } 378 379 //----------------------------------------------- page actions end 380 381 /** 382 * Returns all or the options and values in the database 383 * @access public 384 * @author Sam West aka Nimmit - [email protected] 385 * @return array 386 */ 387 function getAllProductOptionsAndValues($reset = false) { 388 if(0 === count($this->arrAllProductOptionsAndValues)|| true === $reset) { 389 $this->arrAllProductOptionsAndValues = array(); 390 391 $allOptionsAndValues = $this->getAllOptionsAndValues(); 392 //---------------------------- 393 // Change: Add download attributes function for AM 394 // @author Urs Nyffenegger ak mytool 395 // Function: change query string to add the Download Table fields 396 //----------------------------- 397 $queryString = "select pa.*, pad.products_attributes_filename, pad.products_attributes_maxdays, pad.products_attributes_maxcount from ".TABLE_PRODUCTS_ATTRIBUTES." as pa INNER JOIN ".TABLE_PRODUCTS_OPTIONS." po ON pa.options_id=po.products_options_id"; 398 $queryString .= " LEFT JOIN ".TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad ON pa.products_attributes_id = pad.products_attributes_id"; 399 $queryString .= " where products_id = '$this->intPID' AND language_id=".(int)$this->getSelectedLanaguage()." order by "; 400 $queryString .= !AM_USE_SORT_ORDER ? "products_options_name, pa.products_attributes_id" : AM_FIELD_OPTION_VALUE_SORT_ORDER; 401 //---------------------------- 402 // EOF Change: download attributes for AM 403 //----------------------------- 404 $query = amDB::query($queryString); 405 406 $optionsId = null; 407 while($res = amDB::fetchArray($query)) { 408 //print_R($res); 409 if($res['options_id'] != $optionsId) { 410 $optionsId = $res['options_id']; 411 $this->arrAllProductOptionsAndValues[$optionsId]['name'] = $allOptionsAndValues[$optionsId]['name']; 412 // echo $this->arrAllProductOptionsAndValues[$optionsId]['name']; 413 } 414 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['name'] = $allOptionsAndValues[$optionsId]['values'][$res['options_values_id']]; 415 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['price'] = $res['options_values_price']; 416 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['prefix'] = $res['price_prefix']; 417 //---------------------------- 418 // Change: Add download attributes function for AM 419 // @author Urs Nyffenegger ak mytool 420 // Function: get the new Attributes 421 //----------------------------- 422 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['products_attributes_id'] = $res['products_attributes_id']; 423 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['products_attributes_filename'] = $res['products_attributes_filename']; 424 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['products_attributes_maxdays'] = $res['products_attributes_maxdays']; 425 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['products_attributes_maxcount'] = $res['products_attributes_maxcount']; 426 //---------------------------- 427 // EOF Change: download attributes for AM 428 //----------------------------- 429 430 if (AM_USE_SORT_ORDER) { 431 $this->arrAllProductOptionsAndValues[$optionsId]['values'][$res['options_values_id']]['sortOrder'] = $res[AM_FIELD_OPTION_VALUE_SORT_ORDER]; 432 } 433 } 434 } 435 return $this->arrAllProductOptionsAndValues; 436 } 437 438 function moveOptionUp() { 439 $this->moveOption(); 440 } 441 442 function moveOptionDown() { 443 $this->moveOption('down'); 444 } 445 446 function moveOption($get) { 447 448 $extraValues = $this->getExtraValues($get['gets']); 449 $direction = $get['dir']; 450 $changes = false; 451 $newArray = array(); 452 453 // Get current State -- is this necessary? or could we take the getAllProductOptionsAndValues?? i'll see later 454 $sortedArray = $this->getSortedProductAttributes( AM_FIELD_OPTION_SORT_ORDER ); 455 456 // now create new array with the optionsID unique 457 $i = - 1; 458 $firstRow = current($sortedArray); 459 $start_ID = $firstRow['options_id']; 460 461 reset($sortedArray); 462 463 while ( list($key, $val) = each($sortedArray)) { 464 465 if( $val['options_id'] != $start_ID ){ 466 $i = - 1; 467 $start_ID = $val['options_id']; 468 } 469 470 $i++; 471 $optionsArray[ $val['options_id'] ][$i] = $val; 472 473 } 474 475 // get position so we can swap 476 $positionArray = array_keys($optionsArray); 477 $position = array_search( (int)$extraValues['option_id'], $positionArray); 478 479 if($direction == 'up'){ 480 481 if( $position > 0 ){ 482 $changes = true; 483 $prevItem = $positionArray[ $position - 1]; 484 $ThisItem = $positionArray[$position]; 485 $positionArray[$position] = $prevItem; 486 $positionArray[$position - 1] = $ThisItem; 487 } 488 489 } else { 490 491 if( $position < ( count($positionArray)-1 ) ){ 492 $changes = true; 493 $nextItem = $positionArray[ $position + 1]; 494 $ThisItem = $positionArray[$position]; 495 $positionArray[$position] = $nextItem; 496 $positionArray[$position + 1] = $ThisItem; 497 } 498 499 } 500 501 // set new Sortvalues 502 $i = - 1; 503 while ( list($key, $val) = each($positionArray)) { 504 while ( list($okey, $oval) = each( $optionsArray[ $val ]) ) { 505 $i++; 506 $oval[AM_FIELD_OPTION_SORT_ORDER] = $i; 507 $newArray[$i] = $oval; 508 } 509 } 510 511 // update Database 512 if($changes){ 513 $this->updateSortedProductArray($newArray); 514 } 515 } 516 517 function moveOptionValue($get) { 518 519 $extraValues = $this->getExtraValues($get['gets']); 520 $direction = $get['dir']; 521 $changes = false; 522 $sortedArray = array(); 523 $newArray = array(); 524 525 $sortedArray = $this->getSortedProductAttributes( AM_FIELD_OPTION_VALUE_SORT_ORDER ); 526 527 $i = -1; 528 529 // filter array 530 while ( list($key, $val) = each($sortedArray) ) { 531 if( $val['options_id'] == $extraValues['option_id'] ){ 532 $i++; 533 $newArray[$val[AM_FIELD_OPTION_VALUE_SORT_ORDER]] = $val; 534 } 535 } 536 537 // get first and Last Row, so we can determine lowest and higest Sort order value later 538 reset($newArray); 539 540 $first = current($newArray); 541 $firstSortValue = (int)$first[AM_FIELD_OPTION_VALUE_SORT_ORDER]; 542 $lastSortValue = $firstSortValue + count($newArray) - 1; 543 544 while ( list($key, $val) = each($newArray) ) { 545 if( $val['products_attributes_id'] == $extraValues['products_attributes_id'] ){ 546 $startSort = $val[AM_FIELD_OPTION_VALUE_SORT_ORDER]; 547 } 548 } 549 550 if($direction == 'up'){ 551 // ceiling_ only change if its not the top item 552 if ($startSort > (int)$firstSortValue ){ 553 $changes = true; 554 $newArray[$startSort][AM_FIELD_OPTION_VALUE_SORT_ORDER] = (int)$startSort - 1; 555 $newArray[$startSort-1][AM_FIELD_OPTION_VALUE_SORT_ORDER] = (int)$startSort; 556 } 557 }else{ 558 // ceiling only change if its not the bottom item 559 if ( $startSort < (int)$lastSortValue ){ 560 $changes = true; 561 $newArray[$startSort][AM_FIELD_OPTION_VALUE_SORT_ORDER] = (int)$startSort + 1; 562 $newArray[$startSort+1][AM_FIELD_OPTION_VALUE_SORT_ORDER] = (int)$startSort; 563 } 564 } 565 566 // update Database 567 if($changes){ 568 $this->updateSortedProductArray($newArray); 569 } 570 571 } 572 573 function getExtraValues($gets){ 574 $arrExtraValues = array(); 575 $valuePairs = array(); 576 577 if(strpos($gets,'|')) 578 $valuePairs = explode('|',$gets); 579 else 580 $valuePairs[] = $gets; 581 582 foreach($valuePairs as $pair) 583 if(strpos($pair,':')) { 584 list($extraKey, $extraValue) = explode(':',$pair); 585 $arrExtraValues[$extraKey] = $extraValue; 586 } 587 588 return $arrExtraValues; 589 } 590 591 function getSortedProductAttributes( $sortfield ){ 592 593 $sortedArray = array(); 594 595 $queryString = "select products_attributes_id, options_id, products_options_sort_order" . 596 " from ".TABLE_PRODUCTS_ATTRIBUTES. 597 " where products_id=".$this->intPID; 598 599 /* if( $optionsID > -1){ 600 $queryString .= " AND options_id=".$optionsID; 601 } 602 */ 603 $queryString .= " ORDER BY ".$sortfield." asc, options_id asc"; 604 605 $result = amDB::getAll($queryString); 606 607 //$i = (int)$result[0][$sortfield]; 608 $i=0; 609 610 while(list($key, $val) = each($result)) { 611 // set the sorting new 612 $val[AM_FIELD_OPTION_VALUE_SORT_ORDER] = $i; 613 $sortedArray[$i] = $val; 614 $i++; 615 } 616 617 return $sortedArray; 618 } 619 620 621 function updateSortedProductArray($newArray){ 622 623 reset($newArray); 624 while ( list($key, $val) = each($newArray)) { 625 if( !empty($val['products_attributes_id'] )){ 626 amDB::perform(TABLE_PRODUCTS_ATTRIBUTES,$val,'update','products_attributes_id = ' . $val['products_attributes_id'] ); 627 } 628 } 629 } 630 631 function updateSortOrder(){ 632 633 if (AM_USE_SORT_ORDER) { 634 $newArray = $this->getSortedProductAttributes( AM_FIELD_OPTION_VALUE_SORT_ORDER ); 635 $this->updateSortedProductArray( $newArray ); 636 } 637 } 638 639 640 } 641 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |