0

I want to fetch all child function of magento outside of it.I have CORE_PHP with some jquery functionality and php function,In that Files,I need to add Product Children Function of magento into that core_php files.How is it possible? I used this code for called magento functionality.

My Idea is product details page html block will be fetch and display outside External file and user will need to customized product Image using HTML5,JS works and make cart as an individual product.(Just like Customized products).On that External page i just fetch product Name, Description, Image and so on using this code

$_product = Mage::getModel('catalog/product')->load($pid);
echo $_product->getName();

I need to get ChildHtml Block (<?php echo $this->getChildHtml('addto') ?>) content into external file (sample.php).How to achieve it.

For example : <?php echo $this->getChildHtml('addto') ?> This ChildHTML function will fetch outside of Magento and this functionality can be modified into custom core PHP file <?php echo Mage::getSingleton('core/layout')->getChildHtml('addto') ?> . But this concept not working in my custom file.So i need to get all childHtml function outside magento. Working example of fetching magento data outside of it.

$base = __DIR__ . '/../';
require_once($base.'/app/Mage.php'); //Path to Magento
umask(0);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));

Mage::app()->loadArea('frontend');

$layout = Mage::getSingleton('core/layout');
Mage::getSingleton('core/translate')->init('sv_SE', true);
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();

//get the loaded head and header blocks and output
$headBlock = $layout->getBlock('head');
$headerBlock = $layout->getBlock('header');
$footerBlock = $layout->getBlock('footer');


echo $headBlock->toHtml() . $headerBlock->toHtml();

// Change 12 to the ID of the product you want to load
$pid = $_REQUEST['pid'];
$_product = Mage::getModel('catalog/product')->load($pid);
echo Mage::getSingleton('core/layout')->getChildHtml('addto');

But No result from ECHO value.Is it proper way for render ChildHTML functionality into external file. Can please guide me..

  • 1
    Could you explain why you're trying to do this? There might be an easier solution. Why this isn't working is because it's missing a LOT of information. To much to just write down in a list – Sander Mangel Sep 30 '15 at 12:24
  • Hi @SanderMangel.. I tried to create customized product image using core PHP concept.So I need to get ChildHtml Block outside Magento and display in external file.I update my question for your understanding..kindly give some idea for this.. – VIVEK-MDU Sep 30 '15 at 12:35
  • 2
    Ah now I understand. But honestly I would do this completely different. Create a controller that displays the block you need within Magento and then user Ajax to load it in on the other page – Sander Mangel Sep 30 '15 at 12:42
  • Yes @SanderMangel.. Honestly ., I just create simple Customized Button in Product details and move forward into External page with same product details like Product name, SKU, Description and etc..using Ajax. On that page, ChildHtml Function like Review ,Price and etc.. not showing on that external page.give some different idea for getting childHtml functionality..? – VIVEK-MDU Sep 30 '15 at 12:56

Your Answer

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

Browse other questions tagged or ask your own question.