source: branches/version-2_12-dev/data/class/api/operations/ItemLookup.php @ 21864

Revision 21864, 4.6 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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 */
31require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';
32
33class 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        $arrRequest = $this->doInitParam($arrParam);
44        if (!$this->isParamError()) {
45            $objProduct = new SC_Product_Ex();
46
47            switch ($arrRequest['IdType']) {
48            case 'product_code':
49                $search_column = 'product_code';
50                break;
51            case 'product_class_id':
52                $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']);
53                break;
54            case 'product_id':
55            default:
56                $arrProduct = $objProduct->getDetail($arrRequest['ItemId']);
57                break;
58            }
59
60            $objProduct->setProductsClassByProductIds(array($arrProduct['product_id']));
61
62            if ($arrProduct['del_flg'] == '0' && $arrProduct['status'] == '1') {
63                unset($arrProduct['note']);
64                $this->setResponse('product_id', $arrProduct['product_id']);
65                $this->setResponse('DetailPageURL', HTTP_URL . 'products/detail.php?product_id=' . $arrProduct['product_id']);
66                $this->setResponse('Title', $arrProduct['name']);
67                $this->setResponse('ItemAttributes', $arrProduct);
68                return true;
69            } else {
70                $this->addError('ItemLookup.Error', '※ 要求された情報は見つかりませんでした。');
71            }
72        }
73
74        return false;
75    }
76
77    protected function checkErrorExtended($arrParam) {
78        switch ($arrParam['IdType']) {
79        case 'product_code':
80            break;
81        case 'product_id':
82        case 'product_class_id':
83        default:
84            $objErr = new SC_CheckError_Ex($arrParam);
85            $objErr->doFunc(array('指定ID', 'ItemId', INT_LEN), array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
86            $this->addError($objErr->arrErr);
87            break;
88        }
89    }
90
91    protected function lfInitParam(&$objFormParam) {
92        $objFormParam->addParam('商品コンディション', 'Condition', STEXT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
93        $objFormParam->addParam('商品ID種別', 'IdType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
94        $objFormParam->addParam('指定ID', 'ItemId', STEXT_LEN, 'a', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
95        $objFormParam->addParam('関連商品数', 'RelatedItemsPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
96        $objFormParam->addParam('関連商品種別', 'RelationshipType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
97        $objFormParam->addParam('レビューページ番号', 'ReviewPage', INT_LEN, 'N', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
98        $objFormParam->addParam('レビューページソート', 'ReviewSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
99        $objFormParam->addParam('関連タグページ', 'TagPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
100        $objFormParam->addParam('関連タグページ数', 'TagsPerPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
101        $objFormParam->addParam('関連タグソート', 'TagSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
102    }
103
104    public function getResponseGroupName() {
105        return 'Item';
106    }
107}
Note: See TracBrowser for help on using the repository browser.