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>