我在
/app/code/core/Mage/Sales/Model/Order/Api.php
文件。
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;
}
但是当我在应用程序根目录中运行以下代码时
<?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);
?>
我没有得到我所做的更改。
请提出一些解决方案。
编辑:
我覆盖核心代码的目录结构如下。
我的 Overridden Api.php,我正在使用这样的。
class Sigma_Sales_Model_Order_Api extends Mage_Sales_Model_Order_Api
明白了:我需要像这样覆盖
class Sigma_Sales_Model_Order_Api_V2 extends Mage_Sales_Model_Order_Api_V2
因为:- Mage_Sales_Model_Order_Api_V2 扩展了 Mage_Sales_Model_Order_Api