【发布时间】:2019-05-19 16:23:47
【问题描述】:
我正在尝试通过 CS-cart 中的 api 检索用户信息。但它只返回有限的信息。我们如何修改代码以获取前用户个人资料、地址、gst 等所有用户信息。
【问题讨论】:
标签: cs-cart
我正在尝试通过 CS-cart 中的 api 检索用户信息。但它只返回有限的信息。我们如何修改代码以获取前用户个人资料、地址、gst 等所有用户信息。
【问题讨论】:
标签: cs-cart
您可以创建自己的 API。
/var/www/html/app/addons/addon_name/Tygh/Api/Entities/Egg.php
<?php
namespace Tygh\Api\Entities;
use Tygh\Api\AEntity;
use Tygh\Api\Response;
class Egg extends AEntity
{
public function index($id = '', $params = array())
{
if(empty($id))
{
$dd=db_get_array("SELECT * FROM ?:table_name");
//result all rows
}
else
{
// for filtering purpose
$where=array("id"=>$id);
$dd=db_get_array("SELECT * FROM ?:table_name where ?w",$where);
//result-> specific one row
}
return array(
'status' => Response::STATUS_OK,
'data' => $dd
);
}
public function create($params)
{
return array(
'status' => Response::STATUS_OK,
'data' => array()
);
}
public function update($id, $params)
{
return array(
'status' => Response::STATUS_OK,
'data' => array()
);
}
public function delete($id)
{
return array(
'status' => Response::STATUS_NO_CONTENT,
);
}
public function privileges()
{
return array(
'index' => true,
'create' => 'create_things',
'update' => 'edit_things',
'delete' => 'delete_things',
'index' => 'view_things'
);
}
public function privilegesCustomer()
{
return array(
'index' => true
);
}
}
?>
备注: 文件名, 班级名称, 文件路径
【讨论】:
或者您可以从此位置编辑用户 API 实体。
app/Tygh/Api/Entities/Users.php
有任何疑问,然后踢我...
【讨论】: