2016-06-21 9 views
0

Magentoとの統合は完全にSoapClientの周りに構築されています。例えば、出荷はそうのように作成されます。Magentoでは、SOAP経由で注文ID別にインクリメントIDを取得します

$this->_client = @new SoapClient($this->getWsdl(), $context); 
     if ($this->_client) { 
      $this->_session = $this->_client->login($this->magentoUser, $this->magentoKey); 
      return $this; 
     } 

...

$result = $this->_client->salesOrderShipmentCreate(
      $this->_session, 
      $id 
     ); 
return $result; 

と追跡も同様に追加されます。問題は、の更新が必要な場合は、shipment_increment_idが必要です。私たちのシステムから、私はorder_idを引きます。だから私はMagentoに照会して、order_idから関連付けられたshipment_increment_idを取得する必要があります。

だから、this seems to be exactly the solution I needですが、私たちのコードベースにはMageというオブジェクトはありません。私たちは完全にSoapClientを通じて通信しています。 docs on the sales objectを見て、私は実際にここで解決策を見ていません。

MagentoのSOAP API経由で注文IDを使用して出荷IDを取得するにはどうすればよいですか?

+0

をこのSOAPメソッドを呼び出すことができますGoogleの検索結果からは、完全なSOAP APIアプローチがあるhttps://stackoverflow.com/questions/29286210を参照してください。 – user2094178

答えて

1

ソープのデフォルトメソッドを使用すると、注文IDで出荷IDを取得できなくなります。このためには、Mage/Sales/Model/Order/Shipment/Api.phpをオーバーライドし、下記のようにメソッドを拡張する必要があります。アプリ/コード/ローカル/名前空間/ MODULENAMEの/ etc/config.xmlに

<models> 
    <sales> 
     <rewrite> 
      <order_shipment_api>Namespace_Modulename_Model_Sales_Order_Shipment_Api</order_shipment_api> 
     </rewrite> 
    </sales> 
</models> 

今すぐアプリ/コード/ローカル/名前空間/ MODULENAME /モデル/販売/受注/出荷/メソッドを生成Api.php

class Namespace_Modulename_Model_Sales_Order_Shipment_Api extends Mage_Sales_Model_Order_Shipment_Api 
{ 
    /** 
    * Retrieve shipment information 
    * 
    * @param string $shipmentIncrementId 
    * @return array 
    */ 
    public function info($id, $attribute = null) 
    { 
     if(!empty($attribute)){ 
      $ids = Mage::getModel('sales/order_shipment')->getCollection() 
       ->addAttributeToFilter($attribute, $id) 
       ->getAllIds(); 
      if (!empty($ids)) { 
       reset($ids); 
       $shipment = Mage::getModel('sales/order_shipment')->load(current($ids)); 
      } 
     }else{ 
      $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($id); 
     } 

     /* @var $shipment Mage_Sales_Model_Order_Shipment */ 
     if (!$shipment->getId()) { 
      $this->_fault('not_exists'); 
     } 

     $result = $this->_getAttributes($shipment, 'shipment'); 

     $result['items'] = array(); 
     foreach ($shipment->getAllItems() as $item) { 
      $result['items'][] = $this->_getAttributes($item, 'shipment_item'); 
     } 

     $result['tracks'] = array(); 
     foreach ($shipment->getAllTracks() as $track) { 
      $result['tracks'][] = $this->_getAttributes($track, 'shipment_track'); 
     } 

     $result['comments'] = array(); 
     foreach ($shipment->getCommentsCollection() as $comment) { 
      $result['comments'][] = $this->_getAttributes($comment, 'shipment_comment'); 
     } 

     return $result; 
    } 
} 

は今、あなたは(出荷IDを含む)の出荷情報を取得するには、ここコミ着陸人々のため

$result = $this->_client->salesOrderShipmentInfo($sessionId, $orderId, 'order_id'); 
var_dump($result); 
+0

"In app/code/local/Namespace/Modulename/etc/config.xml"これをちょっと拡張できますか?私はMagentoの作業に精通しているだけです。私たちのコードベースはSoapClientを使って構築されています。この答えはMagentoがどこかにインストールされていると仮定していますか? – ShaneOH

+0

はい、純粋にmagentoがどこかにインストールされており、あなたまたはあなたのmagento管理者がmagentoモジュールでこれらのカスタマイズを行う必要があることを意味します。 app/code/local/Namespace/Modulename/etc/config.xmlは、モジュール "Namespace_Modulename"(任意の名前)のメイン構成ファイルです。必要なこのファイルの完全なコードを提供できます。 –

+0

ありがとうございます - 完全なコードは必要ありませんが、私たちのニーズに合わせてMagentoをインストールしてカスタマイズしたいのであれば、私は見ていきます。あなたの答えは助けになり、もう一度感謝します。 – ShaneOH

関連する問題