0
$collection     = $this->_prepareEntityCollection(Mage::getResourceModel('customer/customer_collection'));

    foreach($collection as $customer){
       $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer->getId());
       foreach($_orders as $_ordersitem){

                $orderid    =   $_ordersitem->getEntityId();
                $collection_sales = Mage::getModel('sales/order_item')->load($orderid);
                 $pro_id  =   $collection_sales->getProductId();
                $_product = Mage::getModel('catalog/product')->load($pro_id);
                 echo '<pre>';print_r($_product->getCategoryIds());
        }
    }
1
  • Can you please update what is the process you need to done? Oct 27, 2017 at 12:50

1 Answer 1

0

Try the below query,

SELECT sales_order_item.order_id, sales_order_item.product_id, sales_order.customer_id, catalog_category_product.category_id, catalog_category_entity_varchar.value FROM sales_order_item INNER JOIN sales_order ON sales_order_item.order_id = sales_order.entity_id INNER JOIN catalog_category_product ON sales_order_item.product_id = catalog_category_product.product_id INNER JOIN catalog_category_entity_varchar ON catalog_category_product.category_id = catalog_category_entity_varchar.entity_id GROUP BY catalog_category_product.category_id, sales_order.customer_id

Your Answer

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

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