我正在尝试从控制器传递数据以在视图中使用。正在发生的事情是我正在为用户选择的产品(尺寸和颜色)获取超级属性,所有这些都被序列化并传递给我获得产品对象的控制器。然后,我可以从这个对象获取可配置的 sku,然后我需要将其回显到设计 view.phtml 文件中。
控制器中的功能如下所示:
if($product = $this->_initProduct())
{
$config = $product->getSku();
// if I echo $config here using firephp I can see that this is correct value
Mage::register('config_product', $config);
// I am hoping to set it as a global variable here that
// I can then retrieve on the success of the ajax function
}
在 phtml 中,我有类似的东西可以将表单值发送到该控制器:
var data = $("#product_addtocart_form").serialize();
$.ajax({
url: "/locator/item/index",
data: data
}).done(function(){
<?php $currentProduct = Mage::registry('config_product');
// Why does this return blank??
?>
<?php Mage::helper('firephp')->send( $currentProduct ); ?>
});