Get a simple sku and qty product using salesOrderInfo SOAP API in magento

I added the following code in

/app/code/core/Mage/Sales/Model/Order/Api.php

File.

       public function info($orderIncrementId)
        {

------
-------
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
    // get order total value
$orderValue = number_format ($order->getGrandTotal(), 2, '.' , $thousands_sep = '');
    // get order item collection
$orderItems = $order->getItemsCollection();

    $skuQtyArray = array();
    foreach ($orderItems as $item)
    {
        $product_id = $item->product_id;
        $product_sku = $item->sku;
        $product_name = $item->getName();
        $product_qty = $item->getQtyOrdered();
        $_product = Mage::getModel('catalog/product')->load($product_id);
        $cats = $_product->getCategoryIds();
        $category_id = $cats[0]; // just grab the first id
        $category = Mage::getModel('catalog/category')->load($category_id);
        $category_name = $category->getName();

        $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $product_sku);  

        $productType=$product->getTypeID();
        if($productType=='simple')
        {                                                                   
                $skuQtVal = $product_sku."=".$product_qty;                                      
                $skuQtyArray[] = $skuQtVal;                                 
        }

    }

$result['simple_product_skus'] = $skuQtyArray;
    Mage::log($skuQtyArray,null,"logTest.txt",true);

return $result; 
}

But when I run the following code in the root of the application

<?php
$client = new SoapClient('localhost/magento/index.php/api/v2_soap/index?wsdl=1');
$session = $client->login('testuser', 'testuser');

$result = $client ->salesOrderInfo($session, '100000026'); 

print_r($result);
?>

I do not get the changes I made.

Please suggest some solution.

edited by:

My directory structure for overriding the kernel code is as follows.

I my Overridden Api.php, I use it like this.

class Sigma_Sales_Model_Order_Api extends Mage_Sales_Model_Order_Api

Got: I need to override this

class Sigma_Sales_Model_Order_Api_V2 extends Mage_Sales_Model_Order_Api_V2

Because: - Mage_Sales_Model_Order_Api_V2 extends Mage_Sales_Model_Order_Api

+2
source share
2 answers

Mook, you need to go to the application \ code \ core \ Mage \ Sales \ etc and change wsdl.xml and wsi.xml and add an element for sku or whatever you want, according to your requirement.

<element name="sku" type="xsd:string" minOccurs="0" /> //in wsdl.xml
<xsd:element name="sku" type="xsd:string" minOccurs="0" /> //wsi.xml

, .

+4

/app/code/core/Mage/Sales/Model/Order/Api.php

$orderValue = number_format ($order->getGrandTotal(), 2, '.' , $thousands_sep = '');

number_format

$orderValue = number_format($order->getGrandTotal(), 2, '.' , $thousands_sep = '');

, ?


- var/log/logTest.txt, $skuQtyArray?


, .

, Magento , , .

+1

All Articles