Hey everyone so in my Magento File structure, in my
app/design/frontend/base/default/template/catalog/product/view/type/options/configurable.phtml
I have:
var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
console.log("spConfig", spConfig);
And that gives me all the beautiful information I need! However why does it not show up if I call this exact same way on
app/design/frontend/default/theme424/template/catalog/product/view.phtml
The interesting thing is when I turn on Template Path Hints in Developer->Configuation->Developer panel they are both on the same page and configurable.phtml is inside the wrapper known as the view.phtml
Best Answer
You might want to look into
Mage_Catalog_Block_Product_View_Type_Configurable::getJsonConfig()
. That's where the json gets generated.Every product view gets rendered in
catalog/product/view.phtml
. Product type specific things like a configurable option dropdown, get rendered incatalog/product/type/options/configurable.phtml
.Why you can't call
$this->getJsonConfig()
inconfigurable.phtml
is because:catalog/product/view.phtml
has the block typeMage_Catalog_Block_Product_View
.catalog/product/type/options/configurable.phtml
has the block typeMage_Catalog_Block_Product_View_Type_Configurable
.getJsonConfig()
is defined inMage_Catalog_Block_Product_View_Type_Configurable