1

Currently i can retrieve my order collection from customer email like this, but it will retrieve all the order and when i print the data there's no information about product items for each order:

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
      $customer = Mage::getSingleton('customer/session')->getCustomer();
      $email = $customer->getEmail();

      $orderCollection = Mage::getModel('sales/order')->getCollection();
      $orderCollection->addFieldToFilter('customer_email', $email);
      echo "<pre>";
      print_r($orderCollection->getData());
}

basically i want to retrieve an order id based on product sku and customer email so i can get the order items, is there a way to do this?

1

Can you try this.

if(Mage::getSingleton('customer/session')->isLoggedIn()) {
    $customer = Mage::getSingleton('customer/session')->getCustomer();
    $email = $customer->getEmail();
    $orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('Customer_email',$email);
    echo "<pre>";
    print_r($orders->getData());

}

recently i try and it's work for me also you can try below code to get product sku

foreach ($orders as $order) {
    $orderdata = Mage::getModel('sales/order')->load($order['entity_id']);
    $orderItems = $orderdata->getItemsCollection();
    foreach ($orderItems as $item) {
        echo "<br>".$item->getSku();

    }
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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