Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Display Configurable Products on Popup
 
dmcdaniel12
Jr. Member
 
Total Posts:  15
Joined:  2011-12-20
Cincinnati, OH
 

Hello Everyone,

I am trying to display configurable product options on a popup. I am following this tutorial:

http://inchoo.net/ecommerce/magento/display-html-code-blocks-of-product-options-in-magento/

It starts to load it but never loads the option. In Firebug, I get this error:

ReferenceError: Product is not defined
[Break On This Error]

...]},{"id”:"38”,"label”:"11”,"price”:"0”,"oldPrice”:"0”,"products”:["96"]},{"id":"...

Here is my code:

protected function _getOptionSelect(Mage_Catalog_Model_Product $_product)
        
{
            $blockOption 
Mage::app()->getLayout()->createBlock("Mage_Catalog_Block_Product_View_Options");
            
$blockOption->addOptionRenderer("default","catalog/product_view_options_type_default","catalog/product/view/options/type/default.phtml");
            
$blockOption->addOptionRenderer("text","catalog/product_view_options_type_text","inchoo_catalog/product/view/options/type/text.phtml");
            
$blockOption->addOptionRenderer("file","catalog/product_view_options_type_file","catalog/product/view/options/type/file.phtml");
            
$blockOption->addOptionRenderer("select","checkout/product_view_options_type_select","catalog/product/view/options/type/select.phtml");
            
$blockOption->addOptionRenderer("date","catalog/product_view_options_type_date","catalog/product/view/options/type/date.phtml") ;

            
$blockOptionsHtml null;

            if(
$_product->getTypeId()=="simple"||$_product->getTypeId()=="virtual"||$_product->getTypeId()=="configurable")
            
{
            $blockOption
->setProduct($_product);

            if(
$_product->getOptions())
            
{
                
foreach ($_product->getOptions() as $o)
                
{
                    $blockOptionsHtml 
.= $blockOption->getOptionHtml($o);
                
};
            
}
            }

            
if($_product->isConfigurable())
            
{
                
                $blockViewType 
Mage::app()->getLayout()->createBlock("Mage_Catalog_Block_Product_View_Type_Configurable");
                
$blockViewType->setProduct($_product);
                
$blockViewType->setTemplate("catalog/product/view/type/options/configurable.phtml");
                
$blockOptionsHtml .= $blockViewType->toHtml();
            
}
            
return $blockOptionsHtml;
        
}

to display:

<?php
$product 
$this->getProduct();
?>
<?php 
if ($product->isSaleable()):?>
    
<dl>
    
<?php echo $this->_getOptionSelect(Mage::getModel("catalog/product")->load($product->getId())); ?>
    
</dl>
<?php endif;?>

Any ideas?

Thank you!
dmcdaniel12

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