2

i want to call other layout and block in my phtml

Block Name:-catalog/product_view

Layout handle:-catalog_product_view

i have used below code but it's not working.

Mage::app()->getLayout()->createBlock('catalog/product_view');

Can any one help me on this problem ?

Any references or suggestions are highly appreciated.

4
  • What is ur exact acquirement?
    – Amit Bera
    Apr 26, 2017 at 9:20
  • i want to print $this->getTierPriceHtml() in my template, for $this i want to call that layout and block. @AmitBera Apr 26, 2017 at 9:23
  • on which page ?
    – Amit Bera
    Apr 26, 2017 at 9:27
  • on my custom template.@AmitBera Apr 26, 2017 at 9:28

2 Answers 2

1

1) On phtml files

$this->getLayout()->createBlock('core/template')->setTemplate('template path')->toHtml(); // change the block type as per your need and change the template path as well.

2) From layout xml

<your_handler>
    <block type="your block" name="name">
     <block type="core/template" name="name here" as="alias here" template="path/here/test.phtml"/>
    </block>
   </your_handler>

Now call the file inside your block. you can call like this $this->getChildHtml(alias name);

1

You can try this

But you should be send few params

$productObject =Mage::getModel('catalog/product')->load('[ProductID]');
$block= Mage::app()->getLayout()->createBlock('catalog/product_view')
          ->setTierPriceTemplate('catalog/product/view/tierprices.phtml')  
        ->getTierPriceHtml($productObject,$this); 

// gerenarate html

 echo $block->toHtml()

Also note: product $productObject should be full product object

7
  • what is $productObject ? Apr 26, 2017 at 9:40
  • means object of product :D . Object of this class Mage_Catalog_Model_Product . +1 from me. Apr 26, 2017 at 9:40
  • yes, need to send product object
    – Amit Bera
    Apr 26, 2017 at 9:42
  • I can only pass the product id or name can you please explain little more.i am beginner in magento. Apr 26, 2017 at 9:50
  • No, you cannot product id .. need to send product means $productObject =Mage::getModel(''catalog/product')->load('productId');
    – Amit Bera
    Apr 26, 2017 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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