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

Revision 22856, 4.6 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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    {
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                return true;
70            } else {
71                $this->addError('ItemLookup.Error', '※ 要求された情報は見つかりませんでした。');
72            }
73        }
74
75        return false;
76    }
77
78    protected function checkErrorExtended($arrParam)
79    {
80        switch ($arrParam['IdType']) {
81        case 'product_code':
82            break;
83        case 'product_id':
84        case 'product_class_id':
85        default:
86            $objErr = new SC_CheckError_Ex($arrParam);
87            $objErr->doFunc(array('指定ID', 'ItemId', INT_LEN), array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
88            $this->addError($objErr->arrErr);
89            break;
90        }
91    }
92
93    protected function lfInitParam(&$objFormParam)
94    {
95        $objFormParam->addParam('商品コンディション', 'Condition', STEXT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
96        $objFormParam->addParam('商品ID種別', 'IdType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
97        $objFormParam->addParam('指定ID', 'ItemId', STEXT_LEN, 'a', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
98        $objFormParam->addParam('関連商品数', 'RelatedItemsPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
99        $objFormParam->addParam('関連商品種別', 'RelationshipType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
100        $objFormParam->addParam('レビューページ番号', 'ReviewPage', INT_LEN, 'N', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
101        $objFormParam->addParam('レビューページソート', 'ReviewSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
102        $objFormParam->addParam('関連タグページ', 'TagPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
103        $objFormParam->addParam('関連タグページ数', 'TagsPerPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
104        $objFormParam->addParam('関連タグソート', 'TagSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
105    }
106
107    public function getResponseGroupName()
108    {
109        return 'Item';
110    }
111}
Note: See TracBrowser for help on using the repository browser.