1

グローバル変数をmagentoに登録しようとしましたが、うまくいきません。/app/code/core/Mage/Checkout/controllers/CartController.php に変数を登録します。

Mage::register('g_addressType', $addressType);

$mylog = print_r(Mage::registry('g_addressType'), true);
Mage::log("address_type1:".$mylog, null, 'mygento.log');

$this->_redirect('checkout/onepage/');

/app/code/core/Mage/Checkout/Block/Onepage.php で、この変数を取得しようとしています:

$mylog = print_r(Mage::registry('g_addressType'), true);
Mage::log("address_type2:".$mylog, null, 'mygento.log');
return Mage::registry('g_addressType');

しかし、うまくいきません。私はこのログを取得します:

2013-06-04T13:38:45+00:00 DEBUG (7): address_type1:private
2013-06-04T13:38:51+00:00 DEBUG (7): address_type2:

間違いはどこですか?私はmagento 1.7を使用しています。はい、コア ファイルを変更できないことはわかっています。ありがとう。

4

1 に答える 1