Changeset 17959
- Timestamp:
- 2009/04/09 21:41:05 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/class/pages/products/LC_Page_Products_List.php
r17938 r17959 402 402 } 403 403 } 404 404 405 // ▼対象商品IDの抽出 406 // 商品検索条件の作成(未削除、表示) 407 $where = "del_flg = 0 AND status = 1 "; 408 409 // 在庫無し商品の非表示 410 if (NOSTOCK_HIDDEN === true) { 411 $where .= ' AND (stock_max >= 1 OR stock_unlimited_max = 1)'; 412 } 413 414 if (strlen($where_category) >= 1) { 415 $where.= " $where_category"; 416 $arrval = array_merge($arrval, $arrval_category); 417 } 418 419 // 商品名をwhere文に 420 $name = ereg_replace(",", "", $name);// XXX 421 // 全角スペースを半角スペースに変換 422 $name = str_replace(' ', ' ', $name); 423 // スペースでキーワードを分割 424 $names = preg_split("/ +/", $name); 425 // 分割したキーワードを一つずつwhere文に追加 426 foreach ($names as $val) { 427 if ( strlen($val) > 0 ){ 428 $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 429 $ret = SC_Utils_Ex::sfManualEscape($val); 430 $arrval[] = "%$ret%"; 431 $arrval[] = "%$ret%"; 432 } 433 } 434 435 // メーカーらのWHERE文字列取得 436 if ( $maker_id ) { 437 $where .= " AND maker_id = ? "; 438 $arrval[] = $maker_id; 439 } 440 441 $arrProduct_id = $objQuery->getCol('vw_products_allclass AS allcls', 'DISTINCT product_id', $where, $arrval); 442 // ▲対象商品IDの抽出 443 444 // 行数の取得 445 $linemax = count($arrProduct_id); 446 447 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 448 449 // ページ送りの取得 450 $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 451 452 $strnavi = $this->objNavi->strnavi; 453 $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 454 // 表示文字列 455 $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; 456 $startno = $this->objNavi->start_row; // 開始行 457 458 // ▼商品詳細取得 405 459 $col = <<< __EOS__ 406 460 product_id … … 431 485 ,del_flg 432 486 __EOS__; 433 $from = "vw_products_allclass AS allcls"; 487 488 $from = "vw_products_allclass_detail AS alldtl"; 489 490 // WHERE 句 491 $where = '0=0'; 492 if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 493 $where .= ' AND product_id IN (' . implode(',', $arrProduct_id) . ')'; 494 } 434 495 435 496 //表示順序 … … 455 516 JOIN dtb_category T3 456 517 USING (category_id) 457 WHERE T2.product_id = all cls.product_id518 WHERE T2.product_id = alldtl.product_id 458 519 $where_category 459 520 ORDER BY T3.rank DESC, T2.rank DESC … … 467 528 JOIN dtb_category T3 468 529 USING (category_id) 469 WHERE T2.product_id = all cls.product_id530 WHERE T2.product_id = alldtl.product_id 470 531 $where_category 471 532 ORDER BY T3.rank DESC, T2.rank DESC … … 477 538 break; 478 539 } 479 480 // 商品検索条件の作成(未削除、表示) 481 $where = "del_flg = 0 AND status = 1 "; 482 483 // 在庫無し商品の非表示 484 if (NOSTOCK_HIDDEN === true) { 485 $where .= ' AND (allcls.stock_max >= 1 OR allcls.stock_unlimited_max = 1)'; 486 } 487 488 if (strlen($where_category) >= 1) { 489 $where.= " $where_category"; 490 $arrval = array_merge($arrval, $arrval_category); 491 } 492 493 // 商品名をwhere文に 494 $name = ereg_replace(",", "", $name);// XXX 495 // 全角スペースを半角スペースに変換 496 $name = str_replace(' ', ' ', $name); 497 // スペースでキーワードを分割 498 $names = preg_split("/ +/", $name); 499 // 分割したキーワードを一つずつwhere文に追加 500 foreach ($names as $val) { 501 if ( strlen($val) > 0 ){ 502 $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 503 $ret = SC_Utils_Ex::sfManualEscape($val); 504 $arrval[] = "%$ret%"; 505 $arrval[] = "%$ret%"; 506 } 507 } 508 509 // メーカーらのWHERE文字列取得 510 if ( $maker_id ) { 511 $where .= " AND maker_id = ? "; 512 $arrval[] = $maker_id; 513 } 514 515 // 行数の取得 516 $linemax = count($objQuery->getAll("SELECT DISTINCT product_id " 517 . "FROM vw_products_allclass AS allcls " 518 . (!empty($where) ? " WHERE " . $where 519 : ""), $arrval)); 520 521 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 522 523 // ページ送りの取得 524 $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 525 526 $strnavi = $this->objNavi->strnavi; 527 $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 528 // 表示文字列 529 $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; 530 $startno = $this->objNavi->start_row; // 開始行 531 540 532 541 // 取得範囲の指定(開始行番号、行数のセット) 533 542 $objQuery->setlimitoffset($disp_num, $startno); 534 543 // 表示順序 535 544 $objQuery->setorder($order); 536 545 537 546 // 検索結果の取得 538 $this->arrProducts = $objQuery->select($col, $from, $where, array_merge($arrval, $arrval_order)); 539 547 $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order); 548 // ▲商品詳細取得 549 540 550 // 規格名一覧 541 551 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");
Note: See TracChangeset
for help on using the changeset viewer.