0

Is it possible to render the product view block/template without either performing an ajax request or full product request?

I would like to do something similar to:

$productViewHtml = Mage::app()->getLayout()->createBlock('product.info')->setProduct(1)->toHtml();

For starters, this code doesnt work, therefore i need to resolve that. But the main problem i can see are that different product types require different layout handles which are set in the controller. I can not find any way to achieve.

  • Have you tried using the layout XML equivalent of the code you posted, using <action method="setProduct"><value>1</value</action>? – pspahn Jan 28 '14 at 1:48
1

To do this, you shold replicate viewAction of Mage_Catalog_ProductController. This action uses Mage_Catalog_Helper_Product_View, see it's functions:

public function prepareAndRender($productId, $controller, $params = null)
{
    //product initalization
}

public function initProductLayout($product, $controller)
{
    //most of update handles applies here
}

I am sure you can do this, do some research.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.