Changeset 22796 for branches/version-2_12-dev/data/class/SC_Product.php
- Timestamp:
- 2013/05/02 18:11:36 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_Product.php
r22593 r22796 29 29 * @version $Id$ 30 30 */ 31 class SC_Product 32 { 31 class SC_Product { 33 32 34 33 /** 規格名一覧 */ … … 61 60 * @return void 62 61 */ 63 function setProductsOrder($col, $table = 'dtb_products', $order = 'ASC') 64 { 62 function setProductsOrder($col, $table = 'dtb_products', $order = 'ASC') { 65 63 $this->arrOrderData = array('col' => $col, 'table' => $table, 'order' => $order); 66 64 } … … 75 73 * @return array 商品IDの配列 76 74 */ 77 function findProductIdsOrder(&$objQuery, $arrVal = array()) 78 {79 $table = 'dtb_products AS alldtl';80 75 function findProductIdsOrder(&$objQuery, $arrVal = array()) { 76 $table = <<< __EOS__ 77 dtb_products AS alldtl 78 __EOS__; 81 79 $objQuery->setGroupBy('alldtl.product_id'); 82 80 if (is_array($this->arrOrderData) and $objQuery->order == '') { … … 96 94 $objQuery->setOrder($order); 97 95 } 98 $arrReturn = $objQuery->getCol('alldtl.product_id', $table, '', $arrVal); 99 100 return $arrReturn; 96 $results = $objQuery->select('alldtl.product_id', $table, '', $arrVal, MDB2_FETCHMODE_ORDERED); 97 $resultValues = array(); 98 foreach ($results as $val) { 99 $resultValues[] = $val[0]; 100 } 101 return $resultValues; 101 102 } 102 103 … … 110 111 * @return array 対象商品ID数 111 112 */ 112 function findProductCount(&$objQuery, $arrVal = array()) 113 {114 $table = 'dtb_products AS alldtl';115 113 function findProductCount(&$objQuery, $arrVal = array()) { 114 $table = <<< __EOS__ 115 dtb_products AS alldtl 116 __EOS__; 116 117 return $objQuery->count($table, '', $arrVal); 117 118 } … … 127 128 * @return array 商品一覧の配列 128 129 */ 129 function lists(&$objQuery) 130 { 130 function lists(&$objQuery) { 131 131 $col = <<< __EOS__ 132 132 product_id … … 154 154 __EOS__; 155 155 $res = $objQuery->select($col, $this->alldtlSQL()); 156 157 156 return $res; 158 157 } … … 170 169 * @return array 商品一覧の配列 (キー: 商品ID) 171 170 */ 172 function getListByProductIds(&$objQuery, $arrProductId = array()) 173 { 171 function getListByProductIds(&$objQuery, $arrProductId = array()) { 174 172 if (empty($arrProductId)) { 175 173 return array(); … … 183 181 184 182 // 配列のキーを商品IDに 185 $arrProducts = SC_Utils_Ex::makeArrayIDToKey('product_id', $arrProducts); 183 $arrTmp = array(); 184 foreach ($arrProducts as $arrProduct) { 185 $arrTmp[$arrProduct['product_id']] = $arrProduct; 186 } 187 $arrProducts =& $arrTmp; 188 unset($arrTmp); 186 189 187 190 // SC_Query::setOrder() の指定がない場合、$arrProductId で指定された商品IDの順に配列要素を並び替え … … 207 210 * @return array 商品詳細情報の配列 208 211 */ 209 function getDetail($productId) 210 { 212 function getDetail($productId) { 211 213 $objQuery =& SC_Query_Ex::getSingletonInstance(); 212 214 $arrProduct = $objQuery->getRow('*', $this->alldtlSQL('product_id = ?'), … … 227 229 * @return array 商品詳細情報と商品規格の配列 228 230 */ 229 function getDetailAndProductsClass($productClassId) 230 { 231 function getDetailAndProductsClass($productClassId) { 231 232 $result = $this->getProductsClass($productClassId); 232 233 $result = array_merge($result, $this->getDetail($result['product_id'])); 233 234 234 return $result; 235 235 } … … 245 245 * @return void 246 246 */ 247 function setProductsClassByProductIds($arrProductId, $has_deleted = false) 248 { 247 function setProductsClassByProductIds($arrProductId, $has_deleted = false) { 249 248 250 249 foreach ($arrProductId as $productId) { … … 348 347 * @return array 商品規格の配列 349 348 */ 350 function getProductsClassByQuery(&$objQuery, $params) 351 { 349 function getProductsClassByQuery(&$objQuery, $params) { 352 350 // 末端の規格を取得 353 351 $col = <<< __EOS__ … … 402 400 * @return array 商品規格の配列 403 401 */ 404 function getProductsClass($productClassId) 405 { 402 function getProductsClass($productClassId) { 406 403 $objQuery =& SC_Query_Ex::getSingletonInstance(); 407 404 $objQuery->setWhere('product_class_id = ? AND T1.del_flg = 0'); 408 405 $arrRes = $this->getProductsClassByQuery($objQuery, $productClassId); 409 410 406 return (array)$arrRes[0]; 411 407 } … … 418 414 * @return array 商品規格の配列 419 415 */ 420 function getProductsClassByProductIds($productIds = array(), $has_deleted = false) 421 { 416 function getProductsClassByProductIds($productIds = array(), $has_deleted = false) { 422 417 if (empty($productIds)) { 423 418 return array(); … … 429 424 } 430 425 $objQuery->setWhere($where); 431 432 426 return $this->getProductsClassByQuery($objQuery, $productIds); 433 427 } … … 440 434 * @return array すべての組み合わせの商品規格の配列 441 435 */ 442 function getProductsClassFullByProductId($productId, $has_deleted = false) 443 { 436 function getProductsClassFullByProductId($productId, $has_deleted = false) { 444 437 $arrRet = $this->getProductsClassByProductIds(array($productId), $has_deleted); 445 446 438 return $arrRet; 447 439 } … … 453 445 * @return array 商品IDをキーにした商品ステータスIDの配列 454 446 */ 455 function getProductStatus($productIds) 456 { 447 function getProductStatus($productIds) { 457 448 if (empty($productIds)) { 458 449 return array(); … … 467 458 $results[$status['product_id']][] = $status['product_status_id']; 468 459 } 469 470 460 return $results; 471 461 } … … 479 469 * @param array $productStatusIds ON にする商品ステータスIDの配列 480 470 */ 481 function setProductStatus($productId, $productStatusIds) 482 { 471 function setProductStatus($productId, $productStatusIds) { 483 472 484 473 $val['product_id'] = $productId; … … 506 495 * @see getDetailAndProductsClass() 507 496 */ 508 function getBuyLimit($p) 509 { 497 function getBuyLimit($p) { 510 498 $limit = null; 511 499 if ($p['stock_unlimited'] != '1' && is_numeric($p['sale_limit'])) { … … 516 504 $limit = $p['stock']; 517 505 } 518 519 506 return $limit; 520 507 } … … 532 519 * @return boolean 在庫の減少に成功した場合 true; 失敗した場合 false 533 520 */ 534 function reduceStock($productClassId, $quantity) 535 { 521 function reduceStock($productClassId, $quantity) { 536 522 537 523 if ($quantity == 0) { … … 559 545 * 560 546 * @param array $arrProducts 商品情報の配列 561 * @return array 旧バージョン互換用のデータ 562 */ 563 static function setPriceTaxTo(&$arrProducts) 564 { 565 foreach ($arrProducts as &$arrProduct) { 566 $arrProduct['price01_min_format'] = number_format($arrProduct['price01_min']); 567 $arrProduct['price01_max_format'] = number_format($arrProduct['price01_max']); 568 $arrProduct['price02_min_format'] = number_format($arrProduct['price02_min']); 569 $arrProduct['price02_max_format'] = number_format($arrProduct['price02_max']); 570 571 SC_Product_Ex::setIncTaxToProduct($arrProduct); 572 573 $arrProduct['price01_min_inctax_format'] = number_format($arrProduct['price01_min_inctax']); 574 $arrProduct['price01_max_inctax_format'] = number_format($arrProduct['price01_max_inctax']); 575 $arrProduct['price02_min_inctax_format'] = number_format($arrProduct['price02_min_inctax']); 576 $arrProduct['price02_max_inctax_format'] = number_format($arrProduct['price02_max_inctax']); 577 578 // @deprecated 2.12.4 579 // 旧バージョン互換用 580 // 本来は、税額の代入で使用すべきキー名。 581 $arrProduct['price01_min_tax_format'] =& $arrProduct['price01_min_inctax_format']; 582 $arrProduct['price01_max_tax_format'] =& $arrProduct['price01_max_inctax_format']; 583 $arrProduct['price02_min_tax_format'] =& $arrProduct['price02_min_inctax_format']; 584 $arrProduct['price02_max_tax_format'] =& $arrProduct['price02_max_inctax_format']; 585 } 586 // @deprecated 2.12.4 587 // 旧バージョン互換用 588 // 現在は参照渡しで戻せる 547 * @return array 税込金額を設定した商品情報の配列 548 */ 549 function setPriceTaxTo($arrProducts) { 550 foreach ($arrProducts as $key => $value) { 551 $arrProducts[$key]['price01_min_format'] = number_format($arrProducts[$key]['price01_min']); 552 $arrProducts[$key]['price01_max_format'] = number_format($arrProducts[$key]['price01_max']); 553 $arrProducts[$key]['price02_min_format'] = number_format($arrProducts[$key]['price02_min']); 554 $arrProducts[$key]['price02_max_format'] = number_format($arrProducts[$key]['price02_max']); 555 556 $arrProducts[$key]['price01_min_tax'] = SC_Helper_DB::sfCalcIncTax($arrProducts[$key]['price01_min']); 557 $arrProducts[$key]['price01_max_tax'] = SC_Helper_DB::sfCalcIncTax($arrProducts[$key]['price01_max']); 558 $arrProducts[$key]['price02_min_tax'] = SC_Helper_DB::sfCalcIncTax($arrProducts[$key]['price02_min']); 559 $arrProducts[$key]['price02_max_tax'] = SC_Helper_DB::sfCalcIncTax($arrProducts[$key]['price02_max']); 560 561 $arrProducts[$key]['price01_min_tax_format'] = number_format($arrProducts[$key]['price01_min_tax']); 562 $arrProducts[$key]['price01_max_tax_format'] = number_format($arrProducts[$key]['price01_max_tax']); 563 $arrProducts[$key]['price02_min_tax_format'] = number_format($arrProducts[$key]['price02_min_tax']); 564 $arrProducts[$key]['price02_max_tax_format'] = number_format($arrProducts[$key]['price02_max_tax']); 565 } 589 566 return $arrProducts; 590 567 } … … 596 573 * @return void 597 574 */ 598 static function setIncTaxToProducts(&$arrProducts) 599 { 575 static function setIncTaxToProducts(&$arrProducts) { 600 576 foreach ($arrProducts as &$arrProduct) { 601 577 SC_Product_Ex::setIncTaxToProduct($arrProduct); … … 609 585 * @return void 610 586 */ 611 static function setIncTaxToProduct(&$arrProduct) 612 { 613 $arrProduct['price01_min_inctax'] = isset($arrProduct['price01_min']) ? SC_Helper_DB_Ex::sfCalcIncTax($arrProduct['price01_min']) : null; 614 $arrProduct['price01_max_inctax'] = isset($arrProduct['price01_max']) ? SC_Helper_DB_Ex::sfCalcIncTax($arrProduct['price01_max']) : null; 615 $arrProduct['price02_min_inctax'] = isset($arrProduct['price02_min']) ? SC_Helper_DB_Ex::sfCalcIncTax($arrProduct['price02_min']) : null; 616 $arrProduct['price02_max_inctax'] = isset($arrProduct['price02_max']) ? SC_Helper_DB_Ex::sfCalcIncTax($arrProduct['price02_max']) : null; 587 static function setIncTaxToProduct(&$arrProduct) { 588 $arrProduct['price01_min_inctax'] = isset($arrProduct['price01_min']) ? SC_Helper_DB::sfCalcIncTax($arrProduct['price01_min']) : null; 589 $arrProduct['price01_max_inctax'] = isset($arrProduct['price01_max']) ? SC_Helper_DB::sfCalcIncTax($arrProduct['price01_max']) : null; 590 $arrProduct['price02_min_inctax'] = isset($arrProduct['price02_min']) ? SC_Helper_DB::sfCalcIncTax($arrProduct['price02_min']) : null; 591 $arrProduct['price02_max_inctax'] = isset($arrProduct['price02_max']) ? SC_Helper_DB::sfCalcIncTax($arrProduct['price02_max']) : null; 617 592 } 618 593 … … 623 598 * @return string 商品詳細の SQL 624 599 */ 625 function alldtlSQL($where_products_class = '') 626 { 600 function alldtlSQL($where_products_class = '') { 627 601 if (!SC_Utils_Ex::isBlank($where_products_class)) { 628 602 $where_products_class = 'AND (' . $where_products_class . ')'; … … 719 693 ) AS alldtl 720 694 __EOS__; 721 722 695 return $sql; 723 696 } … … 731 704 * @return string 商品規格詳細の SQL 732 705 */ 733 function prdclsSQL($where = '') 734 { 706 function prdclsSQL($where = '') { 735 707 $where_clause = ''; 736 708 if (!SC_Utils_Ex::isBlank($where)) { … … 770 742 ) as prdcls 771 743 __EOS__; 772 773 744 return $sql; 774 745 }
Note: See TracChangeset
for help on using the changeset viewer.