| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of EC-CUBE |
|---|
| 4 | * |
|---|
| 5 | * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 6 | * |
|---|
| 7 | * http://www.lockon.co.jp/ |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or |
|---|
| 10 | * modify it under the terms of the GNU General Public License |
|---|
| 11 | * as published by the Free Software Foundation; either version 2 |
|---|
| 12 | * of the License, or (at your option) any later version. |
|---|
| 13 | * |
|---|
| 14 | * This program is distributed in the hope that it will be useful, |
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | * GNU General Public License for more details. |
|---|
| 18 | * |
|---|
| 19 | * You should have received a copy of the GNU General Public License |
|---|
| 20 | * along with this program; if not, write to the Free Software |
|---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * APIの基本クラス |
|---|
| 26 | * |
|---|
| 27 | * @package Api |
|---|
| 28 | * @author LOCKON CO.,LTD. |
|---|
| 29 | * @version $Id$ |
|---|
| 30 | */ |
|---|
| 31 | require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php'; |
|---|
| 32 | |
|---|
| 33 | class API_ItemLookup extends SC_Api_Abstract_Ex |
|---|
| 34 | { |
|---|
| 35 | protected $operation_name = 'ItemLookup'; |
|---|
| 36 | protected $operation_description = '商品詳細情報を取得します。'; |
|---|
| 37 | protected $default_auth_types = self::API_AUTH_TYPE_OPEN; |
|---|
| 38 | protected $default_enable = '1'; |
|---|
| 39 | protected $default_is_log = '0'; |
|---|
| 40 | protected $default_sub_data = ''; |
|---|
| 41 | |
|---|
| 42 | public function doAction($arrParam) |
|---|
| 43 | { |
|---|
| 44 | $arrRequest = $this->doInitParam($arrParam); |
|---|
| 45 | if (!$this->isParamError()) { |
|---|
| 46 | $objProduct = new SC_Product_Ex(); |
|---|
| 47 | |
|---|
| 48 | switch ($arrRequest['IdType']) { |
|---|
| 49 | case 'product_code': |
|---|
| 50 | $search_column = 'product_code'; |
|---|
| 51 | break; |
|---|
| 52 | case 'product_class_id': |
|---|
| 53 | $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']); |
|---|
| 54 | break; |
|---|
| 55 | case 'product_id': |
|---|
| 56 | default: |
|---|
| 57 | $arrProduct = $objProduct->getDetail($arrRequest['ItemId']); |
|---|
| 58 | break; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | $objProduct->setProductsClassByProductIds(array($arrProduct['product_id'])); |
|---|
| 62 | |
|---|
| 63 | if ($arrProduct['del_flg'] == '0' && $arrProduct['status'] == '1') { |
|---|
| 64 | unset($arrProduct['note']); |
|---|
| 65 | $this->setResponse('product_id', $arrProduct['product_id']); |
|---|
| 66 | $this->setResponse('DetailPageURL', HTTP_URL . 'products/detail.php?product_id=' . $arrProduct['product_id']); |
|---|
| 67 | $this->setResponse('Title', $arrProduct['name']); |
|---|
| 68 | $this->setResponse('ItemAttributes', $arrProduct); |
|---|
| 69 | |
|---|
| 70 | return true; |
|---|
| 71 | } else { |
|---|
| 72 | $this->addError('ItemLookup.Error', '※ 要求された情報は見つかりませんでした。'); |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | return false; |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | protected function checkErrorExtended($arrParam) |
|---|
| 80 | { |
|---|
| 81 | switch ($arrParam['IdType']) { |
|---|
| 82 | case 'product_code': |
|---|
| 83 | break; |
|---|
| 84 | case 'product_id': |
|---|
| 85 | case 'product_class_id': |
|---|
| 86 | default: |
|---|
| 87 | $objErr = new SC_CheckError_Ex($arrParam); |
|---|
| 88 | $objErr->doFunc(array('指定ID', 'ItemId', INT_LEN), array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
|---|
| 89 | $this->addError($objErr->arrErr); |
|---|
| 90 | break; |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | protected function lfInitParam(&$objFormParam) |
|---|
| 95 | { |
|---|
| 96 | $objFormParam->addParam('商品コンディション', 'Condition', STEXT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 97 | $objFormParam->addParam('商品ID種別', 'IdType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 98 | $objFormParam->addParam('指定ID', 'ItemId', STEXT_LEN, 'a', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 99 | $objFormParam->addParam('関連商品数', 'RelatedItemsPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 100 | $objFormParam->addParam('関連商品種別', 'RelationshipType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 101 | $objFormParam->addParam('レビューページ番号', 'ReviewPage', INT_LEN, 'N', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 102 | $objFormParam->addParam('レビューページソート', 'ReviewSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 103 | $objFormParam->addParam('関連タグページ', 'TagPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 104 | $objFormParam->addParam('関連タグページ数', 'TagsPerPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 105 | $objFormParam->addParam('関連タグソート', 'TagSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | public function getResponseGroupName() |
|---|
| 109 | { |
|---|
| 110 | return 'Item'; |
|---|
| 111 | } |
|---|
| 112 | } |
|---|