Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento API V2-向API响应添加附加属性_Api_Magento_Soap - Fatal编程技术网

Magento API V2-向API响应添加附加属性

Magento API V2-向API响应添加附加属性,api,magento,soap,Api,Magento,Soap,我正在使用MagentoAPIv2 当我调用salesOrderCreditmemoInfo时,我会得到一个带有信用备忘录详细信息和与订单关联的产品列表的响应 但是在产品项目列表中没有产品类型属性 我想手动编辑响应以添加此属性 我试着编辑: app\code\core\Mage\Sales\Model\Order\Creditmemo\Api.php 并替换为: public function info($creditmemoIncrementId) { ... $result[

我正在使用MagentoAPIv2

当我调用salesOrderCreditmemoInfo时,我会得到一个带有信用备忘录详细信息和与订单关联的产品列表的响应

但是在产品项目列表中没有产品类型属性

我想手动编辑响应以添加此属性

我试着编辑: app\code\core\Mage\Sales\Model\Order\Creditmemo\Api.php

并替换为:

public function info($creditmemoIncrementId)
{
    ...
    $result['items'] = array();
    foreach ($creditmemo->getAllItems() as $item) {
        $result['items'][] = $this->_getAttributes($item, 'creditmemo_item');
    }
使用以下内容-(基本上是向数组附加一个额外属性):

当我执行mage::log($result)时,额外的属性似乎正确地添加到了数组中。 (还指示此函数是被调用的函数) 但它对实际的API响应没有影响


我是完全找错地方了,还是还有其他东西需要更新?

因为您使用的是SOAPV2,所以应该更新
wsdl.xml
以获得输出


对于您的情况,它是产品类型并刷新服务器上的缓存/tmp加载已更新的新的
wsdl.xml
。不要忘记转到系统->缓存管理清除所有缓存。

@Josua您能为这个问题提出一些解决方案吗
 public function info($creditmemoIncrementId)
    {
      ...
    $result['items'] = array();
    foreach ($creditmemo->getAllItems() as $item) {
            $product_type = '1'; //test value to check if works
            $attribs = $this->_getAttributes($item, 'creditmemo_item');
            $attribs['product_type'] = $product_type;

            $result['items'][] = $attribs;
        }