残念ながら、Mage::register では目的の場所に移動できません。Mage レジストリ キーは、実行中の PHP スクリプトのメモリに保存されるため、PHP コードを実行しているページ リクエストに範囲が限定され、cron と PHTML ファイルの間で共有されません。
探しているものを実現するには、コレクションをハードディスクや Memcache などの永続ストレージにキャッシュする必要があります。次のように、キャッシュする前に特に load() 関数を呼び出す必要がある場合があります。
<?php
// ...
// ... Somewhere in your cron script
$product_collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('some_field', 'some_value');
$product_collection->load(); // Magento kind of "lazy-loads" its data, so
// without this, you might not save yourself
// from executing MySQL code in the PHTML
// Serialize the data so it can be saved to cache as a string
$cacheData = serialize($product_collection);
$cacheKey = 'some sort of unique cache key';
// Save the serialized collection to the cache (defined in app/etc/local.xml)
Mage::app()->getCacheInstance()->save($cacheData, $cacheKey);
次に、PHTML ファイルで次のことを試してください。
<?php
// ...
$cacheKey = 'same unique cache key set in the cron script';
// Load the collection from cache
$product_collection = Mage::app()->getCacheInstance()->load($cacheKey);
// I'm not sure if Magento will auto-unserialize your object, so if
// the cache gives us a string, then we will do it ourselves
if ( is_string($product_collection) ) {
$product_collection = unserialize($product_collectoin);
}
// ...
http://www.magentocommerce.com/boards/viewthread/240836を参照してください。