Magento API V2 - add an additional attribute to API response
Asked Answered
F

1

6

I'm using the Magento API V2.

When I call salesOrderCreditmemoInfo, I get a response with the credit memo details and a list of the products associated with the order.

But in the list of product items there is no product_type attribute.

I want to manually edit the response to add this attribute.

I tried editing: app\code\core\Mage\Sales\Model\Order\Creditmemo\Api.php

And replaced:

public function info($creditmemoIncrementId)
{
    ...
    $result['items'] = array();
    foreach ($creditmemo->getAllItems() as $item) {
        $result['items'][] = $this->_getAttributes($item, 'creditmemo_item');
    }

With the following - (basically appending an extra attribute to the array):

 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;
        }

When I do mage::log($result), the extra attribute seems to be added correctly to the array. (also indicating that this function is the one getting called) But it has no impact on the actual API response.

Am I totally looking in the wrong place or is there something else I need to update?

Fetich answered 27/6, 2012 at 8:41 Comment(0)
A
6

Since You were using SOAP V2, you should update the wsdl.xml to get the output.

For your case it is product_type and refresh cache on server. /tmp to load the new wsdl.xml that already updated. don't forget to go to System -> Cache Management clear all cache.

Alderney answered 5/8, 2012 at 18:39 Comment(1)
@Josua could you please suggest some solution for this problem #19811807Diplomatic

© 2022 - 2024 — McMap. All rights reserved.