【问题标题】:magento API v2, extending sales/order classmagento API v2,扩展销售/订单类
【发布时间】:2012-02-08 20:39:53
【问题描述】:

我处理 Magento API v2 已经有几天了。我正在尝试扩展 API 以向订单/销售类添加一个名为“pago”(表示付款)的新方法。 到目前为止,我可以使用 v1 WSDL 来做到这一点,但是在使用 v2 时出现此错误:

程序“salesOrderPago”不存在于...中

我的 WSDL 似乎没问题 (http://www.hijole.com.py/ofertas/index.php/api/v2_soap/?wsdl) 我认为我的错误出现在 我的 api.xml 文件

<?xml version="1.0"?>
<config>
    <api>
        <resources>
            <sales_order translate="title" module="sales">
                <model>sales/order_api</model>
                <title>Order API</title>
                <acl>sales/order</acl>
                <methods>
                    <pago translate="title" module="sales">
                        <title>Acepta un pago</title>
                        <acl>sales/order/create</acl>
                    </pago>                 
                </methods>
            </sales_order>
         </resources>
     <resources_alias>
            <order>sales_order</order>
         </resources_alias>
        <v2>
            <resources_function_prefix>
                <order>salesOrder</order>
            </resources_function_prefix>
        </v2>
    </api>
</config>

这是我的 api/v2.php 文件

<?php
class Neurona_Pagoexpress_Model_Sales_Order_Api_V2 extends Mage_Sales_Model_Order_Api
{
    public function pago($ref, $medio, $moneda, $boleta)
    {
    try{
        //Crea invoice para la orden
        $invoice = Mage::getModel('sales/order_invoice_api');
        $invoice->create($ref, array(), 'PagoExpress - '.$boleta);

        $aut = "4894371870891274"; //Generar con algoritmo
        return array('00','Procedimiento correcto',$aut); // 00 = OK, Pago realizado
    }
    catch (Mage_Core_Exception $e) {
        return array('99'); 
    }
}
}

这是我的 conig.xml 文件

<?xml version="1.0"?>
<config>
    <global>
        <models>
            <sales>
                <rewrite>
                    <order_api>Neurona_Pagoexpress_Model_Sales_Order_Api</order_api>
                    <order_api_v2>Neurona_Pagoexpress_Model_Sales_Order_Api_V2</order_api_v2>
                </rewrite>
            </sales>
        </models>
    </global>
</config>

这是我的 etc/wsdl.xml

    <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
        <message name="salesOrderPagoRequest">
            <part name="sessionId" type="xsd:string" />
            <part name="orderIncrementId" type="xsd:string" />
            <part name="orderMedio" type="xsd:string" />
            <part name="orderMoneda" type="xsd:string" />
            <part name="orderBoleta" type="xsd:string" />
        </message>
        <message name="salesOrderPagoResponse">
            <part name="result" type="typens:ArrayOfString" />
        </message>

        <portType>
            <operation name="salesOrderPago">
                <documentation>Implementa el pago de una factura</documentation>
                <input message="typens:salesOrderPagoRequest" />
                <output message="typens:salesOrderPagoResponse" />
            </operation>
         </portType>

        <binding>
            <operation name="salesOrderPago">
                <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
                <input>
                    <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </input>
                <output>
                    <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
        </binding>
    </definitions>

提前致谢!

【问题讨论】:

  • 是的。这个想法是扩展原生 Magento API。
  • 不知道这样是否正确sales/order/create
  • Jevgeni,感谢您的关注。但是在我向我的托管公司请求支持后,我发现该模块今天可以正常工作。似乎是缓存问题。再次感谢

标签: api magento wsdl


【解决方案1】:

我后来找到了解决方案:只需重新启动 Apache。这似乎是一个 wsdl 缓存问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-12
    • 2014-11-19
    • 1970-01-01
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多