次のコードがあります。
$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()));
上記は、phpmyadminで完全に実行され、私が期待する結果を返す実用的なSQLクエリを生成します.
次に、$recipients の数をログに記録します
Mage::log("Loading recipients for queue: {$recipients->count()}");
そして、ここでコードが停止します。実際には、メッセージをログに記録することさえありません。上記のロギング コードをコメント アウトして、
foreach ($recipients as $crm)
{
var_dump($crm);
die();
}
foreach には入りません。パーサーは foreach の前に停止します。
そして最悪なのは、エラー メッセージが表示されないことです。私は真剣に立ち往生しています。
ありがとうございました