如何在magento1中使用汤创建客户登录和注册的API?

时间:2018-06-26 14:11:48

标签: magento-1.7 magento-1.9 magento-1.8

如何在Magento1中运行和构建自定义API?

我尝试过以下代码。 但是无法理解它是如何工作的。

我正在尝试构建扩展的客户注册和登录API。

app / code / local / CH / CustApi / etc / api.xml

<?xml version="1.0"?>
<config>
    <api>
        <resources>
            <custapi_api translate="title" module="custapi">
                <title>Myapi</title>
                <acl>custapi/api</acl>
                <model>custapi/api</model>
                <methods>                    
                        <login translate="title" module="custapi">
                            <title>Customer Login</title>
                            <acl>custapi/login</acl>
                        </login>                    
                        <register translate="title" module="custapi">
                            <title>Customer Register</title>
                            <acl>custapi/register</acl>
                        </register>
                </methods>
            </custapi_api>
        </resources>
        <acl>
            <resources>
                <custapi translate="title" module="custapi">
                    <title>CustApi</title>
                    <sort_order>2000</sort_order>                    
                    <login translate="title" module="custapi">
                        <title>Customer Login</title>
                    </login>                    
                    <register translate="title" module="custapi">
                        <title>Customer Register</title>
                    </register>
                </custapi>
            </resources>
        </acl>
    </api>
</config>

应用/代码/本地/CH/CustApi/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <CH_CustApi>
      <version>1.1.1</version>
    </CH_CustApi>
  </modules>
  <global>
    <helpers>
      <custapi>
        <class>CH_CustApi_Helper</class>
      </custapi>
    </helpers>
    <models>
      <custapi>
        <class>CH_CustApi_Model</class>
        <resourceModel>custapi_mysql4</resourceModel>
      </custapi>
    </models>
  </global>
</config> 

应用程序/代码/本地/CH/CustApi/Helper/Data.php

<?php
class CH_CustApi_Helper_Data extends Mage_Core_Helper_Abstract
{
}

app / code / local / CH / CustApi / Model / Api.php

<?php
class CH_CustApi_Model_Api extends Mage_Api_Model_Resource_Abstract
{        
        public function login(){

        }        
        public function register(){

        }
}

app / etc / modules / CH_CustApi.xml

<?xml version="1.0"?>
<config>
  <modules>
    <CH_CustApi>
      <active>true</active>
      <codePool>local</codePool>            
            <depends>
                <Mage_Api />
            </depends>
      <version>1.1.1</version>
    </CH_CustApi>
  </modules>
</config>

0 个答案:

没有答案