如何使用magento observer(sales_order_place_after)在自定义表中存储销售数据?

时间:2016-03-29 05:29:19

标签: php magento

请参阅下面的代码

public function send_activation_code(Varien_Event_Observer $observer) {

        $cart = Mage::getModel('checkout/cart')->getQuote()->getData();
        Mage::getModel('sales/order_item')->getCollection();



        if (isset($cart['items_qty'])) {
            $getQty = (int) $cart['items_qty'];
        } else {
            $getQty = '0';
        }

        $order = $observer->getEvent()->getOrder();
        $Order_id = $observer->getEvent()->getOrder()->getId();
        $date = Date('y-m-d');
        $customer_id = $order->getCustomerId();
        $incrementId = $observer->getOrder()->getIncrementId();
        $phone = $observer->getOrder()->getBillingAddress()->getTelephone();
        $getEmail = $observer->getOrder()->getBillingAddress()->getEmail();
        $getFirstname = $observer->getOrder()->getBillingAddress()->getFirstname();
        $getLastname = $observer->getOrder()->getBillingAddress()->getLastname();

    }

2 个答案:

答案 0 :(得分:0)

好吧,您可以使用 checkout_onepage_controller_success_action 事件。

要获得订单详细信息,请在观察者中写下代码。

$order_id = $observer->getData('order_ids');
$orderData = Mage::getModel('sales/order')->load($order_id);

希望这能帮到你!

答案 1 :(得分:0)

您可以使用以下代码获取有关事件sales_order_place_after的订单数据。

       $event = $observer->getEvent(); 
        $order = $event->getOrder();
        $order_id=$order->getEntityId();