Magento Forum

   
Displaying Product block Or config product Block outside magento
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 

Load Configurable Product options in Simple Product View Page in Magento

If you need to load other product option in some other product with add to cart button at that time you have follow below steps
that is if you need to load some other config product in simple product view page with add to cart option
be sure below code should be paste before or after form, it should not put in side any form else it wont work

?>
<head>

<
script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);; ?>prototype/prototype.js" type="text/javascript"></script>
<script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);; ?>/varien/configurable.js" type="text/javascript"></script>
</head>
<?php
            
<div>
<?php 
      $_detailstabnumber
Mage::getModel('catalog/product')->load(4861); ?>
    
    
<form action="<?php echo $this->getSubmitUrl($_detailstabnumber) ?>" method="post" id="product_addtocart_form_1"<?php if($_detailstabnumber->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
    
<?php

    
# Init Blocks
      
$_detailstabnumberMage::getModel('catalog/product')->load(4861);
        
Mage::unregister('product');
        
Mage::register('product'$_detailstabnumber);

    
$checkoutLinksBlock Mage::app()->getLayout()->getBlockSingleton("catalog/product_view_type_configurable")->setTemplate('catalog/product/view/type/options/configurable.phtml');


    echo 
$checkoutLinksBlock->renderView();
    
?>

        
<div class="add-to-cart">
            <
button onclick="productAddToCartForm_1.submit()" class="button btn-cart" title="Add to Cart" type="button"><span><span>Add to Cart</span></span></button>
        </
div>
</
div>
<
script type="text/javascript">
    
//<![CDATA[
        
var productAddToCartForm_1 = new VarienForm('product_addtocart_form_1');
        
productAddToCartForm_1.submit = function(buttonurl{
            
if (this.validator.validate()) {
                
var form this.form;
                var 
oldUrl form.action;

                if (
url{
                   form
.action url;
                
}
                
var null;
                try 
{
                    this
.form.submit();
                
catch (e{
                }
                this
.form.action oldUrl;
                if (
e{
                    
throw e;
                
}

                
if (button && button != 'undefined'{
                    button
.disabled true;
                
}
            }
        }
.bind(productAddToCartForm_1);

        
productAddToCartForm_1.submitLight = function(buttonurl){
            
if(this.validator{
                
var nv Validation.methods;
                
delete Validation.methods['required-entry'];
                
delete Validation.methods['validate-one-required'];
                
delete Validation.methods['validate-one-required-by-name'];
                
// Remove custom datetime validators
                
for (var methodName in Validation.methods{
                    
if (methodName.match(/^validate-datetime-.*/i)) {
                        delete Validation
.methods[methodName];
                    
}
                }

                
if (this.validator.validate()) {
                    
if (url{
                        this
.form.action url;
                    
}
                    this
.form.submit();
                
}
                Object
.extend(Validation.methodsnv);
            
}
        }
.bind(productAddToCartForm_1);
    
//]]>
</script>
</form>

 
Magento Community Magento Community
Magento Community
Magento Community
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 

We can call product page out side the Magento also
that is Show product-view block in external page
use below code which will give an idea how to call it

<?php 
    define
('MAGENTO'realpath(dirname(__FILE__)));
    require_once 
MAGENTO '/app/Mage.php';
    
 
$app Mage::app('default');
?>
<head>

<
script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);; ?>prototype/prototype.js" type="text/javascript"></script>
<script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);; ?>/varien/configurable.js" type="text/javascript"></script>
</head>
<?php
$app
->getTranslator()->init('frontend'); 

# Init User Session
session_name('frontend');
$session Mage::getSingleton('customer/session');


# Init Blocks
  
$_productMage::getModel('catalog/product')->load(4861);
    
Mage::register('product'$_product);
    
$linksBlock $app->getLayout()->getBlockSingleton("catalog/product_view");

   
$linksBlock->setProduct($_product)->setTemplate('catalog/product/view.phtml') ;
$checkoutLinksBlock $app->getLayout()->getBlockSingleton("catalog/product_view_type_configurable")->setTemplate('catalog/product/view/type/options/configurable.phtml');
$checkoutLinksBlock->setParentBlock($linksBlock);


echo 
$linksBlock->renderView();
echo 
$checkoutLinksBlock->renderView();

File Attachments
configproduct.php  (File Size: 2KB - Downloads: 31)
 
Magento Community Magento Community
Magento Community
Magento Community
 
Running Horse
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2012-06-04
Ahmedabad
 
pradeep_kumar67 - 28 November 2012 01:27 AM

Load Configurable Product options in Simple Product View Page in Magento

If you need to load other product option in some other product with add to cart button at that time you have follow below steps
that is if you need to load some other config product in simple product view page with add to cart option
be sure below code should be paste before or after form, it should not put in side any form else it wont work

?>
<head>

<
script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);; ?>prototype/prototype.js" type="text/javascript"></script>
<script src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);; ?>/varien/configurable.js" type="text/javascript"></script>
</head>
<?php
            
<div>
<?php 
      $_detailstabnumber
Mage::getModel('catalog/product')->load(4861); ?>
    
    
<form action="<?php echo $this->getSubmitUrl($_detailstabnumber) ?>" method="post" id="product_addtocart_form_1"<?php if($_detailstabnumber->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
    
<?php

    
# Init Blocks
      
$_detailstabnumberMage::getModel('catalog/product')->load(4861);
        
Mage::unregister('product');
        
Mage::register('product'$_detailstabnumber);

    
$checkoutLinksBlock Mage::app()->getLayout()->getBlockSingleton("catalog/product_view_type_configurable")->setTemplate('catalog/product/view/type/options/configurable.phtml');


    echo 
$checkoutLinksBlock->renderView();
    
?>

        
<div class="add-to-cart">
            <
button onclick="productAddToCartForm_1.submit()" class="button btn-cart" title="Add to Cart" type="button"><span><span>Add to Cart</span></span></button>
        </
div>
</
div>
<
script type="text/javascript">
    
//<![CDATA[
        
var productAddToCartForm_1 = new VarienForm('product_addtocart_form_1');
        
productAddToCartForm_1.submit = function(buttonurl{
            
if (this.validator.validate()) {
                
var form this.form;
                var 
oldUrl form.action;

                if (
url{
                   form
.action url;
                
}
                
var null;
                try 
{
                    this
.form.submit();
                
catch (e{
                }
                this
.form.action oldUrl;
                if (
e{
                    
throw e;
                
}

                
if (button && button != 'undefined'{
                    button
.disabled true;
                
}
            }
        }
.bind(productAddToCartForm_1);

        
productAddToCartForm_1.submitLight = function(buttonurl){
            
if(this.validator{
                
var nv Validation.methods;
                
delete Validation.methods['required-entry'];
                
delete Validation.methods['validate-one-required'];
                
delete Validation.methods['validate-one-required-by-name'];
                
// Remove custom datetime validators
                
for (var methodName in Validation.methods{
                    
if (methodName.match(/^validate-datetime-.*/i)) {
                        delete Validation
.methods[methodName];
                    
}
                }

                
if (this.validator.validate()) {
                    
if (url{
                        this
.form.action url;
                    
}
                    this
.form.submit();
                
}
                Object
.extend(Validation.methodsnv);
            
}
        }
.bind(productAddToCartForm_1);
    
//]]>
</script>
</form>

nice. it is helpful.
Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top