2016-07-18 1 views

答えて

0

私は正しい方法はにあると思う:

  • は、カスタムモジュールを作成
  • 必要なすべての注文の詳細を取得し、外部コール
  • を作っハンドラ内で成功チェックアウト
  • にオブザーバを追加

Magentoは、Googleアナリティクスですぐに使用できる仕事をサポートしています。また、正常にチェックアウトすると、基本的には注文を追跡するために同じことをしています。外部APIはクライアント側で処理される特別なタグをレンダリングします。 app/core/Mage/GoogleAnalyticsにそのモジュールを見ることができます。

0

カスタムモジュールオブザーバでこれを行うことができます。このようにステップごとにカスタムモジュールを作成してください。

/app/etc/modules/Custom_Orderinfo.xml

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Custom_Orderinfo> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Custom_Orderinfo> 
    </modules> 
</config> 

アプリケーション/コード/ローカル/カスタム/ ORDERINFOの/ etc/config.xmlの

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Custom_Orderinfo> 
      <version>0.1.0</version> 
     </Custom_Orderinfo> 
    </modules> 
    <frontend> 
    <events> 
    <checkout_onepage_controller_success_action> 
     <observers> 
      <your_sales_order_observer> 
        <type>singleton</type> 
        <class>orderinfo/observer</class> 
        <method>sendOrderInfo</method> 
      </your_sales_order_observer> 
     </observers> 
    </checkout_onepage_controller_success_action> 
    </events> 
    </frontend> 
    <global> 
     <models> 
      <orderinfo> 
       <class>Custom_Orderinfo_Model</class> 
      </orderinfo> 
     </models> 
     <resources> 
      <orderinfo_setup> 
       <setup> 
        <module>Custom_Orderinfo</module> 
       </setup> 
      </orderinfo_setup> 
     </resources> 
     <helpers> 
      <orderinfo> 
       <class>Custom_Orderinfo_Helper</class> 
      </orderinfo> 
     </helpers> 
    </global> 
</config> 

アプリケーション/コード/ローカル/カスタム/Orderinfo/Model/Observer.php

<?php 

class Custom_Orderinfo_Model_Observer 
{ 
    public function sendOrderInfo($observer) 
    { 
     $event = $observer->getEvent(); 
     $orderIds = $event->getOrderIds(); 

     foreach($orderIds as $orderId) 
     { 
      $order = Mage::getModel('sales/order')->load($orderId); 
      $items=$order->getAllItems(); 
      Mage::log($orderId,null,"order_success.log"); 
      /** 
      * do whatever you want to do here 
      */ 
     } 

    } 
} 

アプリ/コード/ローカル/カスタム/ ORDERINFO /ヘルパー/ Data.php

<?php 
 

 
class Custom_Orderinfo_Helper_Data extends Mage_Core_Helper_Abstract 
 
{ 
 

 
}

運のベスト!

+0

ありがとう、完璧に動作します! – user5841295

+0

あなたは歓迎されています! – sanjeev

+0

さて、私は、注文からではなく請求書自体からの情報でインボイスが作成された後に、外部APIにリクエストを送信する正しい方法が実際にあることを理解しました。私は、このためのモジュールを作成する必要があることを理解しています。「請求書送信」アクションのためのオブザーバー。どのようなアイデアでも、特定のイベントとインボイスの詳細をどのように把握できますか? – user5841295

関連する問題