0
我有以下代碼:Magento的資源模型不能正常工作
$recipients = Mage::getResourceModel('crm/crm_collection');
$recipients->getSelect()
->joinInner(array(
'link' => $recipients->getTable('crm/bulkMailLink'),
), "link.crm_id = e.entity_id", array(
'link_id' => 'link.id',
))
->where("link.queue_id = ? AND link.sent_at IS NULL", $queue->getId());
$recipients->addAttributeToSelect('title');
$recipients->addAttributeToSelect('first_name');
$recipients->addAttributeToSelect('chinese_name');
$recipients->addAttributeToSelect('last_name');
$recipients->addAttributeToSelect('email1');
$recipients->addAttributeToFilter('email1', array('neq'=>''));
$recipients->setPageSize(100);
$recipients->setCurPage(1);
我再登錄select語句的代碼產生:
Mage::log("DEBUG: ".((string)$recipients->getSelect()));
上述方法產生,在完全執行工作的SQL查詢phpmyadmin並返回我期望的結果。
我再登錄計數的$收件人
Mage::log("Loading recipients for queue: {$recipients->count()}");
這是代碼結束的地方。實際上它甚至不會記錄消息。如果我註釋掉上面的日誌代碼,並嘗試做一個
foreach ($recipients as $crm)
{
var_dump($crm);
die();
}
它不會進入的foreach。解析器將在foreach之前停止。
最糟糕的是沒有打印出錯信息。我被嚴重卡住了。
謝謝
你先生,是個天才!非常感謝。 – Jason246 2013-05-10 13:49:58