We are creating a custom page in which we are making something of a product wizard and the final step, we want to pull in the product page, really the catalog/product_view
block. Obviously we can create the block and set it in the page with the renderview
method but the problem we are having is its only that block and none of开发者_如何学运维 its children, and since the view.phtml
pulls in a ton of getChildHtml
blocks nothing works.
I am thinking there has to be a way to place the product view block with all of its children in a custom non product page. Without having to create every single child block and their child blocks, is there a way to programmatically pull in all the blocks that are in an xml file like the catalog_product_view
handle in catalog.xml
and place it on another page?
The page we are trying to put it on is a category page using a custom template where we are doing a lot of PHP in the template file to do the wizard.
Have you tried something like this?
//save the product in the registry so the block knows which product to display
$product = Mage::getModel('catalog/product')->load($productId);
Mage::register('product', $product);
//get the block from the layout and render it to html
$Block = Mage::getSingleton('core/layout');
$product_view = $Block->createBlock('catalog/product_view');
$product_view->setTemplate('catalog/product/view.phtml');
$product_view->toHtml();
I've had partial success with this code (part of the product view block is displayed and then I get an error). Hopefully it will point you in the right direction.
精彩评论