tags:

views:

287

answers:

2

hi guys, is there anyway i can edit the catalog page to make link of a simple product (which is part of a grouped product) to open the grouped products page? any help is appreciated.

To be more clear. There's three products a,b and c which in the group 'abc'. So, in the product list, when a customer click on product 'a', it will be forwarded to (or open), group (abc) page.

A: 

Another vote for this one, please. Any help would be appreciated.

amanda
A: 

Hi guys, let's start with a warning : this is messy, but it works !

This was developped under Magento 1.4.1 for simple products part of a grouped product in the shopping cart. With this, when you click the simple product, it goes to the parent grouped product.

In template/checkout/cart/item/default.phtml, replace :

<?php $_item = $this->getItem() ?>

with :

<?php
$_item = $this->getItem(); 
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
$query = 'SELECT parent_id FROM ' . Mage::getSingleton('core/resource')->getTableName('catalog_product_relation') . ' WHERE child_id = ' . $_item->getProductId();
$parent_id = $read->fetchOne($query);
$_parentItem = Mage::getModel('catalog/product')->load($parent_id);
if ($_item->getProductType() == 'simple' && $_parentItem->getTypeId() == 'grouped') {
 $_itemUrl = $_parentItem->getProductUrl();  
}
else {
 $_itemUrl = $this->getProductUrl();
}
?>

Then a few lines later, replace :

    <h2 class="product-name">
    <?php if ($this->hasProductUrl()):?>
        <a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->htmlEscape($this->getProductName()) ?></a>
    <?php else: ?>
        <?php echo $this->htmlEscape($this->getProductName()) ?>
    <?php endif; ?>
    </h2>

with :

    <h2 class="product-name">
    <?php if ($this->hasProductUrl()):?>
        <a href="<?php echo $_itemUrl ?>"><?php echo $this->htmlEscape($this->getProductName()) ?></a>
    <?php else: ?>
        <?php echo $this->htmlEscape($this->getProductName()) ?>
    <?php endif; ?>
    </h2>
Matthieu Fauveau