2

I created my own template/skin. Simple products show great but others fail. As far as i know, the following lines in the view.phtml allow me to do this:

<?php if ($_product->isSaleable() && $this->hasOptions()):?>
       <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<?php endif;?>

Those above lines should load the catalog/product/view/type/grouped.phtml, but they don't in my template. As i ugly workarround i tried implementing the following in my view.phtml:

<?php if($_product->isGrouped()) { ?>

                            <?php $this->setPreconfiguredValue(); ?>
                            <?php $_associatedProducts = $this->getAssociatedProducts(); ?>
                            <?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
                            <table class="data-table grouped-items-table" id="super-product-table">
                                <col />
                                <col />
                                <col width="1" />
                                <thead>
                                    <tr>
                                        <th><?php echo $this->__('Product Name') ?></th>
                                        <?php if ($this->getCanShowProductPrice($_product)): ?>
                                        <th class="a-right"><?php echo $this->__('Price') ?></th>
                                        <?php endif; ?>
                                        <?php if ($_product->isSaleable()): ?>
                                        <th class="a-center"><?php echo $this->__('Qty') ?></th>
                                        <?php endif; ?>
                                    </tr>
                                </thead>
                                <tbody>
                                <?php if ($_hasAssociatedProducts): ?>
                                <?php foreach ($_associatedProducts as $_item): ?>
                                    <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
                                    <tr>
                                        <td><?php echo $this->htmlEscape($_item->getName()) ?></td>
                                        <?php if ($this->getCanShowProductPrice($_product)): ?>
                                        <td class="a-right">
                                            <?php if ($this->getCanShowProductPrice($_item)): ?>
                                            <?php echo $this->getPriceHtml($_item, true) ?>
                                            <?php echo $this->getTierPriceHtml($_item) ?>
                                            <?php endif; ?>
                                        </td>
                                        <?php endif; ?>
                                        <?php if ($_product->isSaleable()): ?>
                                        <td class="a-center">
                                        <?php if ($_item->isSaleable()) : ?>
                                            <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
                                        <?php else: ?>
                                            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                                        <?php endif; ?>
                                        </td>
                                        <?php endif; ?>
                                    </tr>
                                <?php endforeach; ?>
                                <?php else: ?>
                                   <tr>
                                       <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
                                   </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                            <script type="text/javascript">decorateTable('super-product-table')</script>

                <?php   } ?>

Which is the exact same code as the grouped.phtml but this also fails. Can someone set me in the right direction?

18
  • Are you sure your product options are configured into container2 and not container1 ? Commented Mar 22, 2013 at 13:15
  • @Tim i forgot to metion that i have the same code als this used for container1 above this one. But still no result.
    – RTB
    Commented Mar 22, 2013 at 13:48
  • Are you using local.xml within your theme or are you copying default layout files? Commented Mar 22, 2013 at 14:31
  • @Tim i'm using local.xml
    – RTB
    Commented Mar 22, 2013 at 14:40
  • 1
    Did you diff your templates against the default ones and check the differences? Commented Apr 7, 2013 at 14:27

1 Answer 1

3

Sorry I'm so late to the party, but the issue is likely that you are trying to display the grouped product data with the product.info block which by default is an instance of Mage_Catalog_Block_Product_View:

<catalog_product_view translate="label">
    <!-- ... -->
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
    <!-- ... -->
</catalog_product_view translate="label">

That block & template does not display product-type-specific details directly. Rather, the template echoes the product_type_data block:

<?php echo $this->getChildHtml('product_type_data') ?>

The product_type_data alias is a perfect example of why aliases exist in Magento layouts - it allows blocks to exist in layout (requiring a unique name) yet still be assigned as children of other blocks without needing to have a separate template for each combination. Note all of the type-specific handles in catalog.xml which each specify a type-specific block instance & template, yet all assign these type-specific blocks with the product_type_data alias. In your case, see the grouped product handle PRODUCT_TYPE_grouped:

<PRODUCT_TYPE_grouped translate="label" module="catalog">
    <label>Catalog Product View (Grouped)</label>
    <reference name="product.info">
        <block type="catalog/product_view_type_grouped" name="product.info.grouped" as="product_type_data" template="catalog/product/view/type/grouped.phtml">
            <block type="core/text_list" name="product.info.grouped.extra" as="product_type_data_extra" translate="label">
                <label>Product Extra Info</label>
            </block>
        </block>
    </reference>
</PRODUCT_TYPE_grouped>
2
  • Could you please tell us Only what to do in situation instead of telling all the story ?? Commented Oct 23, 2015 at 7:42
  • @PratikCJoshi - I won't, because I don't know your story. Besides, what I present here is precisely what one needs to know to implement full product display behavior in a new custom theme. If you have a specific question about what is and isn't working in your case, you should ask a new question.
    – benmarks
    Commented Oct 23, 2015 at 13:15

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.