服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

获得magento指定customer购买的产品数据

时间:2016-12-19 19:09来源:未知 作者:最模板 点击:
获得magento指定customer 购买的产品信息,如果是configurable的,则取configurable的名字。 $orderedProductsForCustomerData = array(); $orderTable =Mage::getSingleton(core/resource)-getTableName(sales/order); $orderItemTab
获得magento指定customer 购买的产品信息,如果是configurable的,则取configurable的名字。


            $orderedProductsForCustomerData = array();
       
            $orderTable =Mage::getSingleton('core/resource')->getTableName('sales/order');
            $orderItemTable = Mage::getSingleton('core/resource')->getTableName('sales/order_item');
            
            $orderedProductsForCustomers = Mage::getModel('sales/order_item')->getCollection();
            $orderedProductsForCustomers->getSelect()->reset('columns');
            $orderedProductsForCustomers->getSelect()->columns('name');
            $orderedProductsForCustomers->getSelect()->columns('item_id');
            $orderedProductsForCustomers->getSelect()->columns('parent_item_id');
            
            $orderedProductsForCustomers->getSelect()->joinInner(
                  array('orders'=>$orderTable),
                  'main_table.order_id = orders.entity_id',
                  array('product_id'=>'main_table.product_id')
            );
            
            $orderedProductsForCustomers->getSelect()->joinLeft(
                  array('self_table'=>$orderItemTable),
                  'main_table.parent_item_id = self_table.item_id',
                  array()
            );
            
            $orderedProductsForCustomers->getSelect()->where('orders.customer_id=?',$customerId);
            $orderedProductsForCustomers->getSelect()->where('orders.state=?','complete');
            $orderedProductsForCustomers->getSelect()->where('main_table.product_id not in (?)',$reviewedProductIds);
              $orderedProductsForCustomers->getSelect()->where('main_table.parent_item_id is null');
            $orderedProductsForCustomers->getSelect()->distinct();
      
            Mage::log($orderedProductsForCustomers->getSelect().'');
            try{
                  $orderedProductsForCustomerData = $conn->fetchAll($orderedProductsForCustomers->getSelect());
            }
            catch (Exception $e){
                  Mage::logException($e);
            }
 

 

(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容