【发布时间】:2016-04-28 13:16:02
【问题描述】:
如何获取特定客户订购的包含特定产品的所有 magento 订单? 我尝试了以下方法:
$customer_id = Mage::getSingleton('customer/session')->getCustomerId();
$customer_eamil = Mage::getSingleton('customer/session')->getCustomerEmail();
$event = $observer->getEvent();
$product = $event->getProduct();
$product->original_price = $product->getPrice();
$productID = $product->getId();
$fromDate = date('Y-m-d H:i:s', strtotime(date('Y-01-01')));
$toDate = date('Y-m-d H:i:s');
$orders = Mage::getResourceModel('sales/order_item_collection')
->addFieldToSelect('*')
->addAttributeToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
->addAttributeToFilter('product_id', array('eq' => $productID))
->addAttributeToFilter('customer_id', $customer_id)
;
但我得到的只是我的 magento error.log 中的一个错误: 带有消息“SQLSTATE [42S22]”的异常“PDOException”:找不到列:1054“where 子句”中的未知列“customer_id”
我正在使用 magent 1.9.2
感谢您的帮助。
【问题讨论】:
-
很明显...在您的数据库中没有包含 customer_id 列的表!
-
是的,我知道。但是我怎样才能将这两个条件结合起来呢?
标签: php magento magento-1.9