1

I need only customer_id, product_id, customer_email

I am using

  <sales_order_place_after>
    <observers>
      <checkout_submit_all_after_handler>
        <type>model</type>
        <class>amxnotif/observer</class>
        <method>getAlertFrontend</method>
      </checkout_submit_all_after_handler>
    </observers>
  </sales_order_place_after>

In Observer.php

public function getAlertFrontend(Varien_Event_Observer $observer)
{
           Mage::log('we are in cataloginventory frontend log start ');
        $event = $observer->getEvent();
        $order = $event->getOrder();

        $orderId = $order->getIncrementId();  // working

        $customer = $order->getCustomer();
        $productId = $order->getProductId();  
        $customer_id = $order->getCustomerId();
        $orderItem = $order->getItem();


        Mage::log("order_data start");
        Mage::log( $order->getEmail() );
        Mage::log( $orderItem );
        Mage::log( $customer_id );
        Mage::log("order_data ends");
        $customerData = Mage::getModel('customer/customer')->load($customer_id);
        $customerName = $customerData->getName();

         Mage::log("customer_data start");
        Mage::log( $customerName );
        Mage::log( $customerData );

        Mage::log("customer_data ends");


        Mage::log(sprintf('Order Id :: %s ,Product Id :: %s Customer Id :: %s ',$orderId, $productId, $customer_id));

           Mage::log('we are in cataloginventory frontend log ends ');

}

But i am only getting DEBUG (7): Order Id:: 100000144, Product Id:: Customer Id::

1 Answer 1

0

For get all order item , you should use $order->getAllItems().

$customerEmail = $order->getCustomerEmail();

if(!$order->getCustomerIsGuest()){
$customerId = $order->getCustomerId();
}
foreach ($order->getAllItems() as $order) {
      $items=array();
      foreach ($order->getAllItems() as $item) {
        $items[] = array(
            'product_id'            => $item->getProductId(),
            'name'          => $item->getName(),
            'sku'           => $item->getSku(),
            'Price'         => $item->getPrice(),
            'Ordered Qty'   => $item->getQtyOrdered(),


        );}
2
  • how to get customer_id, product_id, customer_email,
    – inrsaurabh
    Commented Oct 16, 2017 at 7:16
  • can you suggest how to get getNotifyStockQty() using above available objects
    – inrsaurabh
    Commented Oct 16, 2017 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.